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

Commit

Permalink
chakrashim: improve hot path calls
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
Reviewed-By: Jimmy Thomson <[email protected]>
  • Loading branch information
obastemur authored and kfarnung committed Jan 9, 2018
1 parent 9c324bc commit 644a452
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
4 changes: 3 additions & 1 deletion deps/chakrashim/src/v8object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,9 @@ JsErrorCode Utils::GetObjectData(Object* object, ObjectData** objectData) {
{
JsPropertyIdRef selfSymbolIdRef =
jsrt::IsolateShim::GetCurrent()->GetSelfSymbolPropertyIdRef();
if (selfSymbolIdRef != JS_INVALID_REFERENCE) {
bool hasSelf = false;
if (JsHasProperty(object, selfSymbolIdRef, &hasSelf) != JsNoError &&
hasSelf == true) {
JsValueRef result;
error = JsGetProperty(object, selfSymbolIdRef, &result);
if (error != JsNoError) {
Expand Down
18 changes: 4 additions & 14 deletions deps/chakrashim/src/v8value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,23 @@ static bool IsOfType(const Value* ref, JsValueType type) {
}

bool Value::IsUndefined() const {
return IsOfType(this, JsValueType::JsUndefined);
return this == jsrt::GetUndefined();
}

bool Value::IsNull() const {
return IsOfType(this, JsValueType::JsNull);
return this == jsrt::GetNull();
}

bool Value::IsNullOrUndefined() const {
return IsNull() || IsUndefined();
}

bool Value::IsTrue() const {
bool isTrue;
if (JsEquals(jsrt::GetTrue(), (JsValueRef)this, &isTrue) != JsNoError) {
return false;
}

return isTrue;
return this == jsrt::GetTrue();
}

bool Value::IsFalse() const {
bool isFalse;
if (JsEquals(jsrt::GetFalse(), (JsValueRef)this, &isFalse) != JsNoError) {
return false;
}

return isFalse;
return this == jsrt::GetFalse();
}

bool Value::IsString() const {
Expand Down

0 comments on commit 644a452

Please sign in to comment.