Simplify and correct logic in CallSite::GetMethodName
SharedFunctionInfo::name is always a String if present (never a Symbol), so there's no need to first test it for IsName() before testing IsString(). This is enforced by a check in %FunctionSetName. As a bonus, the code no longer looks invalid (unconditionally casting a Name to a String). The logic came into this broken-looking state accidentally in the flag cleanup CL https://codereview.chromium.org/2096933002/. Review-Url: https://codereview.chromium.org/2162853003 Cr-Commit-Position: refs/heads/master@{#37914}
This commit is contained in:
parent
dbba4b40be
commit
f1cf71aa4d
@ -261,15 +261,13 @@ Handle<Object> CallSite::GetMethodName() {
|
|||||||
|
|
||||||
Handle<JSObject> obj = Handle<JSObject>::cast(receiver);
|
Handle<JSObject> obj = Handle<JSObject>::cast(receiver);
|
||||||
Handle<Object> function_name(fun_->shared()->name(), isolate_);
|
Handle<Object> function_name(fun_->shared()->name(), isolate_);
|
||||||
if (function_name->IsName()) {
|
if (function_name->IsString()) {
|
||||||
Handle<Name> name = Handle<Name>::cast(function_name);
|
Handle<String> name = Handle<String>::cast(function_name);
|
||||||
// ES2015 gives getters and setters name prefixes which must
|
// ES2015 gives getters and setters name prefixes which must
|
||||||
// be stripped to find the property name.
|
// be stripped to find the property name.
|
||||||
Handle<String> name_string = Handle<String>::cast(name);
|
if (name->IsUtf8EqualTo(CStrVector("get "), true) ||
|
||||||
if (name_string->IsUtf8EqualTo(CStrVector("get "), true) ||
|
name->IsUtf8EqualTo(CStrVector("set "), true)) {
|
||||||
name_string->IsUtf8EqualTo(CStrVector("set "), true)) {
|
name = isolate_->factory()->NewProperSubString(name, 4, name->length());
|
||||||
name = isolate_->factory()->NewProperSubString(name_string, 4,
|
|
||||||
name_string->length());
|
|
||||||
}
|
}
|
||||||
if (CheckMethodName(isolate_, obj, name, fun_,
|
if (CheckMethodName(isolate_, obj, name, fun_,
|
||||||
LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR)) {
|
LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user