diff options
Diffstat (limited to 'deps/v8/src/x64/stub-cache-x64.cc')
-rw-r--r-- | deps/v8/src/x64/stub-cache-x64.cc | 199 |
1 files changed, 143 insertions, 56 deletions
diff --git a/deps/v8/src/x64/stub-cache-x64.cc b/deps/v8/src/x64/stub-cache-x64.cc index 06d8f7108b..4b3ee400f3 100644 --- a/deps/v8/src/x64/stub-cache-x64.cc +++ b/deps/v8/src/x64/stub-cache-x64.cc @@ -27,7 +27,7 @@ #include "v8.h" -#if defined(V8_TARGET_ARCH_X64) +#if V8_TARGET_ARCH_X64 #include "ic-inl.h" #include "codegen.h" @@ -53,7 +53,7 @@ static void ProbeTable(Isolate* isolate, ASSERT(kPointerSizeLog2 == kHeapObjectTagSize + 1); ScaleFactor scale_factor = times_2; - ASSERT_EQ(24, sizeof(StubCache::Entry)); + ASSERT_EQ(3 * kPointerSize, sizeof(StubCache::Entry)); // The offset register holds the entry offset times four (due to masking // and shifting optimizations). ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); @@ -171,8 +171,8 @@ void StubCache::GenerateProbe(MacroAssembler* masm, USE(extra2); // The register extra2 is not used on the X64 platform. USE(extra3); // The register extra2 is not used on the X64 platform. // Make sure that code is valid. The multiplying code relies on the - // entry size being 24. - ASSERT(sizeof(Entry) == 24); + // entry size being 3 * kPointerSize. + ASSERT(sizeof(Entry) == 3 * kPointerSize); // Make sure the flags do not name a specific type. ASSERT(Code::ExtractTypeFromFlags(flags) == 0); @@ -423,10 +423,11 @@ static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) { // Undoes the effects of ReserveSpaceForFastApiCall. static void FreeSpaceForFastApiCall(MacroAssembler* masm, Register scratch) { // ----------- S t a t e ------------- - // -- rsp[0] : return address. - // -- rsp[8] : last fast api call extra argument. + // -- rsp[0] : return address. + // -- rsp[8] : last fast api call extra argument. // -- ... - // -- rsp[kFastApiCallArguments * 8] : first fast api call extra argument. + // -- rsp[kFastApiCallArguments * 8] : first fast api call extra + // argument. // -- rsp[kFastApiCallArguments * 8 + 8] : last argument in the internal // frame. // ----------------------------------- @@ -491,11 +492,14 @@ static void GenerateFastApiCall(MacroAssembler* masm, #if defined(__MINGW64__) Register arguments_arg = rcx; + Register callback_arg = rdx; #elif defined(_WIN64) // Win64 uses first register--rcx--for returned value. Register arguments_arg = returns_handle ? rdx : rcx; + Register callback_arg = returns_handle ? r8 : rdx; #else Register arguments_arg = rdi; + Register callback_arg = rsi; #endif // Allocate the v8::Arguments structure in the arguments' space since @@ -514,7 +518,13 @@ static void GenerateFastApiCall(MacroAssembler* masm, // v8::InvocationCallback's argument. __ lea(arguments_arg, StackSpaceOperand(0)); + Address thunk_address = returns_handle + ? FUNCTION_ADDR(&InvokeInvocationCallback) + : FUNCTION_ADDR(&InvokeFunctionCallback); + __ CallApiFunctionAndReturn(function_address, + thunk_address, + callback_arg, argc + kFastApiCallArguments + 1, returns_handle, kFastApiCallArguments + 1); @@ -737,11 +747,11 @@ static void GenerateCheckPropertyCell(MacroAssembler* masm, Handle<Name> name, Register scratch, Label* miss) { - Handle<JSGlobalPropertyCell> cell = + Handle<PropertyCell> cell = GlobalObject::EnsurePropertyCell(global, name); ASSERT(cell->value()->IsTheHole()); __ Move(scratch, cell); - __ Cmp(FieldOperand(scratch, JSGlobalPropertyCell::kValueOffset), + __ Cmp(FieldOperand(scratch, Cell::kValueOffset), masm->isolate()->factory()->the_hole_value()); __ j(not_equal, miss); } @@ -817,7 +827,13 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, Register storage_reg = name_reg; - if (FLAG_track_fields && representation.IsSmi()) { + if (details.type() == CONSTANT_FUNCTION) { + Handle<HeapObject> constant( + HeapObject::cast(descriptors->GetValue(descriptor))); + __ LoadHeapObject(scratch1, constant); + __ cmpq(value_reg, scratch1); + __ j(not_equal, miss_restore_name); + } else if (FLAG_track_fields && representation.IsSmi()) { __ JumpIfNotSmi(value_reg, miss_restore_name); } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { __ JumpIfSmi(value_reg, miss_restore_name); @@ -844,7 +860,8 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); // Perform map transition for the receiver if necessary. - if (object->map()->unused_property_fields() == 0) { + if (details.type() == FIELD && + object->map()->unused_property_fields() == 0) { // The properties must be extended before we can store the value. // We jump to a runtime call that extends the properties array. __ pop(scratch1); // Return address. @@ -873,6 +890,12 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, OMIT_REMEMBERED_SET, OMIT_SMI_CHECK); + if (details.type() == CONSTANT_FUNCTION) { + ASSERT(value_reg.is(rax)); + __ ret(0); + return; + } + int index = transition->instance_descriptors()->GetFieldIndex( transition->LastAdded()); @@ -1293,8 +1316,8 @@ void BaseLoadStubCompiler::GenerateLoadCallback( Register reg, Handle<ExecutableAccessorInfo> callback) { // Insert additional parameters into the stack frame above return address. - ASSERT(!scratch2().is(reg)); - __ pop(scratch2()); // Get return address to place it below. + ASSERT(!scratch4().is(reg)); + __ pop(scratch4()); // Get return address to place it below. __ push(receiver()); // receiver __ push(reg); // holder @@ -1318,20 +1341,23 @@ void BaseLoadStubCompiler::GenerateLoadCallback( !CallbackTable::ReturnsVoid(isolate(), getter_address); #if defined(__MINGW64__) + Register getter_arg = r8; Register accessor_info_arg = rdx; Register name_arg = rcx; #elif defined(_WIN64) // Win64 uses first register--rcx--for returned value. + Register getter_arg = returns_handle ? r9 : r8; Register accessor_info_arg = returns_handle ? r8 : rdx; Register name_arg = returns_handle ? rdx : rcx; #else + Register getter_arg = rdx; Register accessor_info_arg = rsi; Register name_arg = rdi; #endif - ASSERT(!name_arg.is(scratch2())); + ASSERT(!name_arg.is(scratch4())); __ movq(name_arg, rsp); - __ push(scratch2()); // Restore return address. + __ push(scratch4()); // Restore return address. // v8::Arguments::values_ and handler for name. const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1; @@ -1350,7 +1376,13 @@ void BaseLoadStubCompiler::GenerateLoadCallback( // could be used to pass arguments. __ lea(accessor_info_arg, StackSpaceOperand(0)); + Address thunk_address = returns_handle + ? FUNCTION_ADDR(&InvokeAccessorGetter) + : FUNCTION_ADDR(&InvokeAccessorGetterCallback); + __ CallApiFunctionAndReturn(getter_address, + thunk_address, + getter_arg, kStackSpace, returns_handle, 5); @@ -1485,12 +1517,12 @@ void CallStubCompiler::GenerateGlobalReceiverCheck(Handle<JSObject> object, void CallStubCompiler::GenerateLoadFunctionFromCell( - Handle<JSGlobalPropertyCell> cell, + Handle<Cell> cell, Handle<JSFunction> function, Label* miss) { // Get the value from the cell. __ Move(rdi, cell); - __ movq(rdi, FieldOperand(rdi, JSGlobalPropertyCell::kValueOffset)); + __ movq(rdi, FieldOperand(rdi, Cell::kValueOffset)); // Check that the cell contains the same function. if (heap()->InNewSpace(*function)) { @@ -1581,12 +1613,59 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object, } +Handle<Code> CallStubCompiler::CompileArrayCodeCall( + Handle<Object> object, + Handle<JSObject> holder, + Handle<Cell> cell, + Handle<JSFunction> function, + Handle<String> name, + 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. + __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); + + // Check that the receiver isn't a smi. + __ JumpIfSmi(rdx, &miss); + CheckPrototypes(Handle<JSObject>::cast(object), rdx, holder, rbx, rax, rdi, + name, &miss); + } else { + ASSERT(cell->value() == *function); + GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name, + &miss); + GenerateLoadFunctionFromCell(cell, function, &miss); + } + + Handle<Smi> kind(Smi::FromInt(GetInitialFastElementsKind()), isolate()); + Handle<Cell> kind_feedback_cell = + isolate()->factory()->NewCell(kind); + __ movq(rax, Immediate(argc)); + __ Move(rbx, kind_feedback_cell); + __ Move(rdi, function); + + ArrayConstructorStub stub(isolate()); + __ TailCallStub(&stub); + + __ bind(&miss); + GenerateMissBranch(); + + // Return the generated code. + return GetCode(type, name); +} + + Handle<Code> CallStubCompiler::CompileArrayPushCall( Handle<Object> object, Handle<JSObject> holder, - Handle<JSGlobalPropertyCell> cell, + Handle<Cell> cell, Handle<JSFunction> function, - Handle<String> name) { + Handle<String> name, + Code::StubType type) { // ----------- S t a t e ------------- // -- rcx : name // -- rsp[0] : return address @@ -1827,16 +1906,17 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( GenerateMissBranch(); // Return the generated code. - return GetCode(function); + return GetCode(type, name); } Handle<Code> CallStubCompiler::CompileArrayPopCall( Handle<Object> object, Handle<JSObject> holder, - Handle<JSGlobalPropertyCell> cell, + Handle<Cell> cell, Handle<JSFunction> function, - Handle<String> name) { + Handle<String> name, + Code::StubType type) { // ----------- S t a t e ------------- // -- rcx : name // -- rsp[0] : return address @@ -1908,16 +1988,17 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall( GenerateMissBranch(); // Return the generated code. - return GetCode(function); + return GetCode(type, name); } Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall( Handle<Object> object, Handle<JSObject> holder, - Handle<JSGlobalPropertyCell> cell, + Handle<Cell> cell, Handle<JSFunction> function, - Handle<String> name) { + Handle<String> name, + Code::StubType type) { // ----------- S t a t e ------------- // -- rcx : function name // -- rsp[0] : return address @@ -1988,16 +2069,17 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall( GenerateMissBranch(); // Return the generated code. - return GetCode(function); + return GetCode(type, name); } Handle<Code> CallStubCompiler::CompileStringCharAtCall( Handle<Object> object, Handle<JSObject> holder, - Handle<JSGlobalPropertyCell> cell, + Handle<Cell> cell, Handle<JSFunction> function, - Handle<String> name) { + Handle<String> name, + Code::StubType type) { // ----------- S t a t e ------------- // -- rcx : function name // -- rsp[0] : return address @@ -2068,16 +2150,17 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall( GenerateMissBranch(); // Return the generated code. - return GetCode(function); + return GetCode(type, name); } Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall( Handle<Object> object, Handle<JSObject> holder, - Handle<JSGlobalPropertyCell> cell, + Handle<Cell> cell, Handle<JSFunction> function, - Handle<String> name) { + Handle<String> name, + Code::StubType type) { // ----------- S t a t e ------------- // -- rcx : function name // -- rsp[0] : return address @@ -2139,16 +2222,17 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall( GenerateMissBranch(); // Return the generated code. - return cell.is_null() ? GetCode(function) : GetCode(Code::NORMAL, name); + return GetCode(type, name); } Handle<Code> CallStubCompiler::CompileMathFloorCall( Handle<Object> object, Handle<JSObject> holder, - Handle<JSGlobalPropertyCell> cell, + Handle<Cell> cell, Handle<JSFunction> function, - Handle<String> name) { + Handle<String> name, + Code::StubType type) { // TODO(872): implement this. return Handle<Code>::null(); } @@ -2157,9 +2241,10 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall( Handle<Code> CallStubCompiler::CompileMathAbsCall( Handle<Object> object, Handle<JSObject> holder, - Handle<JSGlobalPropertyCell> cell, + Handle<Cell> cell, Handle<JSFunction> function, - Handle<String> name) { + Handle<String> name, + Code::StubType type) { // ----------- S t a t e ------------- // -- rcx : function name // -- rsp[0] : return address @@ -2255,7 +2340,7 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall( GenerateMissBranch(); // Return the generated code. - return cell.is_null() ? GetCode(function) : GetCode(Code::NORMAL, name); + return GetCode(type, name); } @@ -2263,7 +2348,7 @@ Handle<Code> CallStubCompiler::CompileFastApiCall( const CallOptimization& optimization, Handle<Object> object, Handle<JSObject> holder, - Handle<JSGlobalPropertyCell> cell, + Handle<Cell> cell, Handle<JSFunction> function, Handle<String> name) { ASSERT(optimization.is_simple_api_call()); @@ -2445,8 +2530,9 @@ Handle<Code> CallStubCompiler::CompileCallConstant( Handle<JSFunction> function) { if (HasCustomCallGenerator(function)) { Handle<Code> code = CompileCustomCall(object, holder, - Handle<JSGlobalPropertyCell>::null(), - function, Handle<String>::cast(name)); + Handle<PropertyCell>::null(), + function, Handle<String>::cast(name), + Code::CONSTANT_FUNCTION); // A null handle means bail out to the regular compiler code below. if (!code.is_null()) return code; } @@ -2525,7 +2611,7 @@ Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object, Handle<Code> CallStubCompiler::CompileCallGlobal( Handle<JSObject> object, Handle<GlobalObject> holder, - Handle<JSGlobalPropertyCell> cell, + Handle<PropertyCell> cell, Handle<JSFunction> function, Handle<Name> name) { // ----------- S t a t e ------------- @@ -2540,7 +2626,8 @@ Handle<Code> CallStubCompiler::CompileCallGlobal( if (HasCustomCallGenerator(function)) { Handle<Code> code = CompileCustomCall( - object, holder, cell, function, Handle<String>::cast(name)); + object, holder, cell, function, Handle<String>::cast(name), + Code::NORMAL); // A null handle means bail out to the regular compiler code below. if (!code.is_null()) return code; } @@ -2708,7 +2795,7 @@ Handle<Code> StoreStubCompiler::CompileStoreInterceptor( Handle<Code> StoreStubCompiler::CompileStoreGlobal( Handle<GlobalObject> object, - Handle<JSGlobalPropertyCell> cell, + Handle<PropertyCell> cell, Handle<Name> name) { Label miss; @@ -2720,7 +2807,7 @@ Handle<Code> StoreStubCompiler::CompileStoreGlobal( // Compute the cell operand to use. __ Move(scratch1(), cell); Operand cell_operand = - FieldOperand(scratch1(), JSGlobalPropertyCell::kValueOffset); + FieldOperand(scratch1(), PropertyCell::kValueOffset); // Check that the value in the cell is not the hole. If it is, this // cell could have been deleted and reintroducing the global needs @@ -2888,7 +2975,7 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, Handle<Code> LoadStubCompiler::CompileLoadGlobal( Handle<JSObject> object, Handle<GlobalObject> global, - Handle<JSGlobalPropertyCell> cell, + Handle<PropertyCell> cell, Handle<Name> name, bool is_dont_delete) { Label success, miss; @@ -2902,7 +2989,7 @@ Handle<Code> LoadStubCompiler::CompileLoadGlobal( // Get the value from the cell. __ Move(rbx, cell); - __ movq(rbx, FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset)); + __ movq(rbx, FieldOperand(rbx, PropertyCell::kValueOffset)); // Check for deleted property if property can actually be deleted. if (!is_dont_delete) { @@ -2996,7 +3083,7 @@ void KeyedLoadStubCompiler::GenerateLoadDictionaryElement( // ----------- S t a t e ------------- // -- rax : key // -- rdx : receiver - // -- rsp[0] : return address + // -- rsp[0] : return address // ----------------------------------- TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Slow); @@ -3004,7 +3091,7 @@ void KeyedLoadStubCompiler::GenerateLoadDictionaryElement( // ----------- S t a t e ------------- // -- rax : key // -- rdx : receiver - // -- rsp[0] : return address + // -- rsp[0] : return address // ----------------------------------- TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); } @@ -3039,10 +3126,10 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( MacroAssembler* masm, ElementsKind elements_kind) { // ----------- S t a t e ------------- - // -- rax : value - // -- rcx : key - // -- rdx : receiver - // -- rsp[0] : return address + // -- rax : value + // -- rcx : key + // -- rdx : receiver + // -- rsp[0] : return address // ----------------------------------- Label slow, miss_force_generic; @@ -3199,10 +3286,10 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( __ bind(&slow); // ----------- S t a t e ------------- - // -- rax : value - // -- rcx : key - // -- rdx : receiver - // -- rsp[0] : return address + // -- rax : value + // -- rcx : key + // -- rdx : receiver + // -- rsp[0] : return address // ----------------------------------- TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |