| Index: src/ia32/stub-cache-ia32.cc
|
| diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc
|
| index d12e682add3a4157cb9334fc60ce7ab023457651..a5b93b9b22ebf4ffc6ae62cc42114701efb0ea67 100644
|
| --- a/src/ia32/stub-cache-ia32.cc
|
| +++ b/src/ia32/stub-cache-ia32.cc
|
| @@ -418,11 +418,30 @@ static void CompileCallLoadPropertyWithInterceptor(
|
| }
|
|
|
|
|
| -static void GenerateFastApiCallBody(MacroAssembler* masm,
|
| - const CallOptimization& optimization,
|
| - int argc,
|
| - Register holder_in,
|
| - bool restore_context) {
|
| +// Generate call to api function.
|
| +// This function uses push() to generate smaller, faster code than
|
| +// the version above. It is an optimization that should will be removed
|
| +// when api call ICs are generated in hydrogen.
|
| +static void GenerateFastApiCall(MacroAssembler* masm,
|
| + const CallOptimization& optimization,
|
| + Handle<Map> receiver_map,
|
| + Register receiver,
|
| + Register scratch_in,
|
| + int argc,
|
| + Register* values) {
|
| + // Copy return value.
|
| + __ pop(scratch_in);
|
| + // receiver
|
| + __ push(receiver);
|
| + // Write the arguments to stack frame.
|
| + for (int i = 0; i < argc; i++) {
|
| + Register arg = values[argc-1-i];
|
| + ASSERT(!receiver.is(arg));
|
| + ASSERT(!scratch_in.is(arg));
|
| + __ push(arg);
|
| + }
|
| + __ push(scratch_in);
|
| + // Stack now matches JSFunction abi.
|
| ASSERT(optimization.is_simple_api_call());
|
|
|
| // Abi for CallApiFunctionStub.
|
| @@ -430,11 +449,24 @@ static void GenerateFastApiCallBody(MacroAssembler* masm,
|
| Register call_data = ebx;
|
| Register holder = ecx;
|
| Register api_function_address = edx;
|
| + Register scratch = edi; // scratch_in is no longer valid.
|
|
|
| // Put holder in place.
|
| - __ Move(holder, holder_in);
|
| -
|
| - Register scratch = edi;
|
| + CallOptimization::HolderLookup holder_lookup;
|
| + Handle<JSObject> api_holder = optimization.LookupHolderOfExpectedType(
|
| + receiver_map,
|
| + &holder_lookup);
|
| + switch (holder_lookup) {
|
| + case CallOptimization::kHolderIsReceiver:
|
| + __ Move(holder, receiver);
|
| + break;
|
| + case CallOptimization::kHolderFound:
|
| + __ LoadHeapObject(holder, api_holder);
|
| + break;
|
| + case CallOptimization::kHolderNotFound:
|
| + UNREACHABLE();
|
| + break;
|
| + }
|
|
|
| Isolate* isolate = masm->isolate();
|
| Handle<JSFunction> function = optimization.constant_function();
|
| @@ -461,42 +493,11 @@ static void GenerateFastApiCallBody(MacroAssembler* masm,
|
| __ mov(api_function_address, Immediate(function_address));
|
|
|
| // Jump to stub.
|
| - CallApiFunctionStub stub(restore_context, call_data_undefined, argc);
|
| + CallApiFunctionStub stub(true, call_data_undefined, argc);
|
| __ TailCallStub(&stub);
|
| }
|
|
|
|
|
| -// Generate call to api function.
|
| -// This function uses push() to generate smaller, faster code than
|
| -// the version above. It is an optimization that should will be removed
|
| -// when api call ICs are generated in hydrogen.
|
| -static void GenerateFastApiCall(MacroAssembler* masm,
|
| - const CallOptimization& optimization,
|
| - Register receiver,
|
| - Register scratch1,
|
| - int argc,
|
| - Register* values) {
|
| - // Copy return value.
|
| - __ pop(scratch1);
|
| - // receiver
|
| - __ push(receiver);
|
| - // Write the arguments to stack frame.
|
| - for (int i = 0; i < argc; i++) {
|
| - Register arg = values[argc-1-i];
|
| - ASSERT(!receiver.is(arg));
|
| - ASSERT(!scratch1.is(arg));
|
| - __ push(arg);
|
| - }
|
| - __ push(scratch1);
|
| - // Stack now matches JSFunction abi.
|
| - GenerateFastApiCallBody(masm,
|
| - optimization,
|
| - argc,
|
| - receiver,
|
| - true);
|
| -}
|
| -
|
| -
|
| void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
|
| Label* label,
|
| Handle<Name> name) {
|
| @@ -1065,10 +1066,11 @@ void LoadStubCompiler::GenerateLoadField(Register reg,
|
|
|
|
|
| void LoadStubCompiler::GenerateLoadCallback(
|
| - const CallOptimization& call_optimization) {
|
| + const CallOptimization& call_optimization,
|
| + Handle<Map> receiver_map) {
|
| GenerateFastApiCall(
|
| - masm(), call_optimization, receiver(),
|
| - scratch1(), 0, NULL);
|
| + masm(), call_optimization, receiver_map,
|
| + receiver(), scratch1(), 0, NULL);
|
| }
|
|
|
|
|
| @@ -1271,8 +1273,8 @@ Handle<Code> StoreStubCompiler::CompileStoreCallback(
|
|
|
| Register values[] = { value() };
|
| GenerateFastApiCall(
|
| - masm(), call_optimization, receiver(),
|
| - scratch1(), 1, values);
|
| + masm(), call_optimization, handle(object->map()),
|
| + receiver(), scratch1(), 1, values);
|
|
|
| // Return the generated code.
|
| return GetCode(kind(), Code::FAST, name);
|
| @@ -1285,6 +1287,7 @@ Handle<Code> StoreStubCompiler::CompileStoreCallback(
|
|
|
| void StoreStubCompiler::GenerateStoreViaSetter(
|
| MacroAssembler* masm,
|
| + Handle<HeapType> type,
|
| Handle<JSFunction> setter) {
|
| // ----------- S t a t e -------------
|
| // -- eax : value
|
| @@ -1294,14 +1297,21 @@ void StoreStubCompiler::GenerateStoreViaSetter(
|
| // -----------------------------------
|
| {
|
| FrameScope scope(masm, StackFrame::INTERNAL);
|
| + Register receiver = edx;
|
| + Register value = eax;
|
|
|
| // Save value register, so we can restore it later.
|
| - __ push(eax);
|
| + __ push(value);
|
|
|
| if (!setter.is_null()) {
|
| // Call the JavaScript setter with receiver and value on the stack.
|
| - __ push(edx);
|
| - __ push(eax);
|
| + if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
|
| + // Swap in the global receiver.
|
| + __ mov(receiver,
|
| + FieldOperand(receiver, JSGlobalObject::kGlobalReceiverOffset));
|
| + }
|
| + __ push(receiver);
|
| + __ push(value);
|
| ParameterCount actual(1);
|
| ParameterCount expected(setter);
|
| __ InvokeFunction(setter, expected, actual,
|
| @@ -1421,6 +1431,7 @@ Register* KeyedStoreStubCompiler::registers() {
|
|
|
|
|
| void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
|
| + Handle<HeapType> type,
|
| Register receiver,
|
| Handle<JSFunction> getter) {
|
| {
|
| @@ -1428,6 +1439,11 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
|
|
|
| if (!getter.is_null()) {
|
| // Call the JavaScript getter with the receiver on the stack.
|
| + if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
|
| + // Swap in the global receiver.
|
| + __ mov(receiver,
|
| + FieldOperand(receiver, JSGlobalObject::kGlobalReceiverOffset));
|
| + }
|
| __ push(receiver);
|
| ParameterCount actual(0);
|
| ParameterCount expected(getter);
|
|
|