| Index: src/arm/stub-cache-arm.cc
|
| diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc
|
| index 7e82fd016758d494e11e0024a792ca57487660ff..08fd2c26f1c142342ba2241d26a4de4a6f552ebf 100644
|
| --- a/src/arm/stub-cache-arm.cc
|
| +++ b/src/arm/stub-cache-arm.cc
|
| @@ -742,36 +742,6 @@ void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
|
| }
|
|
|
|
|
| -static void GenerateCallFunction(MacroAssembler* masm,
|
| - Handle<Object> object,
|
| - const ParameterCount& arguments,
|
| - Label* miss,
|
| - Code::ExtraICState extra_ic_state) {
|
| - // ----------- S t a t e -------------
|
| - // -- r0: receiver
|
| - // -- r1: function to call
|
| - // -----------------------------------
|
| -
|
| - // Check that the function really is a function.
|
| - __ JumpIfSmi(r1, miss);
|
| - __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE);
|
| - __ b(ne, miss);
|
| -
|
| - // Patch the receiver on the stack with the global proxy if
|
| - // necessary.
|
| - if (object->IsGlobalObject()) {
|
| - __ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset));
|
| - __ str(r3, MemOperand(sp, arguments.immediate() * kPointerSize));
|
| - }
|
| -
|
| - // Invoke the function.
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| - __ InvokeFunction(r1, arguments, JUMP_FUNCTION, NullCallWrapper(), call_kind);
|
| -}
|
| -
|
| -
|
| static void PushInterceptorArguments(MacroAssembler* masm,
|
| Register receiver,
|
| Register holder,
|
| @@ -798,17 +768,12 @@ 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);
|
| -
|
| - ExternalReference ref =
|
| - ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly),
|
| - masm->isolate());
|
| - __ mov(r0, Operand(StubCache::kInterceptorArgsLength));
|
| - __ mov(r1, Operand(ref));
|
| -
|
| - CEntryStub stub(1);
|
| - __ CallStub(&stub);
|
| + __ CallExternalReference(
|
| + ExternalReference(IC_Utility(id), masm->isolate()),
|
| + StubCache::kInterceptorArgsLength);
|
| }
|
|
|
|
|
| @@ -946,12 +911,12 @@ static void GenerateFastApiCall(MacroAssembler* masm,
|
| __ str(receiver, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
|
| // Write receiver to stack frame.
|
| int index = stack_space - 1;
|
| - __ str(receiver, MemOperand(sp, index * kPointerSize));
|
| + __ str(receiver, MemOperand(sp, index-- * kPointerSize));
|
| // Write the arguments to stack frame.
|
| for (int i = 0; i < argc; i++) {
|
| ASSERT(!receiver.is(values[i]));
|
| ASSERT(!scratch.is(values[i]));
|
| - __ str(receiver, MemOperand(sp, index-- * kPointerSize));
|
| + __ str(values[i], MemOperand(sp, index-- * kPointerSize));
|
| }
|
|
|
| GenerateFastApiDirectCall(masm, optimization, argc, true);
|
| @@ -960,14 +925,12 @@ static void GenerateFastApiCall(MacroAssembler* masm,
|
|
|
| class CallInterceptorCompiler BASE_EMBEDDED {
|
| public:
|
| - CallInterceptorCompiler(StubCompiler* stub_compiler,
|
| + CallInterceptorCompiler(CallStubCompiler* stub_compiler,
|
| const ParameterCount& arguments,
|
| - Register name,
|
| - Code::ExtraICState extra_ic_state)
|
| + Register name)
|
| : stub_compiler_(stub_compiler),
|
| arguments_(arguments),
|
| - name_(name),
|
| - extra_ic_state_(extra_ic_state) {}
|
| + name_(name) {}
|
|
|
| void Compile(MacroAssembler* masm,
|
| Handle<JSObject> object,
|
| @@ -1038,9 +1001,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|.
|
| @@ -1054,10 +1018,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
|
| @@ -1071,13 +1035,8 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| GenerateFastApiDirectCall(
|
| masm, optimization, arguments_.immediate(), false);
|
| } else {
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_ic_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);
|
| + stub_compiler_->GenerateJumpFunction(object, function);
|
| }
|
|
|
| // Deferred code for fast API call case---clean preallocated space.
|
| @@ -1104,19 +1063,19 @@ 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);
|
|
|
| // Call a runtime function to load the interceptor property.
|
| 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_);
|
| // Leave the internal frame.
|
| @@ -1130,14 +1089,14 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| Label* interceptor_succeeded) {
|
| {
|
| FrameScope scope(masm, StackFrame::INTERNAL);
|
| + __ Push(receiver);
|
| __ Push(holder, name_);
|
| - CompileCallLoadPropertyWithInterceptor(masm,
|
| - receiver,
|
| - holder,
|
| - name_,
|
| - holder_obj);
|
| - __ pop(name_); // Restore the name.
|
| - __ pop(receiver); // Restore the holder.
|
| + CompileCallLoadPropertyWithInterceptor(
|
| + masm, receiver, holder, name_, holder_obj,
|
| + IC::kLoadPropertyWithInterceptorOnly);
|
| + __ pop(name_);
|
| + __ pop(holder);
|
| + __ pop(receiver);
|
| }
|
| // If interceptor returns no-result sentinel, call the constant function.
|
| __ LoadRoot(scratch, Heap::kNoInterceptorResultSentinelRootIndex);
|
| @@ -1145,33 +1104,12 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| __ b(ne, interceptor_succeeded);
|
| }
|
|
|
| - StubCompiler* stub_compiler_;
|
| + CallStubCompiler* stub_compiler_;
|
| const ParameterCount& arguments_;
|
| Register name_;
|
| - Code::ExtraICState extra_ic_state_;
|
| };
|
|
|
|
|
| -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) {
|
| __ Jump(code, RelocInfo::CODE_TARGET);
|
| }
|
| @@ -1181,7 +1119,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,
|
| @@ -1191,11 +1129,11 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
| int save_at_depth,
|
| Label* miss,
|
| PrototypeCheckType check) {
|
| + 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, Operand(Handle<Map>(object->map())));
|
| + __ mov(scratch1, Operand(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)
|
| @@ -1210,25 +1148,31 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
| __ str(reg, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
|
| }
|
|
|
| - // Check the maps in the prototype chain.
|
| - // Traverse the prototype chain from the object and do map checks.
|
| - Handle<JSObject> current = object;
|
| - while (!current.is_identical_to(holder)) {
|
| + 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_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,
|
| @@ -1239,8 +1183,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
| __ ldr(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset));
|
| } else {
|
| Register map_reg = scratch1;
|
| - if (!current.is_identical_to(first) || check == CHECK_ALL_MAPS) {
|
| - Handle<Map> current_map(current->map());
|
| + if (depth != 1 || check == CHECK_ALL_MAPS) {
|
| // CheckMap implicitly loads the map of |reg| into |map_reg|.
|
| __ CheckMap(reg, map_reg, current_map, miss, DONT_DO_SMI_CHECK);
|
| } else {
|
| @@ -1250,9 +1193,14 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
| // 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, scratch2, miss);
|
| + } else if (current_map->IsJSGlobalObjectMap()) {
|
| + GenerateCheckPropertyCell(
|
| + masm(), Handle<JSGlobalObject>::cast(current), name,
|
| + scratch2, miss);
|
| }
|
| +
|
| reg = holder_reg; // From now on the object will be in holder_reg.
|
|
|
| if (heap()->InNewSpace(*prototype)) {
|
| @@ -1271,28 +1219,24 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
|
|
| // Go to the next object in the prototype chain.
|
| current = prototype;
|
| + current_map = handle(current->map());
|
| }
|
|
|
| // 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, scratch1, Handle<Map>(holder->map()), miss,
|
| - DONT_DO_SMI_CHECK);
|
| + __ CheckMap(reg, scratch1, 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, 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;
|
| }
|
| @@ -1321,14 +1265,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()));
|
| @@ -1516,11 +1460,10 @@ 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.
|
| Label interceptor_failed;
|
| @@ -1562,21 +1505,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.
|
| - __ ldr(r0, MemOperand(sp, argc * kPointerSize));
|
| -
|
| - // Check that the maps haven't changed.
|
| - __ JumpIfSmi(r0, miss);
|
| - CheckPrototypes(object, r0, holder, r3, r1, r4, name, miss);
|
| +void CallStubCompiler::GenerateFunctionCheck(Register function,
|
| + Register scratch,
|
| + Label* miss) {
|
| + __ JumpIfSmi(function, miss);
|
| + __ CompareObjectType(function, scratch, scratch, JS_FUNCTION_TYPE);
|
| + __ b(ne, miss);
|
| }
|
|
|
|
|
| @@ -1595,9 +1529,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(r1, miss);
|
| - __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE);
|
| - __ b(ne, miss);
|
| + GenerateFunctionCheck(r1, r3, miss);
|
|
|
| // Check the shared function info. Make sure it hasn't changed.
|
| __ Move(r3, Handle<SharedFunctionInfo>(function->shared()));
|
| @@ -1614,7 +1546,7 @@ void CallStubCompiler::GenerateMissBranch() {
|
| Handle<Code> code =
|
| isolate()->stub_cache()->ComputeCallMiss(arguments().immediate(),
|
| kind_,
|
| - extra_state_);
|
| + extra_state());
|
| __ Jump(code, RelocInfo::CODE_TARGET);
|
| }
|
|
|
| @@ -1623,31 +1555,15 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object,
|
| Handle<JSObject> holder,
|
| PropertyIndex index,
|
| Handle<Name> name) {
|
| - // ----------- S t a t e -------------
|
| - // -- r2 : name
|
| - // -- lr : return address
|
| - // -----------------------------------
|
| Label miss;
|
|
|
| - GenerateNameCheck(name, &miss);
|
| -
|
| - const int argc = arguments().immediate();
|
| -
|
| - // Get the receiver of the function from the stack into r0.
|
| - __ ldr(r0, MemOperand(sp, argc * kPointerSize));
|
| - // Check that the receiver isn't a smi.
|
| - __ JumpIfSmi(r0, &miss);
|
| -
|
| - // Do the right check and compute the holder register.
|
| - Register reg = CheckPrototypes(object, r0, holder, r1, r3, r4, name, &miss);
|
| + Register reg = HandlerFrontendHeader(
|
| + object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
| GenerateFastPropertyLoad(masm(), r1, reg, index.is_inobject(holder),
|
| index.translate(holder), Representation::Tagged());
|
| + GenerateJumpFunction(object, r1, &miss);
|
|
|
| - GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_);
|
| -
|
| - // Handle call cache miss.
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(Code::FAST, name);
|
| @@ -1663,30 +1579,16 @@ Handle<Code> CallStubCompiler::CompileArrayCodeCall(
|
| Code::StubType type) {
|
| Label miss;
|
|
|
| - // Check that function is still array
|
| - const int argc = arguments().immediate();
|
| - GenerateNameCheck(name, &miss);
|
| - Register receiver = r1;
|
| -
|
| - if (cell.is_null()) {
|
| - __ ldr(receiver, MemOperand(sp, argc * kPointerSize));
|
| -
|
| - // Check that the receiver isn't a smi.
|
| - __ JumpIfSmi(receiver, &miss);
|
| -
|
| - // Check that the maps haven't changed.
|
| - CheckPrototypes(Handle<JSObject>::cast(object), receiver, holder, r3, r0,
|
| - r4, 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(r0, Operand(argc));
|
| __ mov(r2, Operand(site_feedback_cell));
|
| __ mov(r1, Operand(function));
|
| @@ -1694,8 +1596,7 @@ Handle<Code> CallStubCompiler::CompileArrayCodeCall(
|
| ArrayConstructorStub stub(isolate());
|
| __ TailCallStub(&stub);
|
|
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -1709,36 +1610,22 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- r2 : name
|
| - // -- lr : return address
|
| - // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- sp[argc * 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);
|
| -
|
| - Register receiver = r1;
|
| - // Get the receiver from the stack
|
| - const int argc = arguments().immediate();
|
| - __ ldr(receiver, MemOperand(sp, argc * kPointerSize));
|
|
|
| - // Check that the receiver isn't a smi.
|
| - __ JumpIfSmi(receiver, &miss);
|
| -
|
| - // Check that the maps haven't changed.
|
| - CheckPrototypes(Handle<JSObject>::cast(object), receiver, holder, r3, r0, r4,
|
| - name, &miss);
|
| + HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
| + Register receiver = r0;
|
| + Register scratch = r1;
|
|
|
| + const int argc = arguments().immediate();
|
| if (argc == 0) {
|
| // Nothing to do, just return the length.
|
| __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| @@ -1757,20 +1644,20 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
|
|
| // Check that the elements are in fast mode and writable.
|
| __ CheckMap(elements,
|
| - r0,
|
| + scratch,
|
| Heap::kFixedArrayMapRootIndex,
|
| &check_double,
|
| DONT_DO_SMI_CHECK);
|
|
|
| - // Get the array's length into r0 and calculate new length.
|
| - __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| - __ add(r0, r0, Operand(Smi::FromInt(argc)));
|
| + // Get the array's length into scratch and calculate new length.
|
| + __ ldr(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| + __ add(scratch, scratch, Operand(Smi::FromInt(argc)));
|
|
|
| // Get the elements' length.
|
| __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset));
|
|
|
| // Check if we could survive without allocation.
|
| - __ cmp(r0, r4);
|
| + __ cmp(scratch, r4);
|
| __ b(gt, &attempt_to_grow_elements);
|
|
|
| // Check if value is a smi.
|
| @@ -1778,49 +1665,50 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
| __ JumpIfNotSmi(r4, &with_write_barrier);
|
|
|
| // Save new length.
|
| - __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| + __ str(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
|
|
| // Store the value.
|
| // We may need a register containing the address end_elements below,
|
| // so write back the value in end_elements.
|
| - __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(r0));
|
| + __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(scratch));
|
| const int kEndElementsOffset =
|
| FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize;
|
| __ str(r4, MemOperand(end_elements, kEndElementsOffset, PreIndex));
|
|
|
| // Check for a smi.
|
| __ Drop(argc + 1);
|
| + __ mov(r0, scratch);
|
| __ Ret();
|
|
|
| __ bind(&check_double);
|
|
|
| // Check that the elements are in fast mode and writable.
|
| __ CheckMap(elements,
|
| - r0,
|
| + scratch,
|
| Heap::kFixedDoubleArrayMapRootIndex,
|
| &call_builtin,
|
| DONT_DO_SMI_CHECK);
|
|
|
| - // Get the array's length into r0 and calculate new length.
|
| - __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| - __ add(r0, r0, Operand(Smi::FromInt(argc)));
|
| + // Get the array's length into scratch and calculate new length.
|
| + __ ldr(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| + __ add(scratch, scratch, Operand(Smi::FromInt(argc)));
|
|
|
| // Get the elements' length.
|
| __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset));
|
|
|
| // Check if we could survive without allocation.
|
| - __ cmp(r0, r4);
|
| + __ cmp(scratch, r4);
|
| __ b(gt, &call_builtin);
|
|
|
| __ ldr(r4, MemOperand(sp, (argc - 1) * kPointerSize));
|
| - __ StoreNumberToDoubleElements(r4, r0, elements, r5, d0,
|
| + __ StoreNumberToDoubleElements(r4, scratch, elements, r5, d0,
|
| &call_builtin, argc * kDoubleSize);
|
|
|
| // Save new length.
|
| - __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| + __ str(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
|
|
| - // Check for a smi.
|
| __ Drop(argc + 1);
|
| + __ mov(r0, scratch);
|
| __ Ret();
|
|
|
| __ bind(&with_write_barrier);
|
| @@ -1871,12 +1759,12 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
| }
|
|
|
| // Save new length.
|
| - __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| + __ str(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
|
|
| // Store the value.
|
| // We may need a register containing the address end_elements below,
|
| // so write back the value in end_elements.
|
| - __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(r0));
|
| + __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(scratch));
|
| __ str(r4, MemOperand(end_elements, kEndElementsOffset, PreIndex));
|
|
|
| __ RecordWrite(elements,
|
| @@ -1887,10 +1775,11 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
| EMIT_REMEMBERED_SET,
|
| OMIT_SMI_CHECK);
|
| __ Drop(argc + 1);
|
| + __ mov(r0, scratch);
|
| __ Ret();
|
|
|
| __ bind(&attempt_to_grow_elements);
|
| - // r0: array's length + 1.
|
| + // scratch: array's length + 1.
|
|
|
| if (!FLAG_inline_new) {
|
| __ b(&call_builtin);
|
| @@ -1912,7 +1801,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
|
|
| const int kAllocationDelta = 4;
|
| // Load top and check if it is the end of elements.
|
| - __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(r0));
|
| + __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(scratch));
|
| __ add(end_elements, end_elements, Operand(kEndElementsOffset));
|
| __ mov(r4, Operand(new_space_allocation_top));
|
| __ ldr(r3, MemOperand(r4));
|
| @@ -1937,13 +1826,14 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
| }
|
|
|
| // Update elements' and array's sizes.
|
| - __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| + __ str(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset));
|
| __ add(r4, r4, Operand(Smi::FromInt(kAllocationDelta)));
|
| __ str(r4, FieldMemOperand(elements, FixedArray::kLengthOffset));
|
|
|
| // Elements are in new space, so write barrier is not required.
|
| __ Drop(argc + 1);
|
| + __ mov(r0, scratch);
|
| __ Ret();
|
| }
|
| __ bind(&call_builtin);
|
| @@ -1951,9 +1841,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
| ExternalReference(Builtins::c_ArrayPush, isolate()), argc + 1, 1);
|
| }
|
|
|
| - // Handle call cache miss.
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -1967,42 +1855,28 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- r2 : name
|
| - // -- lr : return address
|
| - // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- sp[argc * 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;
|
| - Register receiver = r1;
|
| + Register receiver = r0;
|
| + Register scratch = r1;
|
| Register elements = r3;
|
| - GenerateNameCheck(name, &miss);
|
| -
|
| - // Get the receiver from the stack
|
| - const int argc = arguments().immediate();
|
| - __ ldr(receiver, MemOperand(sp, argc * kPointerSize));
|
| - // Check that the receiver isn't a smi.
|
| - __ JumpIfSmi(receiver, &miss);
|
|
|
| - // Check that the maps haven't changed.
|
| - CheckPrototypes(Handle<JSObject>::cast(object), receiver, holder, elements,
|
| - r4, r0, name, &miss);
|
| + HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
|
|
| // Get the elements array of the object.
|
| __ ldr(elements, FieldMemOperand(receiver, JSArray::kElementsOffset));
|
|
|
| // Check that the elements are in fast mode and writable.
|
| __ CheckMap(elements,
|
| - r0,
|
| + scratch,
|
| Heap::kFixedArrayMapRootIndex,
|
| &call_builtin,
|
| DONT_DO_SMI_CHECK);
|
| @@ -2017,8 +1891,8 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
|
| // We can't address the last element in one operation. Compute the more
|
| // expensive shift first, and use an offset later on.
|
| __ add(elements, elements, Operand::PointerOffsetFromSmiKey(r4));
|
| - __ ldr(r0, FieldMemOperand(elements, FixedArray::kHeaderSize));
|
| - __ cmp(r0, r6);
|
| + __ ldr(scratch, FieldMemOperand(elements, FixedArray::kHeaderSize));
|
| + __ cmp(scratch, r6);
|
| __ b(eq, &call_builtin);
|
|
|
| // Set the array's length.
|
| @@ -2026,7 +1900,9 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
|
|
|
| // Fill with the hole.
|
| __ str(r6, FieldMemOperand(elements, FixedArray::kHeaderSize));
|
| + const int argc = arguments().immediate();
|
| __ Drop(argc + 1);
|
| + __ mov(r0, scratch);
|
| __ Ret();
|
|
|
| __ bind(&return_undefined);
|
| @@ -2038,9 +1914,7 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
|
| __ TailCallExternalReference(
|
| ExternalReference(Builtins::c_ArrayPop, isolate()), argc + 1, 1);
|
|
|
| - // Handle call cache miss.
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2054,43 +1928,26 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- r2 : function name
|
| - // -- lr : return address
|
| - // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- sp[argc * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| // If object is not a string, bail out to regular call.
|
| if (!object->IsString() || !cell.is_null()) return Handle<Code>::null();
|
|
|
| - const int argc = arguments().immediate();
|
| Label miss;
|
| Label name_miss;
|
| Label index_out_of_range;
|
| 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,
|
| - r0,
|
| - &miss);
|
| - ASSERT(!object.is_identical_to(holder));
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - r0, holder, r1, r3, r4, name, &miss);
|
|
|
| - Register receiver = r1;
|
| + HandlerFrontendHeader(object, holder, name, STRING_CHECK, &name_miss);
|
| +
|
| + Register receiver = r0;
|
| Register index = r4;
|
| - Register result = r0;
|
| + Register result = r1;
|
| + const int argc = arguments().immediate();
|
| __ ldr(receiver, MemOperand(sp, argc * kPointerSize));
|
| if (argc > 0) {
|
| __ ldr(index, MemOperand(sp, (argc - 1) * kPointerSize));
|
| @@ -2107,6 +1964,7 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
|
| STRING_INDEX_IS_NUMBER);
|
| generator.GenerateFast(masm());
|
| __ Drop(argc + 1);
|
| + __ mov(r0, result);
|
| __ Ret();
|
|
|
| StubRuntimeCallHelper call_helper;
|
| @@ -2122,8 +1980,7 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
|
| __ bind(&miss);
|
| // Restore function name in r2.
|
| __ Move(r2, name);
|
| - __ bind(&name_miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&name_miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2137,14 +1994,6 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- r2 : function name
|
| - // -- lr : return address
|
| - // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- sp[argc * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| // If object is not a string, bail out to regular call.
|
| if (!object->IsString() || !cell.is_null()) return Handle<Code>::null();
|
|
|
| @@ -2154,27 +2003,17 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
|
| Label index_out_of_range;
|
| 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,
|
| - r0,
|
| - &miss);
|
| - ASSERT(!object.is_identical_to(holder));
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - r0, holder, r1, r3, r4, name, &miss);
|
| +
|
| + HandlerFrontendHeader(object, holder, name, STRING_CHECK, &name_miss);
|
|
|
| Register receiver = r0;
|
| Register index = r4;
|
| Register scratch = r3;
|
| - Register result = r0;
|
| - __ ldr(receiver, MemOperand(sp, argc * kPointerSize));
|
| + Register result = r1;
|
| if (argc > 0) {
|
| __ ldr(index, MemOperand(sp, (argc - 1) * kPointerSize));
|
| } else {
|
| @@ -2191,6 +2030,7 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
|
| STRING_INDEX_IS_NUMBER);
|
| generator.GenerateFast(masm());
|
| __ Drop(argc + 1);
|
| + __ mov(r0, result);
|
| __ Ret();
|
|
|
| StubRuntimeCallHelper call_helper;
|
| @@ -2206,8 +2046,7 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
|
| __ bind(&miss);
|
| // Restore function name in r2.
|
| __ Move(r2, name);
|
| - __ bind(&name_miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&name_miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2221,14 +2060,6 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- r2 : function name
|
| - // -- lr : return address
|
| - // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- sp[argc * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| const int argc = arguments().immediate();
|
|
|
| // If the object is not a JSObject or we got an unexpected number of
|
| @@ -2236,19 +2067,10 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
|
| if (!object->IsJSObject() || argc != 1) return Handle<Code>::null();
|
|
|
| Label miss;
|
| - GenerateNameCheck(name, &miss);
|
| -
|
| - if (cell.is_null()) {
|
| - __ ldr(r1, MemOperand(sp, 1 * kPointerSize));
|
| -
|
| - __ JumpIfSmi(r1, &miss);
|
|
|
| - CheckPrototypes(Handle<JSObject>::cast(object), r1, holder, r0, r3, r4,
|
| - 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);
|
| }
|
|
|
| @@ -2271,16 +2093,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);
|
| - 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);
|
| - // r2: function name.
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2294,31 +2112,16 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- r2 : function name
|
| - // -- lr : return address
|
| - // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- sp[argc * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| const int argc = arguments().immediate();
|
| // If the object is not a JSObject or we got an unexpected number of
|
| // arguments, bail out to the regular call.
|
| if (!object->IsJSObject() || argc != 1) return Handle<Code>::null();
|
|
|
| Label miss, slow;
|
| - GenerateNameCheck(name, &miss);
|
|
|
| - if (cell.is_null()) {
|
| - __ ldr(r1, MemOperand(sp, 1 * kPointerSize));
|
| - __ JumpIfSmi(r1, &miss);
|
| - CheckPrototypes(Handle<JSObject>::cast(object), r1, holder, r0, r3, r4,
|
| - 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);
|
| }
|
|
|
| @@ -2381,15 +2184,11 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall(
|
| __ Ret();
|
|
|
| __ bind(&slow);
|
| - // Tail call the full function. We do not have to patch the receiver
|
| - // because the function makes no use of it.
|
| - 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);
|
| - // r2: function name.
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2403,30 +2202,16 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // ----------- S t a t e -------------
|
| - // -- r2 : function name
|
| - // -- lr : return address
|
| - // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
|
| - // -- ...
|
| - // -- sp[argc * 4] : receiver
|
| - // -----------------------------------
|
| -
|
| const int argc = arguments().immediate();
|
| // If the object is not a JSObject or we got an unexpected number of
|
| // arguments, bail out to the regular call.
|
| if (!object->IsJSObject() || argc != 1) return Handle<Code>::null();
|
|
|
| Label miss;
|
| - GenerateNameCheck(name, &miss);
|
| - if (cell.is_null()) {
|
| - __ ldr(r1, MemOperand(sp, 1 * kPointerSize));
|
| - __ JumpIfSmi(r1, &miss);
|
| - CheckPrototypes(Handle<JSObject>::cast(object), r1, holder, r0, r3, r4,
|
| - 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);
|
| }
|
|
|
| @@ -2479,16 +2264,12 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
|
| __ Drop(argc + 1);
|
| __ Ret();
|
|
|
| - // 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);
|
| - // r2: function name.
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2530,16 +2311,16 @@ Handle<Code> CallStubCompiler::CompileFastApiCall(
|
| ReserveSpaceForFastApiCall(masm(), r0);
|
|
|
| // Check that the maps haven't changed and find a Holder as a side effect.
|
| - CheckPrototypes(Handle<JSObject>::cast(object), r1, holder, r0, r3, r4, name,
|
| - depth, &miss);
|
| + CheckPrototypes(
|
| + IC::CurrentTypeOf(object, isolate()),
|
| + r1, holder, r0, r3, r4, name, depth, &miss);
|
|
|
| GenerateFastApiDirectCall(masm(), optimization, argc, false);
|
|
|
| __ bind(&miss);
|
| FreeSpaceForFastApiCall(masm());
|
|
|
| - __ bind(&miss_before_stack_reserved);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss_before_stack_reserved);
|
|
|
| // Return the generated code.
|
| return GetCode(function);
|
| @@ -2559,24 +2340,37 @@ void StubCompiler::GenerateBooleanCheck(Register object, Label* miss) {
|
| }
|
|
|
|
|
| -void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object,
|
| - Handle<JSObject> holder,
|
| - Handle<Name> name,
|
| - CheckType check) {
|
| +void CallStubCompiler::PatchGlobalProxy(Handle<Object> object) {
|
| + if (object->IsGlobalObject()) {
|
| + const int argc = arguments().immediate();
|
| + const int receiver_offset = argc * kPointerSize;
|
| + __ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset));
|
| + __ str(r3, MemOperand(sp, receiver_offset));
|
| + }
|
| +}
|
| +
|
| +
|
| +Register CallStubCompiler::HandlerFrontendHeader(Handle<Object> object,
|
| + Handle<JSObject> holder,
|
| + Handle<Name> name,
|
| + CheckType check,
|
| + Label* miss) {
|
| // ----------- S t a t e -------------
|
| // -- r2 : name
|
| // -- lr : return address
|
| // -----------------------------------
|
| - Label miss;
|
| - GenerateNameCheck(name, &miss);
|
| + GenerateNameCheck(name, miss);
|
| +
|
| + Register reg = r0;
|
|
|
| // Get the receiver from the stack
|
| const int argc = arguments().immediate();
|
| - __ ldr(r1, MemOperand(sp, argc * kPointerSize));
|
| + const int receiver_offset = argc * kPointerSize;
|
| + __ ldr(r0, MemOperand(sp, receiver_offset));
|
|
|
| // Check that the receiver isn't a smi.
|
| if (check != NUMBER_CHECK) {
|
| - __ JumpIfSmi(r1, &miss);
|
| + __ JumpIfSmi(r0, miss);
|
| }
|
|
|
| // Make sure that it's okay not to patch the on stack receiver
|
| @@ -2584,123 +2378,82 @@ void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object,
|
| ASSERT(!object->IsGlobalObject() || check == RECEIVER_MAP_CHECK);
|
| switch (check) {
|
| case RECEIVER_MAP_CHECK:
|
| - __ IncrementCounter(isolate()->counters()->call_const(), 1, r0, r3);
|
| + __ IncrementCounter(isolate()->counters()->call_const(), 1, r1, r3);
|
|
|
| // Check that the maps haven't changed.
|
| - CheckPrototypes(Handle<JSObject>::cast(object), r1, holder, r0, r3, r4,
|
| - name, &miss);
|
| -
|
| - // Patch the receiver on the stack with the global proxy if
|
| - // necessary.
|
| - if (object->IsGlobalObject()) {
|
| - __ ldr(r3, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset));
|
| - __ str(r3, MemOperand(sp, argc * kPointerSize));
|
| - }
|
| + reg = CheckPrototypes(
|
| + IC::CurrentTypeOf(object, isolate()),
|
| + reg, holder, r1, r3, r4, name, miss);
|
| break;
|
|
|
| - case STRING_CHECK:
|
| + case STRING_CHECK: {
|
| // Check that the object is a string.
|
| - __ CompareObjectType(r1, r3, r3, FIRST_NONSTRING_TYPE);
|
| - __ b(ge, &miss);
|
| + __ CompareObjectType(reg, r3, r3, FIRST_NONSTRING_TYPE);
|
| + __ b(ge, miss);
|
| // Check that the maps starting from the prototype haven't changed.
|
| GenerateDirectLoadGlobalFunctionPrototype(
|
| - masm(), Context::STRING_FUNCTION_INDEX, r0, &miss);
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - r0, holder, r3, r1, r4, name, &miss);
|
| + masm(), Context::STRING_FUNCTION_INDEX, r1, miss);
|
| break;
|
| -
|
| - case SYMBOL_CHECK:
|
| + }
|
| + case SYMBOL_CHECK: {
|
| // Check that the object is a symbol.
|
| - __ CompareObjectType(r1, r1, r3, SYMBOL_TYPE);
|
| - __ b(ne, &miss);
|
| + __ CompareObjectType(reg, r3, r3, SYMBOL_TYPE);
|
| + __ b(ne, miss);
|
| // Check that the maps starting from the prototype haven't changed.
|
| GenerateDirectLoadGlobalFunctionPrototype(
|
| - masm(), Context::SYMBOL_FUNCTION_INDEX, r0, &miss);
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - r0, holder, r3, r1, r4, name, &miss);
|
| + masm(), Context::SYMBOL_FUNCTION_INDEX, r1, miss);
|
| break;
|
| -
|
| + }
|
| case NUMBER_CHECK: {
|
| Label fast;
|
| // Check that the object is a smi or a heap number.
|
| - __ JumpIfSmi(r1, &fast);
|
| - __ CompareObjectType(r1, r0, r0, HEAP_NUMBER_TYPE);
|
| - __ b(ne, &miss);
|
| + __ JumpIfSmi(reg, &fast);
|
| + __ CompareObjectType(reg, r3, r3, HEAP_NUMBER_TYPE);
|
| + __ b(ne, miss);
|
| __ bind(&fast);
|
| // Check that the maps starting from the prototype haven't changed.
|
| GenerateDirectLoadGlobalFunctionPrototype(
|
| - masm(), Context::NUMBER_FUNCTION_INDEX, r0, &miss);
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - r0, holder, r3, r1, r4, name, &miss);
|
| + masm(), Context::NUMBER_FUNCTION_INDEX, r1, miss);
|
| break;
|
| }
|
| case BOOLEAN_CHECK: {
|
| - GenerateBooleanCheck(r1, &miss);
|
| + GenerateBooleanCheck(reg, miss);
|
|
|
| // Check that the maps starting from the prototype haven't changed.
|
| GenerateDirectLoadGlobalFunctionPrototype(
|
| - masm(), Context::BOOLEAN_FUNCTION_INDEX, r0, &miss);
|
| - CheckPrototypes(
|
| - Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))),
|
| - r0, holder, r3, r1, r4, name, &miss);
|
| + masm(), Context::BOOLEAN_FUNCTION_INDEX, r1, miss);
|
| break;
|
| }
|
| }
|
|
|
| - Label success;
|
| - __ b(&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()),
|
| + r1, holder, r1, r3, r4, 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;
|
| - }
|
| -
|
| - CompileHandlerFrontend(object, holder, name, check);
|
| - CompileHandlerBackend(function);
|
| +void CallStubCompiler::GenerateJumpFunction(Handle<Object> object,
|
| + Register function,
|
| + Label* miss) {
|
| + ASSERT(function.is(r1));
|
| + // Check that the function really is a function.
|
| + GenerateFunctionCheck(function, r3, miss);
|
| + PatchGlobalProxy(object);
|
|
|
| - // Return the generated code.
|
| - return GetCode(function);
|
| + // Invoke the function.
|
| + __ InvokeFunction(r1, arguments(), JUMP_FUNCTION,
|
| + NullCallWrapper(), call_kind());
|
| }
|
|
|
|
|
| Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
|
| Handle<JSObject> holder,
|
| Handle<Name> name) {
|
| - // ----------- S t a t e -------------
|
| - // -- r2 : name
|
| - // -- lr : return address
|
| - // -----------------------------------
|
| Label miss;
|
| GenerateNameCheck(name, &miss);
|
|
|
| @@ -2712,7 +2465,7 @@ Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
|
| // Get the receiver from the stack.
|
| __ ldr(r1, MemOperand(sp, argc * kPointerSize));
|
|
|
| - CallInterceptorCompiler compiler(this, arguments(), r2, extra_state_);
|
| + CallInterceptorCompiler compiler(this, arguments(), r2);
|
| compiler.Compile(masm(), object, holder, name, &lookup, r1, r3, r4, r0,
|
| &miss);
|
|
|
| @@ -2721,11 +2474,9 @@ Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
|
| // Restore receiver.
|
| __ ldr(r0, MemOperand(sp, argc * kPointerSize));
|
|
|
| - GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_);
|
| + GenerateJumpFunction(object, r1, &miss);
|
|
|
| - // Handle call cache miss.
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(Code::FAST, name);
|
| @@ -2738,10 +2489,6 @@ Handle<Code> CallStubCompiler::CompileCallGlobal(
|
| Handle<PropertyCell> cell,
|
| Handle<JSFunction> function,
|
| Handle<Name> name) {
|
| - // ----------- S t a t e -------------
|
| - // -- r2 : name
|
| - // -- lr : return address
|
| - // -----------------------------------
|
| if (HasCustomCallGenerator(function)) {
|
| Handle<Code> code = CompileCustomCall(
|
| object, holder, cell, function, Handle<String>::cast(name),
|
| @@ -2751,41 +2498,15 @@ 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);
|
|
|
| - // Patch the receiver on the stack with the global proxy if
|
| - // necessary.
|
| - if (object->IsGlobalObject()) {
|
| - __ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset));
|
| - __ str(r3, MemOperand(sp, argc * kPointerSize));
|
| - }
|
| -
|
| - // Set up the context (function already in r1).
|
| - __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
|
| -
|
| - // Jump to the cached code (tail call).
|
| Counters* counters = isolate()->counters();
|
| __ IncrementCounter(counters->call_global_inline(), 1, r3, r4);
|
| - 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.
|
| - __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset));
|
| - __ InvokeCode(r3, expected, arguments(), JUMP_FUNCTION,
|
| - NullCallWrapper(), call_kind);
|
| -
|
| - // Handle call cache miss.
|
| - __ bind(&miss);
|
| - __ IncrementCounter(counters->call_global_inline_miss(), 1, r1, r3);
|
| - GenerateMissBranch();
|
| + GenerateJumpFunction(object, r1, function);
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(Code::NORMAL, name);
|
| @@ -2797,7 +2518,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);
|
|
|
| // Stub never generated for non-global objects that require access checks.
|
| ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded());
|
| @@ -2823,7 +2545,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(
|
| @@ -2900,13 +2623,10 @@ Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
|
|
|
| __ Push(receiver(), this->name(), value());
|
|
|
| - __ mov(scratch1(), Operand(Smi::FromInt(strict_mode())));
|
| - __ push(scratch1()); // strict mode
|
| -
|
| // 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);
|
|
|
| // Handle store cache miss.
|
| __ bind(&miss);
|
| @@ -2917,12 +2637,10 @@ Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
|
| }
|
|
|
|
|
| -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.
|
| @@ -3018,14 +2736,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.
|
| __ mov(r3, Operand(cell));
|
|
|