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

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

Issue 104013008: Reland v8:18458 "Load the global proxy from the context of the target function." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 months 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
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 } 2343 }
2344 2344
2345 2345
2346 void CallFunctionStub::Generate(MacroAssembler* masm) { 2346 void CallFunctionStub::Generate(MacroAssembler* masm) {
2347 // rbx : cache cell for call target 2347 // rbx : cache cell for call target
2348 // rdi : the function to call 2348 // rdi : the function to call
2349 Isolate* isolate = masm->isolate(); 2349 Isolate* isolate = masm->isolate();
2350 Label slow, non_function; 2350 Label slow, non_function;
2351 StackArgumentsAccessor args(rsp, argc_); 2351 StackArgumentsAccessor args(rsp, argc_);
2352 2352
2353 // Check that the function really is a JavaScript function.
2354 __ JumpIfSmi(rdi, &non_function);
2355
2353 // The receiver might implicitly be the global object. This is 2356 // The receiver might implicitly be the global object. This is
2354 // indicated by passing the hole as the receiver to the call 2357 // indicated by passing the hole as the receiver to the call
2355 // function stub. 2358 // function stub.
2356 if (ReceiverMightBeImplicit()) { 2359 if (ReceiverMightBeImplicit() || ReceiverIsImplicit()) {
2357 Label call; 2360 Label try_call, call, patch_current_context;
2358 // Get the receiver from the stack. 2361 if (ReceiverMightBeImplicit()) {
2359 __ movq(rax, args.GetReceiverOperand()); 2362 // Get the receiver from the stack.
2360 // Call as function is indicated with the hole. 2363 __ movq(rax, args.GetReceiverOperand());
2361 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); 2364 // Call as function is indicated with the hole.
2362 __ j(not_equal, &call, Label::kNear); 2365 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
2366 __ j(not_equal, &try_call, Label::kNear);
2367 }
2363 // Patch the receiver on the stack with the global receiver object. 2368 // Patch the receiver on the stack with the global receiver object.
2364 __ movq(rcx, GlobalObjectOperand()); 2369 // Goto slow case if we do not have a function.
2365 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset)); 2370 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2371 __ j(not_equal, &patch_current_context);
2372 CallStubCompiler::FetchGlobalProxy(masm, rcx, rdi);
2366 __ movq(args.GetReceiverOperand(), rcx); 2373 __ movq(args.GetReceiverOperand(), rcx);
2374 __ jmp(&call, Label::kNear);
2375
2376 __ bind(&patch_current_context);
2377 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
2378 __ movq(args.GetReceiverOperand(), kScratchRegister);
2379 __ jmp(&slow);
2380
2381 __ bind(&try_call);
2382 // Goto slow case if we do not have a function.
2383 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2384 __ j(not_equal, &slow);
2385
2367 __ bind(&call); 2386 __ bind(&call);
2387 } else {
2388 // Goto slow case if we do not have a function.
2389 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2390 __ j(not_equal, &slow);
2368 } 2391 }
2369 2392
2370 // Check that the function really is a JavaScript function.
2371 __ JumpIfSmi(rdi, &non_function);
2372 // Goto slow case if we do not have a function.
2373 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2374 __ j(not_equal, &slow);
2375
2376 if (RecordCallTarget()) { 2393 if (RecordCallTarget()) {
2377 GenerateRecordCallTarget(masm); 2394 GenerateRecordCallTarget(masm);
2378 } 2395 }
2379 2396
2380 // Fast-case: Just invoke the function. 2397 // Fast-case: Just invoke the function.
2381 ParameterCount actual(argc_); 2398 ParameterCount actual(argc_);
2382 2399
2383 if (ReceiverMightBeImplicit()) { 2400 if (ReceiverMightBeImplicit()) {
2384 Label call_as_function; 2401 Label call_as_function;
2385 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); 2402 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
(...skipping 21 matching lines...) Expand all
2407 TypeFeedbackCells::MegamorphicSentinel(isolate)); 2424 TypeFeedbackCells::MegamorphicSentinel(isolate));
2408 } 2425 }
2409 // Check for function proxy. 2426 // Check for function proxy.
2410 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); 2427 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE);
2411 __ j(not_equal, &non_function); 2428 __ j(not_equal, &non_function);
2412 __ PopReturnAddressTo(rcx); 2429 __ PopReturnAddressTo(rcx);
2413 __ push(rdi); // put proxy as additional argument under return address 2430 __ push(rdi); // put proxy as additional argument under return address
2414 __ PushReturnAddressFrom(rcx); 2431 __ PushReturnAddressFrom(rcx);
2415 __ Set(rax, argc_ + 1); 2432 __ Set(rax, argc_ + 1);
2416 __ Set(rbx, 0); 2433 __ Set(rbx, 0);
2417 __ SetCallKind(rcx, CALL_AS_METHOD); 2434 __ SetCallKind(rcx, CALL_AS_FUNCTION);
2418 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY); 2435 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY);
2419 { 2436 {
2420 Handle<Code> adaptor = 2437 Handle<Code> adaptor =
2421 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); 2438 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline();
2422 __ jmp(adaptor, RelocInfo::CODE_TARGET); 2439 __ jmp(adaptor, RelocInfo::CODE_TARGET);
2423 } 2440 }
2424 2441
2425 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead 2442 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead
2426 // of the original receiver from the call site). 2443 // of the original receiver from the call site).
2427 __ bind(&non_function); 2444 __ bind(&non_function);
(...skipping 3093 matching lines...) Expand 10 before | Expand all | Expand 10 after
5521 __ bind(&fast_elements_case); 5538 __ bind(&fast_elements_case);
5522 GenerateCase(masm, FAST_ELEMENTS); 5539 GenerateCase(masm, FAST_ELEMENTS);
5523 } 5540 }
5524 5541
5525 5542
5526 #undef __ 5543 #undef __
5527 5544
5528 } } // namespace v8::internal 5545 } } // namespace v8::internal
5529 5546
5530 #endif // V8_TARGET_ARCH_X64 5547 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698