| Index: src/ia32/stub-cache-ia32.cc
|
| diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc
|
| index adbef1708495447fa7061b0869283d0fc5a1e8e2..6ab3964b80f75b469e0004d32c0ee75d82e00278 100644
|
| --- a/src/ia32/stub-cache-ia32.cc
|
| +++ b/src/ia32/stub-cache-ia32.cc
|
| @@ -405,11 +405,11 @@ static void CompileCallLoadPropertyWithInterceptor(
|
| Register receiver,
|
| Register holder,
|
| Register name,
|
| - Handle<JSObject> holder_obj) {
|
| + Handle<JSObject> holder_obj,
|
| + IC::UtilityId id) {
|
| PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
|
| __ CallExternalReference(
|
| - ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly),
|
| - masm->isolate()),
|
| + ExternalReference(IC_Utility(id), masm->isolate()),
|
| StubCache::kInterceptorArgsLength);
|
| }
|
|
|
| @@ -645,14 +645,12 @@ static void GenerateFastApiCallBody(MacroAssembler* masm,
|
|
|
| class CallInterceptorCompiler BASE_EMBEDDED {
|
| public:
|
| - CallInterceptorCompiler(StubCompiler* stub_compiler,
|
| + CallInterceptorCompiler(CallStubCompiler* stub_compiler,
|
| const ParameterCount& arguments,
|
| - Register name,
|
| - Code::ExtraICState extra_state)
|
| + Register name)
|
| : stub_compiler_(stub_compiler),
|
| arguments_(arguments),
|
| - name_(name),
|
| - extra_state_(extra_state) {}
|
| + name_(name) {}
|
|
|
| void Compile(MacroAssembler* masm,
|
| Handle<JSObject> object,
|
| @@ -723,9 +721,10 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| Label miss_cleanup;
|
| Label* miss = can_do_fast_api_call ? &miss_cleanup : miss_label;
|
| Register holder =
|
| - stub_compiler_->CheckPrototypes(object, receiver, interceptor_holder,
|
| - scratch1, scratch2, scratch3,
|
| - name, depth1, miss);
|
| + stub_compiler_->CheckPrototypes(
|
| + IC::CurrentTypeOf(object, masm->isolate()), receiver,
|
| + interceptor_holder, scratch1, scratch2, scratch3,
|
| + name, depth1, miss);
|
|
|
| // Invoke an interceptor and if it provides a value,
|
| // branch to |regular_invoke|.
|
| @@ -739,10 +738,10 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| // Check that the maps from interceptor's holder to constant function's
|
| // holder haven't changed and thus we can use cached constant function.
|
| if (*interceptor_holder != lookup->holder()) {
|
| - stub_compiler_->CheckPrototypes(interceptor_holder, receiver,
|
| - Handle<JSObject>(lookup->holder()),
|
| - scratch1, scratch2, scratch3,
|
| - name, depth2, miss);
|
| + stub_compiler_->CheckPrototypes(
|
| + IC::CurrentTypeOf(interceptor_holder, masm->isolate()), holder,
|
| + handle(lookup->holder()), scratch1, scratch2, scratch3,
|
| + name, depth2, miss);
|
| } else {
|
| // CheckPrototypes has a side effect of fetching a 'holder'
|
| // for API (object which is instanceof for the signature). It's
|
| @@ -755,13 +754,8 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| if (can_do_fast_api_call) {
|
| GenerateFastApiCall(masm, optimization, arguments_.immediate());
|
| } else {
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| - Handle<JSFunction> function = optimization.constant_function();
|
| - ParameterCount expected(function);
|
| - __ InvokeFunction(function, expected, arguments_,
|
| - JUMP_FUNCTION, NullCallWrapper(), call_kind);
|
| + Handle<JSFunction> fun = optimization.constant_function();
|
| + stub_compiler_->GenerateJumpFunction(object, fun);
|
| }
|
|
|
| // Deferred code for fast API call case---clean preallocated space.
|
| @@ -788,20 +782,17 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| Handle<JSObject> interceptor_holder,
|
| Label* miss_label) {
|
| Register holder =
|
| - stub_compiler_->CheckPrototypes(object, receiver, interceptor_holder,
|
| - scratch1, scratch2, scratch3,
|
| - name, miss_label);
|
| + stub_compiler_->CheckPrototypes(
|
| + IC::CurrentTypeOf(object, masm->isolate()), receiver,
|
| + interceptor_holder, scratch1, scratch2, scratch3, name, miss_label);
|
|
|
| FrameScope scope(masm, StackFrame::INTERNAL);
|
| // Save the name_ register across the call.
|
| __ push(name_);
|
|
|
| - PushInterceptorArguments(masm, receiver, holder, name_, interceptor_holder);
|
| -
|
| - __ CallExternalReference(
|
| - ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorForCall),
|
| - masm->isolate()),
|
| - StubCache::kInterceptorArgsLength);
|
| + CompileCallLoadPropertyWithInterceptor(
|
| + masm, receiver, holder, name_, interceptor_holder,
|
| + IC::kLoadPropertyWithInterceptorForCall);
|
|
|
| // Restore the name_ register.
|
| __ pop(name_);
|
| @@ -816,17 +807,17 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| Label* interceptor_succeeded) {
|
| {
|
| FrameScope scope(masm, StackFrame::INTERNAL);
|
| - __ push(holder); // Save the holder.
|
| - __ push(name_); // Save the name.
|
| + __ push(receiver);
|
| + __ push(holder);
|
| + __ push(name_);
|
|
|
| - CompileCallLoadPropertyWithInterceptor(masm,
|
| - receiver,
|
| - holder,
|
| - name_,
|
| - holder_obj);
|
| + CompileCallLoadPropertyWithInterceptor(
|
| + masm, receiver, holder, name_, holder_obj,
|
| + IC::kLoadPropertyWithInterceptorOnly);
|
|
|
| - __ pop(name_); // Restore the name.
|
| - __ pop(receiver); // Restore the holder.
|
| + __ pop(name_);
|
| + __ pop(holder);
|
| + __ pop(receiver);
|
| // Leave the internal frame.
|
| }
|
|
|
| @@ -834,10 +825,9 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| __ j(not_equal, interceptor_succeeded);
|
| }
|
|
|
| - StubCompiler* stub_compiler_;
|
| + CallStubCompiler* stub_compiler_;
|
| const ParameterCount& arguments_;
|
| Register name_;
|
| - Code::ExtraICState extra_state_;
|
| };
|
|
|
|
|
| @@ -1184,26 +1174,6 @@ void StoreStubCompiler::GenerateStoreField(MacroAssembler* masm,
|
| }
|
|
|
|
|
| -void StubCompiler::GenerateCheckPropertyCells(MacroAssembler* masm,
|
| - Handle<JSObject> object,
|
| - Handle<JSObject> holder,
|
| - Handle<Name> name,
|
| - Register scratch,
|
| - Label* miss) {
|
| - Handle<JSObject> current = object;
|
| - while (!current.is_identical_to(holder)) {
|
| - if (current->IsJSGlobalObject()) {
|
| - GenerateCheckPropertyCell(masm,
|
| - Handle<JSGlobalObject>::cast(current),
|
| - name,
|
| - scratch,
|
| - miss);
|
| - }
|
| - current = Handle<JSObject>(JSObject::cast(current->GetPrototype()));
|
| - }
|
| -}
|
| -
|
| -
|
| void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
|
| __ jmp(code, RelocInfo::CODE_TARGET);
|
| }
|
| @@ -1213,7 +1183,7 @@ void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
|
| #define __ ACCESS_MASM(masm())
|
|
|
|
|
| -Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
| +Register StubCompiler::CheckPrototypes(Handle<Type> type,
|
| Register object_reg,
|
| Handle<JSObject> holder,
|
| Register holder_reg,
|
| @@ -1223,12 +1193,11 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
| int save_at_depth,
|
| Label* miss,
|
| PrototypeCheckType check) {
|
| - const int kHolderIndex = FunctionCallbackArguments::kHolderIndex + 1;
|
| + Handle<Map> receiver_map(IC::TypeToMap(*type, isolate()));
|
| // Make sure that the type feedback oracle harvests the receiver map.
|
| // TODO(svenpanne) Remove this hack when all ICs are reworked.
|
| - __ mov(scratch1, Handle<Map>(object->map()));
|
| + __ mov(scratch1, receiver_map);
|
|
|
| - Handle<JSObject> first = object;
|
| // Make sure there's no overlap between holder and object registers.
|
| ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
|
| ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg)
|
| @@ -1236,31 +1205,38 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
|
|
| // Keep track of the current object in register reg.
|
| Register reg = object_reg;
|
| - Handle<JSObject> current = object;
|
| int depth = 0;
|
|
|
| + const int kHolderIndex = FunctionCallbackArguments::kHolderIndex + 1;
|
| if (save_at_depth == depth) {
|
| __ mov(Operand(esp, kHolderIndex * kPointerSize), reg);
|
| }
|
|
|
| + Handle<JSObject> current = Handle<JSObject>::null();
|
| + if (type->IsConstant()) current = Handle<JSObject>::cast(type->AsConstant());
|
| + Handle<JSObject> prototype = Handle<JSObject>::null();
|
| + Handle<Map> current_map = receiver_map;
|
| + Handle<Map> holder_map(holder->map());
|
| // Traverse the prototype chain and check the maps in the prototype chain for
|
| // fast and global objects or do negative lookup for normal objects.
|
| - while (!current.is_identical_to(holder)) {
|
| + while (!current_map.is_identical_to(holder_map)) {
|
| ++depth;
|
|
|
| // Only global objects and objects that do not require access
|
| // checks are allowed in stubs.
|
| - ASSERT(current->IsJSGlobalProxy() || !current->IsAccessCheckNeeded());
|
| + ASSERT(current_map->IsJSGlobalProxyMap() ||
|
| + !current_map->is_access_check_needed());
|
|
|
| - Handle<JSObject> prototype(JSObject::cast(current->GetPrototype()));
|
| - if (!current->HasFastProperties() &&
|
| - !current->IsJSGlobalObject() &&
|
| - !current->IsJSGlobalProxy()) {
|
| + prototype = handle(JSObject::cast(current_map->prototype()));
|
| + if (current_map->is_dictionary_map() &&
|
| + !current_map->IsJSGlobalObjectMap() &&
|
| + !current_map->IsJSGlobalProxyMap()) {
|
| if (!name->IsUniqueName()) {
|
| ASSERT(name->IsString());
|
| name = factory()->InternalizeString(Handle<String>::cast(name));
|
| }
|
| - ASSERT(current->property_dictionary()->FindEntry(*name) ==
|
| + ASSERT(current.is_null() ||
|
| + current->property_dictionary()->FindEntry(*name) ==
|
| NameDictionary::kNotFound);
|
|
|
| GenerateDictionaryNegativeLookup(masm(), miss, reg, name,
|
| @@ -1271,16 +1247,19 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
| __ mov(reg, FieldOperand(scratch1, Map::kPrototypeOffset));
|
| } else {
|
| bool in_new_space = heap()->InNewSpace(*prototype);
|
| - Handle<Map> current_map(current->map());
|
| - if (!current.is_identical_to(first) || check == CHECK_ALL_MAPS) {
|
| + if (depth != 1 || check == CHECK_ALL_MAPS) {
|
| __ CheckMap(reg, current_map, miss, DONT_DO_SMI_CHECK);
|
| }
|
|
|
| // Check access rights to the global object. This has to happen after
|
| // the map check so that we know that the object is actually a global
|
| // object.
|
| - if (current->IsJSGlobalProxy()) {
|
| + if (current_map->IsJSGlobalProxyMap()) {
|
| __ CheckAccessGlobalProxy(reg, scratch1, scratch2, miss);
|
| + } else if (current_map->IsJSGlobalObjectMap()) {
|
| + GenerateCheckPropertyCell(
|
| + masm(), Handle<JSGlobalObject>::cast(current), name,
|
| + scratch2, miss);
|
| }
|
|
|
| if (in_new_space) {
|
| @@ -1306,28 +1285,24 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
|
|
| // Go to the next object in the prototype chain.
|
| current = prototype;
|
| + current_map = handle(current->map());
|
| }
|
| - ASSERT(current.is_identical_to(holder));
|
|
|
| // Log the check depth.
|
| LOG(isolate(), IntEvent("check-maps-depth", depth + 1));
|
|
|
| - if (!holder.is_identical_to(first) || check == CHECK_ALL_MAPS) {
|
| + if (depth != 0 || check == CHECK_ALL_MAPS) {
|
| // Check the holder map.
|
| - __ CheckMap(reg, Handle<Map>(holder->map()), miss, DONT_DO_SMI_CHECK);
|
| + __ CheckMap(reg, current_map, miss, DONT_DO_SMI_CHECK);
|
| }
|
|
|
| // Perform security check for access to the global object.
|
| - ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded());
|
| - if (holder->IsJSGlobalProxy()) {
|
| + ASSERT(current_map->IsJSGlobalProxyMap() ||
|
| + !current_map->is_access_check_needed());
|
| + if (current_map->IsJSGlobalProxyMap()) {
|
| __ CheckAccessGlobalProxy(reg, scratch1, scratch2, miss);
|
| }
|
|
|
| - // If we've skipped any global objects, it's not enough to verify that
|
| - // their maps haven't changed. We also need to check that the property
|
| - // cell for the property is still empty.
|
| - GenerateCheckPropertyCells(masm(), object, holder, name, scratch1, miss);
|
| -
|
| // Return the register containing the holder.
|
| return reg;
|
| }
|
| @@ -1356,14 +1331,14 @@ void StoreStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
|
|
|
|
|
| Register LoadStubCompiler::CallbackHandlerFrontend(
|
| - Handle<Object> object,
|
| + Handle<Type> type,
|
| Register object_reg,
|
| Handle<JSObject> holder,
|
| Handle<Name> name,
|
| Handle<Object> callback) {
|
| Label miss;
|
|
|
| - Register reg = HandlerFrontendHeader(object, object_reg, holder, name, &miss);
|
| + Register reg = HandlerFrontendHeader(type, object_reg, holder, name, &miss);
|
|
|
| if (!holder->HasFastProperties() && !holder->IsJSGlobalObject()) {
|
| ASSERT(!reg.is(scratch2()));
|
| @@ -1567,11 +1542,9 @@ void LoadStubCompiler::GenerateLoadInterceptor(
|
| // Invoke an interceptor. Note: map checks from receiver to
|
| // interceptor's holder has been compiled before (see a caller
|
| // of this method.)
|
| - CompileCallLoadPropertyWithInterceptor(masm(),
|
| - receiver(),
|
| - holder_reg,
|
| - this->name(),
|
| - interceptor_holder);
|
| + CompileCallLoadPropertyWithInterceptor(
|
| + masm(), receiver(), holder_reg, this->name(), interceptor_holder,
|
| + IC::kLoadPropertyWithInterceptorOnly);
|
|
|
| // Check if interceptor provided a value for property. If it's
|
| // the case, return immediately.
|
| @@ -1623,22 +1596,12 @@ void CallStubCompiler::GenerateNameCheck(Handle<Name> name, Label* miss) {
|
| }
|
|
|
|
|
| -void CallStubCompiler::GenerateGlobalReceiverCheck(Handle<JSObject> object,
|
| - Handle<JSObject> holder,
|
| - Handle<Name> name,
|
| - Label* miss) {
|
| - ASSERT(holder->IsGlobalObject());
|
| -
|
| - // Get the number of arguments.
|
| - const int argc = arguments().immediate();
|
| -
|
| - // Get the receiver from the stack.
|
| - __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
|
| -
|
| -
|
| - // Check that the maps haven't changed.
|
| - __ JumpIfSmi(edx, miss);
|
| - CheckPrototypes(object, edx, holder, ebx, eax, edi, name, miss);
|
| +void CallStubCompiler::GenerateFunctionCheck(Register function,
|
| + Register scratch,
|
| + Label* miss) {
|
| + __ JumpIfSmi(function, miss);
|
| + __ CmpObjectType(function, JS_FUNCTION_TYPE, scratch);
|
| + __ j(not_equal, miss);
|
| }
|
|
|
|
|
| @@ -1661,9 +1624,7 @@ void CallStubCompiler::GenerateLoadFunctionFromCell(
|
| // the nice side effect that multiple closures based on the same
|
| // function can all use this call IC. Before we load through the
|
| // function, we have to verify that it still is a function.
|
| - __ JumpIfSmi(edi, miss);
|
| - __ CmpObjectType(edi, JS_FUNCTION_TYPE, ebx);
|
| - __ j(not_equal, miss);
|
| + GenerateFunctionCheck(edi, ebx, miss);
|
|
|
| // Check the shared function info. Make sure it hasn't changed.
|
| __ cmp(FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset),
|
| @@ -1679,7 +1640,7 @@ void CallStubCompiler::GenerateMissBranch() {
|
| Handle<Code> code =
|
| isolate()->stub_cache()->ComputeCallMiss(arguments().immediate(),
|
| kind_,
|
| - extra_state_);
|
| + extra_state());
|
| __ jmp(code, RelocInfo::CODE_TARGET);
|
| }
|
|
|
| @@ -1688,54 +1649,17 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object,
|
| Handle<JSObject> holder,
|
| PropertyIndex index,
|
| Handle<Name> name) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| Label miss;
|
|
|
| - GenerateNameCheck(name, &miss);
|
| -
|
| - // Get the receiver from the stack.
|
| - const int argc = arguments().immediate();
|
| - __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
|
| -
|
| - // Check that the receiver isn't a smi.
|
| - __ JumpIfSmi(edx, &miss);
|
| -
|
| - // Do the right check and compute the holder register.
|
| - Register reg = CheckPrototypes(object, edx, holder, ebx, eax, edi,
|
| - name, &miss);
|
| + Register reg = HandlerFrontendHeader(
|
| + object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
|
|
| GenerateFastPropertyLoad(
|
| masm(), edi, reg, index.is_inobject(holder),
|
| index.translate(holder), Representation::Tagged());
|
| + GenerateJumpFunction(object, edi, &miss);
|
|
|
| - // Check that the function really is a function.
|
| - __ JumpIfSmi(edi, &miss);
|
| - __ CmpObjectType(edi, JS_FUNCTION_TYPE, ebx);
|
| - __ j(not_equal, &miss);
|
| -
|
| - // Patch the receiver on the stack with the global proxy if
|
| - // necessary.
|
| - if (object->IsGlobalObject()) {
|
| - __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset));
|
| - __ mov(Operand(esp, (argc + 1) * kPointerSize), edx);
|
| - }
|
| -
|
| - // Invoke the function.
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| - __ InvokeFunction(edi, arguments(), JUMP_FUNCTION,
|
| - NullCallWrapper(), call_kind);
|
| -
|
| - // Handle call cache miss.
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(Code::FAST, name);
|
| @@ -1751,28 +1675,16 @@ Handle<Code> CallStubCompiler::CompileArrayCodeCall(
|
| Code::StubType type) {
|
| Label miss;
|
|
|
| - // Check that function is still array
|
| - const int argc = arguments().immediate();
|
| - GenerateNameCheck(name, &miss);
|
| -
|
| - if (cell.is_null()) {
|
| - // Get the receiver from the stack.
|
| - __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
|
| -
|
| - // Check that the receiver isn't a smi.
|
| - __ JumpIfSmi(edx, &miss);
|
| - CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi,
|
| - name, &miss);
|
| - } else {
|
| + HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
| + if (!cell.is_null()) {
|
| ASSERT(cell->value() == *function);
|
| - GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name,
|
| - &miss);
|
| GenerateLoadFunctionFromCell(cell, function, &miss);
|
| }
|
|
|
| Handle<AllocationSite> site = isolate()->factory()->NewAllocationSite();
|
| site->SetElementsKind(GetInitialFastElementsKind());
|
| Handle<Cell> site_feedback_cell = isolate()->factory()->NewCell(site);
|
| + const int argc = arguments().immediate();
|
| __ mov(eax, Immediate(argc));
|
| __ mov(ebx, site_feedback_cell);
|
| __ mov(edi, function);
|
| @@ -1780,8 +1692,7 @@ Handle<Code> CallStubCompiler::CompileArrayCodeCall(
|
| ArrayConstructorStub stub(isolate());
|
| __ TailCallStub(&stub);
|
|
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -1795,35 +1706,20 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| - // If object is not an array or is observed, bail out to regular call.
|
| + // If object is not an array or is observed or sealed, bail out to regular
|
| + // call.
|
| if (!object->IsJSArray() ||
|
| !cell.is_null() ||
|
| - Handle<JSArray>::cast(object)->map()->is_observed()) {
|
| + Handle<JSArray>::cast(object)->map()->is_observed() ||
|
| + !Handle<JSArray>::cast(object)->map()->is_extensible()) {
|
| return Handle<Code>::null();
|
| }
|
|
|
| Label miss;
|
|
|
| - GenerateNameCheck(name, &miss);
|
| + HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
|
|
| - // Get the receiver from the stack.
|
| const int argc = arguments().immediate();
|
| - __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
|
| -
|
| - // Check that the receiver isn't a smi.
|
| - __ JumpIfSmi(edx, &miss);
|
| -
|
| - CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi,
|
| - name, &miss);
|
| -
|
| if (argc == 0) {
|
| // Noop, return the length.
|
| __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset));
|
| @@ -2041,8 +1937,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
| 1);
|
| }
|
|
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2056,33 +1951,18 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| - // If object is not an array or is observed, bail out to regular call.
|
| + // If object is not an array or is observed or sealed, bail out to regular
|
| + // call.
|
| if (!object->IsJSArray() ||
|
| !cell.is_null() ||
|
| - Handle<JSArray>::cast(object)->map()->is_observed()) {
|
| + Handle<JSArray>::cast(object)->map()->is_observed() ||
|
| + !Handle<JSArray>::cast(object)->map()->is_extensible()) {
|
| return Handle<Code>::null();
|
| }
|
|
|
| Label miss, return_undefined, call_builtin;
|
|
|
| - GenerateNameCheck(name, &miss);
|
| -
|
| - // Get the receiver from the stack.
|
| - const int argc = arguments().immediate();
|
| - __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
|
| -
|
| - // Check that the receiver isn't a smi.
|
| - __ JumpIfSmi(edx, &miss);
|
| - CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi,
|
| - name, &miss);
|
| + HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
|
|
| // Get the elements array of the object.
|
| __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset));
|
| @@ -2114,6 +1994,7 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
|
| ecx, times_half_pointer_size,
|
| FixedArray::kHeaderSize),
|
| Immediate(factory()->the_hole_value()));
|
| + const int argc = arguments().immediate();
|
| __ ret((argc + 1) * kPointerSize);
|
|
|
| __ bind(&return_undefined);
|
| @@ -2126,8 +2007,7 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
|
| argc + 1,
|
| 1);
|
|
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2141,14 +2021,6 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : function name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| // If object is not a string, bail out to regular call.
|
| if (!object->IsString() || !cell.is_null()) {
|
| return Handle<Code>::null();
|
| @@ -2162,22 +2034,12 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
|
| Label* index_out_of_range_label = &index_out_of_range;
|
|
|
| if (kind_ == Code::CALL_IC &&
|
| - (CallICBase::StringStubState::decode(extra_state_) ==
|
| + (CallICBase::StringStubState::decode(extra_state()) ==
|
| DEFAULT_STRING_STUB)) {
|
| index_out_of_range_label = &miss;
|
| }
|
|
|
| - GenerateNameCheck(name, &name_miss);
|
| -
|
| - // Check that the maps starting from the prototype haven't changed.
|
| - GenerateDirectLoadGlobalFunctionPrototype(masm(),
|
| - Context::STRING_FUNCTION_INDEX,
|
| - eax,
|
| - &miss);
|
| - ASSERT(!object.is_identical_to(holder));
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - eax, holder, ebx, edx, edi, name, &miss);
|
| + HandlerFrontendHeader(object, holder, name, STRING_CHECK, &name_miss);
|
|
|
| Register receiver = ebx;
|
| Register index = edi;
|
| @@ -2211,8 +2073,7 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
|
| __ bind(&miss);
|
| // Restore function name in ecx.
|
| __ Set(ecx, Immediate(name));
|
| - __ bind(&name_miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&name_miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2226,14 +2087,6 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : function name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| // If object is not a string, bail out to regular call.
|
| if (!object->IsString() || !cell.is_null()) {
|
| return Handle<Code>::null();
|
| @@ -2247,22 +2100,12 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
|
| Label* index_out_of_range_label = &index_out_of_range;
|
|
|
| if (kind_ == Code::CALL_IC &&
|
| - (CallICBase::StringStubState::decode(extra_state_) ==
|
| + (CallICBase::StringStubState::decode(extra_state()) ==
|
| DEFAULT_STRING_STUB)) {
|
| index_out_of_range_label = &miss;
|
| }
|
|
|
| - GenerateNameCheck(name, &name_miss);
|
| -
|
| - // Check that the maps starting from the prototype haven't changed.
|
| - GenerateDirectLoadGlobalFunctionPrototype(masm(),
|
| - Context::STRING_FUNCTION_INDEX,
|
| - eax,
|
| - &miss);
|
| - ASSERT(!object.is_identical_to(holder));
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - eax, holder, ebx, edx, edi, name, &miss);
|
| + HandlerFrontendHeader(object, holder, name, STRING_CHECK, &name_miss);
|
|
|
| Register receiver = eax;
|
| Register index = edi;
|
| @@ -2298,8 +2141,7 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
|
| __ bind(&miss);
|
| // Restore function name in ecx.
|
| __ Set(ecx, Immediate(name));
|
| - __ bind(&name_miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&name_miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2313,14 +2155,6 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : function name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| const int argc = arguments().immediate();
|
|
|
| // If the object is not a JSObject or we got an unexpected number of
|
| @@ -2330,18 +2164,10 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
|
| }
|
|
|
| Label miss;
|
| - GenerateNameCheck(name, &miss);
|
|
|
| - if (cell.is_null()) {
|
| - __ mov(edx, Operand(esp, 2 * kPointerSize));
|
| - STATIC_ASSERT(kSmiTag == 0);
|
| - __ JumpIfSmi(edx, &miss);
|
| - CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi,
|
| - name, &miss);
|
| - } else {
|
| + HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
| + if (!cell.is_null()) {
|
| ASSERT(cell->value() == *function);
|
| - GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name,
|
| - &miss);
|
| GenerateLoadFunctionFromCell(cell, function, &miss);
|
| }
|
|
|
| @@ -2364,19 +2190,12 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
|
| StubRuntimeCallHelper call_helper;
|
| generator.GenerateSlow(masm(), call_helper);
|
|
|
| - // Tail call the full function. We do not have to patch the receiver
|
| - // because the function makes no use of it.
|
| __ bind(&slow);
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| - ParameterCount expected(function);
|
| - __ InvokeFunction(function, expected, arguments(),
|
| - JUMP_FUNCTION, NullCallWrapper(), call_kind);
|
| + // We do not have to patch the receiver because the function makes no use of
|
| + // it.
|
| + GenerateJumpFunctionIgnoreReceiver(function);
|
|
|
| - __ bind(&miss);
|
| - // ecx: function name.
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2390,14 +2209,6 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| if (!CpuFeatures::IsSupported(SSE2)) {
|
| return Handle<Code>::null();
|
| }
|
| @@ -2413,20 +2224,10 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall(
|
| }
|
|
|
| Label miss;
|
| - GenerateNameCheck(name, &miss);
|
| -
|
| - if (cell.is_null()) {
|
| - __ mov(edx, Operand(esp, 2 * kPointerSize));
|
| -
|
| - STATIC_ASSERT(kSmiTag == 0);
|
| - __ JumpIfSmi(edx, &miss);
|
|
|
| - CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi,
|
| - name, &miss);
|
| - } else {
|
| + HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
| + if (!cell.is_null()) {
|
| ASSERT(cell->value() == *function);
|
| - GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name,
|
| - &miss);
|
| GenerateLoadFunctionFromCell(cell, function, &miss);
|
| }
|
|
|
| @@ -2499,16 +2300,12 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall(
|
| __ mov(eax, Operand(esp, 1 * kPointerSize));
|
| __ ret(2 * kPointerSize);
|
|
|
| - // Tail call the full function. We do not have to patch the receiver
|
| - // because the function makes no use of it.
|
| __ bind(&slow);
|
| - ParameterCount expected(function);
|
| - __ InvokeFunction(function, expected, arguments(),
|
| - JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD);
|
| + // We do not have to patch the receiver because the function makes no use of
|
| + // it.
|
| + GenerateJumpFunctionIgnoreReceiver(function);
|
|
|
| - __ bind(&miss);
|
| - // ecx: function name.
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2522,14 +2319,6 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| const int argc = arguments().immediate();
|
|
|
| // If the object is not a JSObject or we got an unexpected number of
|
| @@ -2539,20 +2328,10 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
|
| }
|
|
|
| Label miss;
|
| - GenerateNameCheck(name, &miss);
|
| -
|
| - if (cell.is_null()) {
|
| - __ mov(edx, Operand(esp, 2 * kPointerSize));
|
|
|
| - STATIC_ASSERT(kSmiTag == 0);
|
| - __ JumpIfSmi(edx, &miss);
|
| -
|
| - CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi,
|
| - name, &miss);
|
| - } else {
|
| + HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
| + if (!cell.is_null()) {
|
| ASSERT(cell->value() == *function);
|
| - GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name,
|
| - &miss);
|
| GenerateLoadFunctionFromCell(cell, function, &miss);
|
| }
|
|
|
| @@ -2608,16 +2387,12 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
|
| __ mov(FieldOperand(eax, HeapNumber::kMantissaOffset), ecx);
|
| __ ret(2 * kPointerSize);
|
|
|
| - // Tail call the full function. We do not have to patch the receiver
|
| - // because the function makes no use of it.
|
| __ bind(&slow);
|
| - ParameterCount expected(function);
|
| - __ InvokeFunction(function, expected, arguments(),
|
| - JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD);
|
| + // We do not have to patch the receiver because the function makes no use of
|
| + // it.
|
| + GenerateJumpFunctionIgnoreReceiver(function);
|
|
|
| - __ bind(&miss);
|
| - // ecx: function name.
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2661,8 +2436,8 @@ Handle<Code> CallStubCompiler::CompileFastApiCall(
|
| __ sub(esp, Immediate(kFastApiCallArguments * kPointerSize));
|
|
|
| // Check that the maps haven't changed and find a Holder as a side effect.
|
| - CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi,
|
| - name, depth, &miss);
|
| + CheckPrototypes(IC::CurrentTypeOf(object, isolate()), edx, holder,
|
| + ebx, eax, edi, name, depth, &miss);
|
|
|
| // Move the return address on top of the stack.
|
| __ mov(eax, Operand(esp, kFastApiCallArguments * kPointerSize));
|
| @@ -2675,8 +2450,7 @@ Handle<Code> CallStubCompiler::CompileFastApiCall(
|
| __ bind(&miss);
|
| __ add(esp, Immediate(kFastApiCallArguments * kPointerSize));
|
|
|
| - __ bind(&miss_before_stack_reserved);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss_before_stack_reserved);
|
|
|
| // Return the generated code.
|
| return GetCode(function);
|
| @@ -2694,27 +2468,32 @@ void StubCompiler::GenerateBooleanCheck(Register object, Label* miss) {
|
| }
|
|
|
|
|
| -void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object,
|
| - Handle<JSObject> holder,
|
| - Handle<Name> name,
|
| - CheckType check) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| - Label miss;
|
| - GenerateNameCheck(name, &miss);
|
| +void CallStubCompiler::PatchGlobalProxy(Handle<Object> object) {
|
| + if (object->IsGlobalObject()) {
|
| + const int argc = arguments().immediate();
|
| + const int receiver_offset = (argc + 1) * kPointerSize;
|
| + __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset));
|
| + __ mov(Operand(esp, receiver_offset), edx);
|
| + }
|
| +}
|
| +
|
| +
|
| +Register CallStubCompiler::HandlerFrontendHeader(Handle<Object> object,
|
| + Handle<JSObject> holder,
|
| + Handle<Name> name,
|
| + CheckType check,
|
| + Label* miss) {
|
| + GenerateNameCheck(name, miss);
|
| +
|
| + Register reg = edx;
|
|
|
| - // Get the receiver from the stack.
|
| const int argc = arguments().immediate();
|
| - __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
|
| + const int receiver_offset = (argc + 1) * kPointerSize;
|
| + __ mov(reg, Operand(esp, receiver_offset));
|
|
|
| // Check that the receiver isn't a smi.
|
| if (check != NUMBER_CHECK) {
|
| - __ JumpIfSmi(edx, &miss);
|
| + __ JumpIfSmi(reg, miss);
|
| }
|
|
|
| // Make sure that it's okay not to patch the on stack receiver
|
| @@ -2725,123 +2504,79 @@ void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object,
|
| __ IncrementCounter(isolate()->counters()->call_const(), 1);
|
|
|
| // Check that the maps haven't changed.
|
| - CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax,
|
| - edi, name, &miss);
|
| -
|
| - // Patch the receiver on the stack with the global proxy if
|
| - // necessary.
|
| - if (object->IsGlobalObject()) {
|
| - __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset));
|
| - __ mov(Operand(esp, (argc + 1) * kPointerSize), edx);
|
| - }
|
| + reg = CheckPrototypes(IC::CurrentTypeOf(object, isolate()), reg, holder,
|
| + ebx, eax, edi, name, miss);
|
| +
|
| break;
|
|
|
| - case STRING_CHECK:
|
| + case STRING_CHECK: {
|
| // Check that the object is a string.
|
| - __ CmpObjectType(edx, FIRST_NONSTRING_TYPE, eax);
|
| - __ j(above_equal, &miss);
|
| + __ CmpObjectType(reg, FIRST_NONSTRING_TYPE, eax);
|
| + __ j(above_equal, miss);
|
| // Check that the maps starting from the prototype haven't changed.
|
| GenerateDirectLoadGlobalFunctionPrototype(
|
| - masm(), Context::STRING_FUNCTION_INDEX, eax, &miss);
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - eax, holder, ebx, edx, edi, name, &miss);
|
| + masm(), Context::STRING_FUNCTION_INDEX, eax, miss);
|
| break;
|
| -
|
| - case SYMBOL_CHECK:
|
| + }
|
| + case SYMBOL_CHECK: {
|
| // Check that the object is a symbol.
|
| - __ CmpObjectType(edx, SYMBOL_TYPE, eax);
|
| - __ j(not_equal, &miss);
|
| + __ CmpObjectType(reg, SYMBOL_TYPE, eax);
|
| + __ j(not_equal, miss);
|
| // Check that the maps starting from the prototype haven't changed.
|
| GenerateDirectLoadGlobalFunctionPrototype(
|
| - masm(), Context::SYMBOL_FUNCTION_INDEX, eax, &miss);
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - eax, holder, ebx, edx, edi, name, &miss);
|
| + masm(), Context::SYMBOL_FUNCTION_INDEX, eax, miss);
|
| break;
|
| -
|
| + }
|
| case NUMBER_CHECK: {
|
| Label fast;
|
| // Check that the object is a smi or a heap number.
|
| - __ JumpIfSmi(edx, &fast);
|
| - __ CmpObjectType(edx, HEAP_NUMBER_TYPE, eax);
|
| - __ j(not_equal, &miss);
|
| + __ JumpIfSmi(reg, &fast);
|
| + __ CmpObjectType(reg, HEAP_NUMBER_TYPE, eax);
|
| + __ j(not_equal, miss);
|
| __ bind(&fast);
|
| // Check that the maps starting from the prototype haven't changed.
|
| GenerateDirectLoadGlobalFunctionPrototype(
|
| - masm(), Context::NUMBER_FUNCTION_INDEX, eax, &miss);
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - eax, holder, ebx, edx, edi, name, &miss);
|
| + masm(), Context::NUMBER_FUNCTION_INDEX, eax, miss);
|
| break;
|
| }
|
| case BOOLEAN_CHECK: {
|
| - GenerateBooleanCheck(edx, &miss);
|
| + GenerateBooleanCheck(reg, miss);
|
| // Check that the maps starting from the prototype haven't changed.
|
| GenerateDirectLoadGlobalFunctionPrototype(
|
| - masm(), Context::BOOLEAN_FUNCTION_INDEX, eax, &miss);
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - eax, holder, ebx, edx, edi, name, &miss);
|
| + masm(), Context::BOOLEAN_FUNCTION_INDEX, eax, miss);
|
| break;
|
| }
|
| }
|
|
|
| - Label success;
|
| - __ jmp(&success);
|
| -
|
| - // Handle call cache miss.
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| -
|
| - __ bind(&success);
|
| -}
|
| -
|
| + if (check != RECEIVER_MAP_CHECK) {
|
| + Handle<Object> prototype(object->GetPrototype(isolate()), isolate());
|
| + reg = CheckPrototypes(
|
| + IC::CurrentTypeOf(prototype, isolate()),
|
| + eax, holder, ebx, edx, edi, name, miss);
|
| + }
|
|
|
| -void CallStubCompiler::CompileHandlerBackend(Handle<JSFunction> function) {
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| - ParameterCount expected(function);
|
| - __ InvokeFunction(function, expected, arguments(),
|
| - JUMP_FUNCTION, NullCallWrapper(), call_kind);
|
| + return reg;
|
| }
|
|
|
|
|
| -Handle<Code> CallStubCompiler::CompileCallConstant(
|
| - Handle<Object> object,
|
| - Handle<JSObject> holder,
|
| - Handle<Name> name,
|
| - CheckType check,
|
| - Handle<JSFunction> function) {
|
| -
|
| - if (HasCustomCallGenerator(function)) {
|
| - Handle<Code> code = CompileCustomCall(object, holder,
|
| - Handle<Cell>::null(),
|
| - function, Handle<String>::cast(name),
|
| - Code::FAST);
|
| - // A null handle means bail out to the regular compiler code below.
|
| - if (!code.is_null()) return code;
|
| - }
|
| +void CallStubCompiler::GenerateJumpFunction(Handle<Object> object,
|
| + Register function,
|
| + Label* miss) {
|
| + // Check that the function really is a function.
|
| + GenerateFunctionCheck(function, ebx, miss);
|
|
|
| - CompileHandlerFrontend(object, holder, name, check);
|
| - CompileHandlerBackend(function);
|
| + if (!function.is(edi)) __ mov(edi, function);
|
| + PatchGlobalProxy(object);
|
|
|
| - // Return the generated code.
|
| - return GetCode(function);
|
| + // Invoke the function.
|
| + __ InvokeFunction(edi, arguments(), JUMP_FUNCTION,
|
| + NullCallWrapper(), call_kind());
|
| }
|
|
|
|
|
| Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
|
| Handle<JSObject> holder,
|
| Handle<Name> name) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| Label miss;
|
|
|
| GenerateNameCheck(name, &miss);
|
| @@ -2855,36 +2590,16 @@ Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
|
| // Get the receiver from the stack.
|
| __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
|
|
|
| - CallInterceptorCompiler compiler(this, arguments(), ecx, extra_state_);
|
| + CallInterceptorCompiler compiler(this, arguments(), ecx);
|
| compiler.Compile(masm(), object, holder, name, &lookup, edx, ebx, edi, eax,
|
| &miss);
|
|
|
| // Restore receiver.
|
| __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
|
|
|
| - // Check that the function really is a function.
|
| - __ JumpIfSmi(eax, &miss);
|
| - __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx);
|
| - __ j(not_equal, &miss);
|
| -
|
| - // Patch the receiver on the stack with the global proxy if
|
| - // necessary.
|
| - if (object->IsGlobalObject()) {
|
| - __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset));
|
| - __ mov(Operand(esp, (argc + 1) * kPointerSize), edx);
|
| - }
|
| -
|
| - // Invoke the function.
|
| - __ mov(edi, eax);
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| - __ InvokeFunction(edi, arguments(), JUMP_FUNCTION,
|
| - NullCallWrapper(), call_kind);
|
| + GenerateJumpFunction(object, eax, &miss);
|
|
|
| - // Handle load cache miss.
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(Code::FAST, name);
|
| @@ -2897,14 +2612,6 @@ Handle<Code> CallStubCompiler::CompileCallGlobal(
|
| Handle<PropertyCell> cell,
|
| Handle<JSFunction> function,
|
| Handle<Name> name) {
|
| - // ----------- S t a t e -------------
|
| - // -- ecx : name
|
| - // -- esp[0] : return address
|
| - // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- esp[(argc + 1) * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| if (HasCustomCallGenerator(function)) {
|
| Handle<Code> code = CompileCustomCall(
|
| object, holder, cell, function, Handle<String>::cast(name),
|
| @@ -2914,40 +2621,13 @@ Handle<Code> CallStubCompiler::CompileCallGlobal(
|
| }
|
|
|
| Label miss;
|
| - GenerateNameCheck(name, &miss);
|
| -
|
| - // Get the number of arguments.
|
| - const int argc = arguments().immediate();
|
| - GenerateGlobalReceiverCheck(object, holder, name, &miss);
|
| + HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
| + // Potentially loads a closure that matches the shared function info of the
|
| + // function, rather than function.
|
| GenerateLoadFunctionFromCell(cell, function, &miss);
|
| + GenerateJumpFunction(object, edi, function);
|
|
|
| - // Patch the receiver on the stack with the global proxy.
|
| - if (object->IsGlobalObject()) {
|
| - __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset));
|
| - __ mov(Operand(esp, (argc + 1) * kPointerSize), edx);
|
| - }
|
| -
|
| - // Set up the context (function already in edi).
|
| - __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
|
| -
|
| - // Jump to the cached code (tail call).
|
| - Counters* counters = isolate()->counters();
|
| - __ IncrementCounter(counters->call_global_inline(), 1);
|
| - ParameterCount expected(function->shared()->formal_parameter_count());
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| - // We call indirectly through the code field in the function to
|
| - // allow recompilation to take effect without changing any of the
|
| - // call sites.
|
| - __ InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
|
| - expected, arguments(), JUMP_FUNCTION,
|
| - NullCallWrapper(), call_kind);
|
| -
|
| - // Handle call cache miss.
|
| - __ bind(&miss);
|
| - __ IncrementCounter(counters->call_global_inline_miss(), 1);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(Code::NORMAL, name);
|
| @@ -2959,7 +2639,8 @@ Handle<Code> StoreStubCompiler::CompileStoreCallback(
|
| Handle<JSObject> holder,
|
| Handle<Name> name,
|
| Handle<ExecutableAccessorInfo> callback) {
|
| - HandlerFrontend(object, receiver(), holder, name);
|
| + HandlerFrontend(IC::CurrentTypeOf(object, isolate()),
|
| + receiver(), holder, name);
|
|
|
| __ pop(scratch1()); // remove the return address
|
| __ push(receiver());
|
| @@ -2983,7 +2664,8 @@ Handle<Code> StoreStubCompiler::CompileStoreCallback(
|
| Handle<JSObject> holder,
|
| Handle<Name> name,
|
| const CallOptimization& call_optimization) {
|
| - HandlerFrontend(object, receiver(), holder, name);
|
| + HandlerFrontend(IC::CurrentTypeOf(object, isolate()),
|
| + receiver(), holder, name);
|
|
|
| Register values[] = { value() };
|
| GenerateFastApiCall(
|
| @@ -3049,13 +2731,12 @@ Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
|
| __ push(receiver());
|
| __ push(this->name());
|
| __ push(value());
|
| - __ push(Immediate(Smi::FromInt(strict_mode())));
|
| __ push(scratch1()); // restore return address
|
|
|
| // Do tail-call to the runtime system.
|
| ExternalReference store_ic_property =
|
| ExternalReference(IC_Utility(IC::kStoreInterceptorProperty), isolate());
|
| - __ TailCallExternalReference(store_ic_property, 4, 1);
|
| + __ TailCallExternalReference(store_ic_property, 3, 1);
|
|
|
| // Return the generated code.
|
| return GetCode(kind(), Code::FAST, name);
|
| @@ -3090,12 +2771,10 @@ Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
|
| }
|
|
|
|
|
| -Handle<Code> LoadStubCompiler::CompileLoadNonexistent(
|
| - Handle<Object> object,
|
| - Handle<JSObject> last,
|
| - Handle<Name> name,
|
| - Handle<JSGlobalObject> global) {
|
| - NonexistentHandlerFrontend(object, last, name, global);
|
| +Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<Type> type,
|
| + Handle<JSObject> last,
|
| + Handle<Name> name) {
|
| + NonexistentHandlerFrontend(type, last, name);
|
|
|
| // Return undefined if maps of the full prototype chain are still the
|
| // same and no global property with this name contains a value.
|
| @@ -3186,14 +2865,14 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
|
|
|
|
|
| Handle<Code> LoadStubCompiler::CompileLoadGlobal(
|
| - Handle<Object> object,
|
| + Handle<Type> type,
|
| Handle<GlobalObject> global,
|
| Handle<PropertyCell> cell,
|
| Handle<Name> name,
|
| bool is_dont_delete) {
|
| Label miss;
|
|
|
| - HandlerFrontendHeader(object, receiver(), global, name, &miss);
|
| + HandlerFrontendHeader(type, receiver(), global, name, &miss);
|
| // Get the value from the cell.
|
| if (Serializer::enabled()) {
|
| __ mov(eax, Immediate(cell));
|
|
|