OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 VisitForStackValue(args->at(i)); | 2234 VisitForStackValue(args->at(i)); |
2235 } | 2235 } |
2236 __ Set(ecx, Immediate(name)); | 2236 __ Set(ecx, Immediate(name)); |
2237 } | 2237 } |
2238 // Record source position of the IC call. | 2238 // Record source position of the IC call. |
2239 SetSourcePosition(expr->position()); | 2239 SetSourcePosition(expr->position()); |
2240 Handle<Code> ic = | 2240 Handle<Code> ic = |
2241 isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); | 2241 isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); |
2242 CallIC(ic, mode, expr->CallFeedbackId()); | 2242 CallIC(ic, mode, expr->CallFeedbackId()); |
2243 RecordJSReturnSite(expr); | 2243 RecordJSReturnSite(expr); |
2244 // Restore context register. | 2244 __ ReloadContextFromFrame(); |
2245 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | |
2246 context()->Plug(eax); | 2245 context()->Plug(eax); |
2247 } | 2246 } |
2248 | 2247 |
2249 | 2248 |
2250 void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, | 2249 void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
2251 Expression* key) { | 2250 Expression* key) { |
2252 // Load the key. | 2251 // Load the key. |
2253 VisitForAccumulatorValue(key); | 2252 VisitForAccumulatorValue(key); |
2254 | 2253 |
2255 // Swap the name of the function and the receiver on the stack to follow | 2254 // Swap the name of the function and the receiver on the stack to follow |
(...skipping 10 matching lines...) Expand all Loading... |
2266 VisitForStackValue(args->at(i)); | 2265 VisitForStackValue(args->at(i)); |
2267 } | 2266 } |
2268 } | 2267 } |
2269 // Record source position of the IC call. | 2268 // Record source position of the IC call. |
2270 SetSourcePosition(expr->position()); | 2269 SetSourcePosition(expr->position()); |
2271 Handle<Code> ic = | 2270 Handle<Code> ic = |
2272 isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count); | 2271 isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count); |
2273 __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key. | 2272 __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key. |
2274 CallIC(ic, RelocInfo::CODE_TARGET, expr->CallFeedbackId()); | 2273 CallIC(ic, RelocInfo::CODE_TARGET, expr->CallFeedbackId()); |
2275 RecordJSReturnSite(expr); | 2274 RecordJSReturnSite(expr); |
2276 // Restore context register. | 2275 __ ReloadContextFromFrame(); |
2277 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | |
2278 context()->DropAndPlug(1, eax); // Drop the key still on the stack. | 2276 context()->DropAndPlug(1, eax); // Drop the key still on the stack. |
2279 } | 2277 } |
2280 | 2278 |
2281 | 2279 |
2282 void FullCodeGenerator::EmitCallWithStub(Call* expr, CallFunctionFlags flags) { | 2280 void FullCodeGenerator::EmitCallWithStub(Call* expr, CallFunctionFlags flags) { |
2283 // Code common for calls using the call stub. | 2281 // Code common for calls using the call stub. |
2284 ZoneList<Expression*>* args = expr->arguments(); | 2282 ZoneList<Expression*>* args = expr->arguments(); |
2285 int arg_count = args->length(); | 2283 int arg_count = args->length(); |
2286 { PreservePositionScope scope(masm()->positions_recorder()); | 2284 { PreservePositionScope scope(masm()->positions_recorder()); |
2287 for (int i = 0; i < arg_count; i++) { | 2285 for (int i = 0; i < arg_count; i++) { |
(...skipping 10 matching lines...) Expand all Loading... |
2298 Handle<JSGlobalPropertyCell> cell = | 2296 Handle<JSGlobalPropertyCell> cell = |
2299 isolate()->factory()->NewJSGlobalPropertyCell(uninitialized); | 2297 isolate()->factory()->NewJSGlobalPropertyCell(uninitialized); |
2300 RecordTypeFeedbackCell(expr->CallFeedbackId(), cell); | 2298 RecordTypeFeedbackCell(expr->CallFeedbackId(), cell); |
2301 __ mov(ebx, cell); | 2299 __ mov(ebx, cell); |
2302 | 2300 |
2303 CallFunctionStub stub(arg_count, flags); | 2301 CallFunctionStub stub(arg_count, flags); |
2304 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2302 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
2305 __ CallStub(&stub, expr->CallFeedbackId()); | 2303 __ CallStub(&stub, expr->CallFeedbackId()); |
2306 | 2304 |
2307 RecordJSReturnSite(expr); | 2305 RecordJSReturnSite(expr); |
2308 // Restore context register. | 2306 __ ReloadContextFromFrame(); |
2309 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | |
2310 context()->DropAndPlug(1, eax); | 2307 context()->DropAndPlug(1, eax); |
2311 } | 2308 } |
2312 | 2309 |
2313 | 2310 |
2314 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { | 2311 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
2315 // Push copy of the first argument or undefined if it doesn't exist. | 2312 // Push copy of the first argument or undefined if it doesn't exist. |
2316 if (arg_count > 0) { | 2313 if (arg_count > 0) { |
2317 __ push(Operand(esp, arg_count * kPointerSize)); | 2314 __ push(Operand(esp, arg_count * kPointerSize)); |
2318 } else { | 2315 } else { |
2319 __ push(Immediate(isolate()->factory()->undefined_value())); | 2316 __ push(Immediate(isolate()->factory()->undefined_value())); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2368 // edx (receiver). Touch up the stack with the right values. | 2365 // edx (receiver). Touch up the stack with the right values. |
2369 __ mov(Operand(esp, (arg_count + 0) * kPointerSize), edx); | 2366 __ mov(Operand(esp, (arg_count + 0) * kPointerSize), edx); |
2370 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); | 2367 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); |
2371 } | 2368 } |
2372 // Record source position for debugger. | 2369 // Record source position for debugger. |
2373 SetSourcePosition(expr->position()); | 2370 SetSourcePosition(expr->position()); |
2374 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); | 2371 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); |
2375 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2372 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
2376 __ CallStub(&stub); | 2373 __ CallStub(&stub); |
2377 RecordJSReturnSite(expr); | 2374 RecordJSReturnSite(expr); |
2378 // Restore context register. | 2375 __ ReloadContextFromFrame(); |
2379 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | |
2380 context()->DropAndPlug(1, eax); | 2376 context()->DropAndPlug(1, eax); |
2381 | 2377 |
2382 } else if (proxy != NULL && proxy->var()->IsUnallocated()) { | 2378 } else if (proxy != NULL && proxy->var()->IsUnallocated()) { |
2383 // Push global object as receiver for the call IC. | 2379 // Push global object as receiver for the call IC. |
2384 __ push(GlobalObjectOperand()); | 2380 __ push(GlobalObjectOperand()); |
2385 EmitCallWithIC(expr, proxy->name(), RelocInfo::CODE_TARGET_CONTEXT); | 2381 EmitCallWithIC(expr, proxy->name(), RelocInfo::CODE_TARGET_CONTEXT); |
2386 | 2382 |
2387 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 2383 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
2388 // Call to a lookup slot (dynamically introduced variable). | 2384 // Call to a lookup slot (dynamically introduced variable). |
2389 Label slow, done; | 2385 Label slow, done; |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3388 // Check for non-function argument (including proxy). | 3384 // Check for non-function argument (including proxy). |
3389 __ JumpIfSmi(eax, &runtime); | 3385 __ JumpIfSmi(eax, &runtime); |
3390 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); | 3386 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); |
3391 __ j(not_equal, &runtime); | 3387 __ j(not_equal, &runtime); |
3392 | 3388 |
3393 // InvokeFunction requires the function in edi. Move it in there. | 3389 // InvokeFunction requires the function in edi. Move it in there. |
3394 __ mov(edi, result_register()); | 3390 __ mov(edi, result_register()); |
3395 ParameterCount count(arg_count); | 3391 ParameterCount count(arg_count); |
3396 __ InvokeFunction(edi, count, CALL_FUNCTION, | 3392 __ InvokeFunction(edi, count, CALL_FUNCTION, |
3397 NullCallWrapper(), CALL_AS_METHOD); | 3393 NullCallWrapper(), CALL_AS_METHOD); |
3398 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3394 __ ReloadContextFromFrame(); |
3399 __ jmp(&done); | 3395 __ jmp(&done); |
3400 | 3396 |
3401 __ bind(&runtime); | 3397 __ bind(&runtime); |
3402 __ push(eax); | 3398 __ push(eax); |
3403 __ CallRuntime(Runtime::kCall, args->length()); | 3399 __ CallRuntime(Runtime::kCall, args->length()); |
3404 __ bind(&done); | 3400 __ bind(&done); |
3405 | 3401 |
3406 context()->Plug(eax); | 3402 context()->Plug(eax); |
3407 } | 3403 } |
3408 | 3404 |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3797 __ jmp(&done); | 3793 __ jmp(&done); |
3798 | 3794 |
3799 | 3795 |
3800 __ bind(&bailout); | 3796 __ bind(&bailout); |
3801 __ mov(result_operand, isolate()->factory()->undefined_value()); | 3797 __ mov(result_operand, isolate()->factory()->undefined_value()); |
3802 __ bind(&done); | 3798 __ bind(&done); |
3803 __ mov(eax, result_operand); | 3799 __ mov(eax, result_operand); |
3804 // Drop temp values from the stack, and restore context register. | 3800 // Drop temp values from the stack, and restore context register. |
3805 __ add(esp, Immediate(3 * kPointerSize)); | 3801 __ add(esp, Immediate(3 * kPointerSize)); |
3806 | 3802 |
3807 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3803 __ ReloadContextFromFrame(); |
3808 context()->Plug(eax); | 3804 context()->Plug(eax); |
3809 } | 3805 } |
3810 | 3806 |
3811 | 3807 |
3812 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 3808 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
3813 Handle<String> name = expr->name(); | 3809 Handle<String> name = expr->name(); |
3814 if (name->length() > 0 && name->Get(0) == '_') { | 3810 if (name->length() > 0 && name->Get(0) == '_') { |
3815 Comment cmnt(masm_, "[ InlineRuntimeCall"); | 3811 Comment cmnt(masm_, "[ InlineRuntimeCall"); |
3816 EmitInlineRuntimeCall(expr); | 3812 EmitInlineRuntimeCall(expr); |
3817 return; | 3813 return; |
(...skipping 14 matching lines...) Expand all Loading... |
3832 VisitForStackValue(args->at(i)); | 3828 VisitForStackValue(args->at(i)); |
3833 } | 3829 } |
3834 | 3830 |
3835 if (expr->is_jsruntime()) { | 3831 if (expr->is_jsruntime()) { |
3836 // Call the JS runtime function via a call IC. | 3832 // Call the JS runtime function via a call IC. |
3837 __ Set(ecx, Immediate(expr->name())); | 3833 __ Set(ecx, Immediate(expr->name())); |
3838 RelocInfo::Mode mode = RelocInfo::CODE_TARGET; | 3834 RelocInfo::Mode mode = RelocInfo::CODE_TARGET; |
3839 Handle<Code> ic = | 3835 Handle<Code> ic = |
3840 isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); | 3836 isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); |
3841 CallIC(ic, mode, expr->CallRuntimeFeedbackId()); | 3837 CallIC(ic, mode, expr->CallRuntimeFeedbackId()); |
3842 // Restore context register. | 3838 __ ReloadContextFromFrame(); |
3843 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | |
3844 } else { | 3839 } else { |
3845 // Call the C runtime function. | 3840 // Call the C runtime function. |
3846 __ CallRuntime(expr->function(), arg_count); | 3841 __ CallRuntime(expr->function(), arg_count); |
3847 } | 3842 } |
3848 context()->Plug(eax); | 3843 context()->Plug(eax); |
3849 } | 3844 } |
3850 | 3845 |
3851 | 3846 |
3852 void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { | 3847 void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |
3853 switch (expr->op()) { | 3848 switch (expr->op()) { |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4550 *stack_depth = 0; | 4545 *stack_depth = 0; |
4551 *context_length = 0; | 4546 *context_length = 0; |
4552 return previous_; | 4547 return previous_; |
4553 } | 4548 } |
4554 | 4549 |
4555 #undef __ | 4550 #undef __ |
4556 | 4551 |
4557 } } // namespace v8::internal | 4552 } } // namespace v8::internal |
4558 | 4553 |
4559 #endif // V8_TARGET_ARCH_IA32 | 4554 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |