Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 5db7165

Browse files
committed
chakrashim: improve hot path calls
- Number of times this call is successful is merely 0 yet it's in the middle of a `GetObjectData` hot path. If `object` is not proxy, we are able to do `HasProperty` discovery without really entering into script. So.. `JsHasProperty` is reasonably faster than `JsGetProperty + isUndefined` calls. - Use fast pointer compare for True/False/Undefined/Null PR-URL: #425 Reviewed-By: Jack Horton <jahorto@microsoft.com> Reviewed-By: Jimmy Thomson <jithomson@microsoft.com>
1 parent 1dca122 commit 5db7165

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

deps/chakrashim/src/v8object.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,9 @@ JsErrorCode Utils::GetObjectData(Object* object, ObjectData** objectData) {
717717
{
718718
JsPropertyIdRef selfSymbolIdRef =
719719
jsrt::IsolateShim::GetCurrent()->GetSelfSymbolPropertyIdRef();
720-
if (selfSymbolIdRef != JS_INVALID_REFERENCE) {
720+
bool hasSelf = false;
721+
if (JsHasProperty(object, selfSymbolIdRef, &hasSelf) != JsNoError &&
722+
hasSelf == true) {
721723
JsValueRef result;
722724
error = JsGetProperty(object, selfSymbolIdRef, &result);
723725
if (error != JsNoError) {

deps/chakrashim/src/v8value.cc

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,23 @@ static bool IsOfType(const Value* ref, JsValueType type) {
4545
}
4646

4747
bool Value::IsUndefined() const {
48-
return IsOfType(this, JsValueType::JsUndefined);
48+
return this == jsrt::GetUndefined();
4949
}
5050

5151
bool Value::IsNull() const {
52-
return IsOfType(this, JsValueType::JsNull);
52+
return this == jsrt::GetNull();
5353
}
5454

5555
bool Value::IsNullOrUndefined() const {
5656
return IsNull() || IsUndefined();
5757
}
5858

5959
bool Value::IsTrue() const {
60-
bool isTrue;
61-
if (JsEquals(jsrt::GetTrue(), (JsValueRef)this, &isTrue) != JsNoError) {
62-
return false;
63-
}
64-
65-
return isTrue;
60+
return this == jsrt::GetTrue();
6661
}
6762

6863
bool Value::IsFalse() const {
69-
bool isFalse;
70-
if (JsEquals(jsrt::GetFalse(), (JsValueRef)this, &isFalse) != JsNoError) {
71-
return false;
72-
}
73-
74-
return isFalse;
64+
return this == jsrt::GetFalse();
7565
}
7666

7767
bool Value::IsString() const {

0 commit comments

Comments
 (0)