Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 111613003: Load the global proxy from the context of the target function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: hydrogen Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 } 2546 }
2547 2547
2548 2548
2549 void CallFunctionStub::Generate(MacroAssembler* masm) { 2549 void CallFunctionStub::Generate(MacroAssembler* masm) {
2550 // rbx : cache cell for call target 2550 // rbx : cache cell for call target
2551 // rdi : the function to call 2551 // rdi : the function to call
2552 Isolate* isolate = masm->isolate(); 2552 Isolate* isolate = masm->isolate();
2553 Label slow, non_function; 2553 Label slow, non_function;
2554 StackArgumentsAccessor args(rsp, argc_); 2554 StackArgumentsAccessor args(rsp, argc_);
2555 2555
2556 // Check that the function really is a JavaScript function.
2557 __ JumpIfSmi(rdi, &non_function);
2558
2556 // The receiver might implicitly be the global object. This is 2559 // The receiver might implicitly be the global object. This is
2557 // indicated by passing the hole as the receiver to the call 2560 // indicated by passing the hole as the receiver to the call
2558 // function stub. 2561 // function stub.
2559 if (ReceiverMightBeImplicit()) { 2562 if (ReceiverMightBeImplicit() || ReceiverIsImplicit()) {
2560 Label call; 2563 Label call, patch_current_context;
2561 // Get the receiver from the stack. 2564 if (ReceiverMightBeImplicit()) {
2562 __ movq(rax, args.GetReceiverOperand()); 2565 // Get the receiver from the stack.
2563 // Call as function is indicated with the hole. 2566 __ movq(rax, args.GetReceiverOperand());
2564 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); 2567 // Call as function is indicated with the hole.
2565 __ j(not_equal, &call, Label::kNear); 2568 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
2569 __ j(not_equal, &call, Label::kNear);
2570 }
2566 // Patch the receiver on the stack with the global receiver object. 2571 // Patch the receiver on the stack with the global receiver object.
2572 // Goto slow case if we do not have a function.
2573 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2574 __ j(not_equal, &patch_current_context);
2575 CallStubCompiler::FetchGlobalProxy(masm, rdi, rcx);
2576 __ movq(args.GetReceiverOperand(), rcx);
2577 __ jmp(&call, Label::kNear);
2578 __ bind(&patch_current_context);
2567 __ movq(rcx, GlobalObjectOperand()); 2579 __ movq(rcx, GlobalObjectOperand());
2568 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset)); 2580 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset));
2569 __ movq(args.GetReceiverOperand(), rcx); 2581 __ movq(args.GetReceiverOperand(), rcx);
2582 __ jmp(&slow);
2570 __ bind(&call); 2583 __ bind(&call);
2584 } else {
2585 // Goto slow case if we do not have a function.
2586 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2587 __ j(not_equal, &slow);
2571 } 2588 }
2572 2589
2573 // Check that the function really is a JavaScript function.
2574 __ JumpIfSmi(rdi, &non_function);
2575 // Goto slow case if we do not have a function.
2576 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2577 __ j(not_equal, &slow);
2578
2579 if (RecordCallTarget()) { 2590 if (RecordCallTarget()) {
2580 GenerateRecordCallTarget(masm); 2591 GenerateRecordCallTarget(masm);
2581 } 2592 }
2582 2593
2583 // Fast-case: Just invoke the function. 2594 // Fast-case: Just invoke the function.
2584 ParameterCount actual(argc_); 2595 ParameterCount actual(argc_);
2585 2596
2586 if (ReceiverMightBeImplicit()) { 2597 if (ReceiverMightBeImplicit()) {
2587 Label call_as_function; 2598 Label call_as_function;
2588 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); 2599 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
(...skipping 3105 matching lines...) Expand 10 before | Expand all | Expand 10 after
5694 __ bind(&fast_elements_case); 5705 __ bind(&fast_elements_case);
5695 GenerateCase(masm, FAST_ELEMENTS); 5706 GenerateCase(masm, FAST_ELEMENTS);
5696 } 5707 }
5697 5708
5698 5709
5699 #undef __ 5710 #undef __
5700 5711
5701 } } // namespace v8::internal 5712 } } // namespace v8::internal
5702 5713
5703 #endif // V8_TARGET_ARCH_X64 5714 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698