From c8479785fc795f29f78c3abe879815fcb5d905ee Mon Sep 17 00:00:00 2001 From: jkummerow Date: Wed, 25 Feb 2015 07:24:29 -0800 Subject: [PATCH] Make ComputeReceiverForNonGlobal faster by checking instance type rather than constructor. BUG=chromium:461734 LOG=n R=verwaest@chromium.org Review URL: https://codereview.chromium.org/953283004 Cr-Commit-Position: refs/heads/master@{#26856} --- src/runtime/runtime-scopes.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc index 201bf9d4c6..9706e1dc98 100644 --- a/src/runtime/runtime-scopes.cc +++ b/src/runtime/runtime-scopes.cc @@ -855,16 +855,14 @@ RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) { static Object* ComputeReceiverForNonGlobal(Isolate* isolate, JSObject* holder) { DCHECK(!holder->IsGlobalObject()); - Context* top = isolate->context(); - // Get the context extension function. - JSFunction* context_extension_function = - top->native_context()->context_extension_function(); + // If the holder isn't a context extension object, we just return it // as the receiver. This allows arguments objects to be used as // receivers, but only if they are put in the context scope chain // explicitly via a with-statement. - Object* constructor = holder->map()->GetConstructor(); - if (constructor != context_extension_function) return holder; + if (holder->map()->instance_type() != JS_CONTEXT_EXTENSION_OBJECT_TYPE) { + return holder; + } // Fall back to using the global object as the implicit receiver if // the property turns out to be a local variable allocated in a // context extension object - introduced via eval.