OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 // -- esp[kFastApiCallArguments * 4 + 4] : last argument in the internal | 405 // -- esp[kFastApiCallArguments * 4 + 4] : last argument in the internal |
406 // frame. | 406 // frame. |
407 // ----------------------------------- | 407 // ----------------------------------- |
408 __ pop(scratch); | 408 __ pop(scratch); |
409 __ add(esp, Immediate(kPointerSize * kFastApiCallArguments)); | 409 __ add(esp, Immediate(kPointerSize * kFastApiCallArguments)); |
410 __ push(scratch); | 410 __ push(scratch); |
411 } | 411 } |
412 | 412 |
413 | 413 |
414 // Generates call to API function. | 414 // Generates call to API function. |
415 static MaybeObject* GenerateFastApiCall(MacroAssembler* masm, | 415 static MaybeObject* GenerateFastApiCall(MacroAssembler* masm, |
Vyacheslav Egorov (Chromium)
2011/10/12 12:36:05
check all callers for gc safeness.
| |
416 const CallOptimization& optimization, | 416 const CallOptimization& optimization, |
417 int argc) { | 417 int argc) { |
418 // ----------- S t a t e ------------- | 418 // ----------- S t a t e ------------- |
419 // -- esp[0] : return address | 419 // -- esp[0] : return address |
420 // -- esp[4] : object passing the type check | 420 // -- esp[4] : object passing the type check |
421 // (last fast api call extra argument, | 421 // (last fast api call extra argument, |
422 // set by CheckPrototypes) | 422 // set by CheckPrototypes) |
423 // -- esp[8] : api function | 423 // -- esp[8] : api function |
424 // (first fast api call extra argument) | 424 // (first fast api call extra argument) |
425 // -- esp[12] : api call data | 425 // -- esp[12] : api call data |
426 // -- esp[16] : last argument | 426 // -- esp[16] : last argument |
427 // -- ... | 427 // -- ... |
428 // -- esp[(argc + 3) * 4] : first argument | 428 // -- esp[(argc + 3) * 4] : first argument |
429 // -- esp[(argc + 4) * 4] : receiver | 429 // -- esp[(argc + 4) * 4] : receiver |
430 // ----------------------------------- | 430 // ----------------------------------- |
431 // Get the function and setup the context. | 431 // Get the function and setup the context. |
432 JSFunction* function = optimization.constant_function(); | 432 JSFunction* function = optimization.constant_function(); |
433 __ mov(edi, Immediate(Handle<JSFunction>(function))); | 433 __ LoadHeapObject(edi, Handle<JSFunction>(function)); |
434 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 434 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
435 | 435 |
436 // Pass the additional arguments. | 436 // Pass the additional arguments. |
437 __ mov(Operand(esp, 2 * kPointerSize), edi); | 437 __ mov(Operand(esp, 2 * kPointerSize), edi); |
438 Object* call_data = optimization.api_call_info()->data(); | 438 Object* call_data = optimization.api_call_info()->data(); |
439 Handle<CallHandlerInfo> api_call_info_handle(optimization.api_call_info()); | 439 Handle<CallHandlerInfo> api_call_info_handle(optimization.api_call_info()); |
440 if (masm->isolate()->heap()->InNewSpace(call_data)) { | 440 if (masm->isolate()->heap()->InNewSpace(call_data)) { |
441 __ mov(ecx, api_call_info_handle); | 441 __ mov(ecx, api_call_info_handle); |
442 __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset)); | 442 __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset)); |
443 __ mov(Operand(esp, 3 * kPointerSize), ebx); | 443 __ mov(Operand(esp, 3 * kPointerSize), ebx); |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1099 __ mov(ApiParameterOperand(1), ebx); // arguments pointer. | 1099 __ mov(ApiParameterOperand(1), ebx); // arguments pointer. |
1100 | 1100 |
1101 // Emitting a stub call may try to allocate (if the code is not | 1101 // Emitting a stub call may try to allocate (if the code is not |
1102 // already generated). Do not allow the assembler to perform a | 1102 // already generated). Do not allow the assembler to perform a |
1103 // garbage collection but instead return the allocation failure | 1103 // garbage collection but instead return the allocation failure |
1104 // object. | 1104 // object. |
1105 return masm()->TryCallApiFunctionAndReturn(&fun, kStackSpace); | 1105 return masm()->TryCallApiFunctionAndReturn(&fun, kStackSpace); |
1106 } | 1106 } |
1107 | 1107 |
1108 | 1108 |
1109 void StubCompiler::GenerateLoadConstant(JSObject* object, | 1109 void StubCompiler::GenerateLoadConstant(JSObject* object, |
Vyacheslav Egorov (Chromium)
2011/10/12 12:36:05
check all callers for gc safeness.
| |
1110 JSObject* holder, | 1110 JSObject* holder, |
1111 Register receiver, | 1111 Register receiver, |
1112 Register scratch1, | 1112 Register scratch1, |
1113 Register scratch2, | 1113 Register scratch2, |
1114 Register scratch3, | 1114 Register scratch3, |
1115 Object* value, | 1115 JSFunction* value, |
1116 String* name, | 1116 String* name, |
1117 Label* miss) { | 1117 Label* miss) { |
1118 // Check that the receiver isn't a smi. | 1118 // Check that the receiver isn't a smi. |
1119 __ JumpIfSmi(receiver, miss); | 1119 __ JumpIfSmi(receiver, miss); |
1120 | 1120 |
1121 // Check that the maps haven't changed. | 1121 // Check that the maps haven't changed. |
1122 CheckPrototypes(object, receiver, holder, | 1122 CheckPrototypes(object, receiver, holder, |
1123 scratch1, scratch2, scratch3, name, miss); | 1123 scratch1, scratch2, scratch3, name, miss); |
1124 | 1124 |
1125 // Return the constant value. | 1125 __ LoadHeapObject(eax, Handle<JSFunction>(value)); |
1126 __ mov(eax, Handle<Object>(value)); | |
1127 __ ret(0); | 1126 __ ret(0); |
1128 } | 1127 } |
1129 | 1128 |
1130 | 1129 |
1131 void StubCompiler::GenerateLoadInterceptor(JSObject* object, | 1130 void StubCompiler::GenerateLoadInterceptor(JSObject* object, |
1132 JSObject* interceptor_holder, | 1131 JSObject* interceptor_holder, |
1133 LookupResult* lookup, | 1132 LookupResult* lookup, |
1134 Register receiver, | 1133 Register receiver, |
1135 Register name_reg, | 1134 Register name_reg, |
1136 Register scratch1, | 1135 Register scratch1, |
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2872 __ bind(&miss); | 2871 __ bind(&miss); |
2873 GenerateLoadMiss(masm(), Code::LOAD_IC); | 2872 GenerateLoadMiss(masm(), Code::LOAD_IC); |
2874 | 2873 |
2875 // Return the generated code. | 2874 // Return the generated code. |
2876 return GetCode(CALLBACKS, name); | 2875 return GetCode(CALLBACKS, name); |
2877 } | 2876 } |
2878 | 2877 |
2879 | 2878 |
2880 MaybeObject* LoadStubCompiler::CompileLoadConstant(JSObject* object, | 2879 MaybeObject* LoadStubCompiler::CompileLoadConstant(JSObject* object, |
2881 JSObject* holder, | 2880 JSObject* holder, |
2882 Object* value, | 2881 JSFunction* value, |
2883 String* name) { | 2882 String* name) { |
2884 // ----------- S t a t e ------------- | 2883 // ----------- S t a t e ------------- |
2885 // -- eax : receiver | 2884 // -- eax : receiver |
2886 // -- ecx : name | 2885 // -- ecx : name |
2887 // -- esp[0] : return address | 2886 // -- esp[0] : return address |
2888 // ----------------------------------- | 2887 // ----------------------------------- |
2889 Label miss; | 2888 Label miss; |
2890 | 2889 |
2891 GenerateLoadConstant(object, holder, eax, ebx, edx, edi, value, name, &miss); | 2890 GenerateLoadConstant(object, holder, eax, ebx, edx, edi, value, name, &miss); |
2892 __ bind(&miss); | 2891 __ bind(&miss); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3045 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 3044 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
3046 | 3045 |
3047 // Return the generated code. | 3046 // Return the generated code. |
3048 return GetCode(CALLBACKS, name); | 3047 return GetCode(CALLBACKS, name); |
3049 } | 3048 } |
3050 | 3049 |
3051 | 3050 |
3052 MaybeObject* KeyedLoadStubCompiler::CompileLoadConstant(String* name, | 3051 MaybeObject* KeyedLoadStubCompiler::CompileLoadConstant(String* name, |
3053 JSObject* receiver, | 3052 JSObject* receiver, |
3054 JSObject* holder, | 3053 JSObject* holder, |
3055 Object* value) { | 3054 JSFunction* value) { |
3056 // ----------- S t a t e ------------- | 3055 // ----------- S t a t e ------------- |
3057 // -- eax : key | 3056 // -- eax : key |
3058 // -- edx : receiver | 3057 // -- edx : receiver |
3059 // -- esp[0] : return address | 3058 // -- esp[0] : return address |
3060 // ----------------------------------- | 3059 // ----------------------------------- |
3061 Label miss; | 3060 Label miss; |
3062 | 3061 |
3063 Counters* counters = isolate()->counters(); | 3062 Counters* counters = isolate()->counters(); |
3064 __ IncrementCounter(counters->keyed_load_constant_function(), 1); | 3063 __ IncrementCounter(counters->keyed_load_constant_function(), 1); |
3065 | 3064 |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4009 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); | 4008 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); |
4010 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); | 4009 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); |
4011 } | 4010 } |
4012 | 4011 |
4013 | 4012 |
4014 #undef __ | 4013 #undef __ |
4015 | 4014 |
4016 } } // namespace v8::internal | 4015 } } // namespace v8::internal |
4017 | 4016 |
4018 #endif // V8_TARGET_ARCH_IA32 | 4017 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |