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

Side by Side Diff: src/x64/builtins-x64.cc

Issue 6713074: Require an isolate parameter for most external reference creation to (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Further cleanup Created 9 years, 9 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/assembler-x64.cc ('k') | src/x64/code-stubs-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 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 __ pop(kScratchRegister); // Save return address. 62 __ pop(kScratchRegister); // Save return address.
63 __ push(rdi); 63 __ push(rdi);
64 __ push(kScratchRegister); // Restore return address. 64 __ push(kScratchRegister); // Restore return address.
65 } else { 65 } else {
66 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); 66 ASSERT(extra_args == NO_EXTRA_ARGUMENTS);
67 } 67 }
68 68
69 // JumpToExternalReference expects rax to contain the number of arguments 69 // JumpToExternalReference expects rax to contain the number of arguments
70 // including the receiver and the extra arguments. 70 // including the receiver and the extra arguments.
71 __ addq(rax, Immediate(num_extra_args + 1)); 71 __ addq(rax, Immediate(num_extra_args + 1));
72 __ JumpToExternalReference(ExternalReference(id), 1); 72 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), 1);
73 } 73 }
74 74
75 75
76 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { 76 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
77 // ----------- S t a t e ------------- 77 // ----------- S t a t e -------------
78 // -- rax: number of arguments 78 // -- rax: number of arguments
79 // -- rdi: constructor function 79 // -- rdi: constructor function
80 // ----------------------------------- 80 // -----------------------------------
81 81
82 Label non_function_call; 82 Label non_function_call;
83 // Check that function is not a smi. 83 // Check that function is not a smi.
84 __ JumpIfSmi(rdi, &non_function_call); 84 __ JumpIfSmi(rdi, &non_function_call);
85 // Check that function is a JSFunction. 85 // Check that function is a JSFunction.
86 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); 86 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
87 __ j(not_equal, &non_function_call); 87 __ j(not_equal, &non_function_call);
88 88
89 // Jump to the function-specific construct stub. 89 // Jump to the function-specific construct stub.
90 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 90 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
91 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kConstructStubOffset)); 91 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kConstructStubOffset));
92 __ lea(rbx, FieldOperand(rbx, Code::kHeaderSize)); 92 __ lea(rbx, FieldOperand(rbx, Code::kHeaderSize));
93 __ jmp(rbx); 93 __ jmp(rbx);
94 94
95 // rdi: called object 95 // rdi: called object
96 // rax: number of arguments 96 // rax: number of arguments
97 __ bind(&non_function_call); 97 __ bind(&non_function_call);
98 // Set expected number of arguments to zero (not changing rax). 98 // Set expected number of arguments to zero (not changing rax).
99 __ movq(rbx, Immediate(0)); 99 __ movq(rbx, Immediate(0));
100 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); 100 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR);
101 __ Jump(Handle<Code>(Isolate::Current()->builtins()->builtin( 101 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin(
102 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); 102 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET);
103 } 103 }
104 104
105 105
106 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 106 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
107 bool is_api_function, 107 bool is_api_function,
108 bool count_constructions) { 108 bool count_constructions) {
109 // Should never count constructions for api objects. 109 // Should never count constructions for api objects.
110 ASSERT(!is_api_function || !count_constructions); 110 ASSERT(!is_api_function || !count_constructions);
111 111
112 // Enter a construct frame. 112 // Enter a construct frame.
113 __ EnterConstructFrame(); 113 __ EnterConstructFrame();
114 114
115 // Store a smi-tagged arguments count on the stack. 115 // Store a smi-tagged arguments count on the stack.
116 __ Integer32ToSmi(rax, rax); 116 __ Integer32ToSmi(rax, rax);
117 __ push(rax); 117 __ push(rax);
118 118
119 // Push the function to invoke on the stack. 119 // Push the function to invoke on the stack.
120 __ push(rdi); 120 __ push(rdi);
121 121
122 // Try to allocate the object without transitioning into C code. If any of the 122 // Try to allocate the object without transitioning into C code. If any of the
123 // preconditions is not met, the code bails out to the runtime call. 123 // preconditions is not met, the code bails out to the runtime call.
124 Label rt_call, allocated; 124 Label rt_call, allocated;
125 if (FLAG_inline_new) { 125 if (FLAG_inline_new) {
126 Label undo_allocation; 126 Label undo_allocation;
127 127
128 #ifdef ENABLE_DEBUGGER_SUPPORT 128 #ifdef ENABLE_DEBUGGER_SUPPORT
129 ExternalReference debug_step_in_fp = 129 ExternalReference debug_step_in_fp =
130 ExternalReference::debug_step_in_fp_address(); 130 ExternalReference::debug_step_in_fp_address(masm->isolate());
131 __ movq(kScratchRegister, debug_step_in_fp); 131 __ movq(kScratchRegister, debug_step_in_fp);
132 __ cmpq(Operand(kScratchRegister, 0), Immediate(0)); 132 __ cmpq(Operand(kScratchRegister, 0), Immediate(0));
133 __ j(not_equal, &rt_call); 133 __ j(not_equal, &rt_call);
134 #endif 134 #endif
135 135
136 // Verified that the constructor is a JSFunction. 136 // Verified that the constructor is a JSFunction.
137 // Load the initial map and verify that it is in fact a map. 137 // Load the initial map and verify that it is in fact a map.
138 // rdi: constructor 138 // rdi: constructor
139 __ movq(rax, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); 139 __ movq(rax, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
140 // Will both indicate a NULL and a Smi 140 // Will both indicate a NULL and a Smi
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 __ jmp(&entry); 332 __ jmp(&entry);
333 __ bind(&loop); 333 __ bind(&loop);
334 __ push(Operand(rbx, rcx, times_pointer_size, 0)); 334 __ push(Operand(rbx, rcx, times_pointer_size, 0));
335 __ bind(&entry); 335 __ bind(&entry);
336 __ decq(rcx); 336 __ decq(rcx);
337 __ j(greater_equal, &loop); 337 __ j(greater_equal, &loop);
338 338
339 // Call the function. 339 // Call the function.
340 if (is_api_function) { 340 if (is_api_function) {
341 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 341 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
342 Handle<Code> code = Handle<Code>(Isolate::Current()->builtins()->builtin( 342 Handle<Code> code = Handle<Code>(masm->isolate()->builtins()->builtin(
343 Builtins::HandleApiCallConstruct)); 343 Builtins::HandleApiCallConstruct));
344 ParameterCount expected(0); 344 ParameterCount expected(0);
345 __ InvokeCode(code, expected, expected, 345 __ InvokeCode(code, expected, expected,
346 RelocInfo::CODE_TARGET, CALL_FUNCTION); 346 RelocInfo::CODE_TARGET, CALL_FUNCTION);
347 } else { 347 } else {
348 ParameterCount actual(rax); 348 ParameterCount actual(rax);
349 __ InvokeFunction(rdi, actual, CALL_FUNCTION); 349 __ InvokeFunction(rdi, actual, CALL_FUNCTION);
350 } 350 }
351 351
352 // Restore context from the frame. 352 // Restore context from the frame.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0)); 485 __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0));
486 __ push(Operand(kScratchRegister, 0)); // dereference handle 486 __ push(Operand(kScratchRegister, 0)); // dereference handle
487 __ addq(rcx, Immediate(1)); 487 __ addq(rcx, Immediate(1));
488 __ bind(&entry); 488 __ bind(&entry);
489 __ cmpq(rcx, rax); 489 __ cmpq(rcx, rax);
490 __ j(not_equal, &loop); 490 __ j(not_equal, &loop);
491 491
492 // Invoke the code. 492 // Invoke the code.
493 if (is_construct) { 493 if (is_construct) {
494 // Expects rdi to hold function pointer. 494 // Expects rdi to hold function pointer.
495 __ Call(Handle<Code>(Isolate::Current()->builtins()->builtin( 495 __ Call(Handle<Code>(masm->isolate()->builtins()->builtin(
496 Builtins::JSConstructCall)), RelocInfo::CODE_TARGET); 496 Builtins::JSConstructCall)), RelocInfo::CODE_TARGET);
497 } else { 497 } else {
498 ParameterCount actual(rax); 498 ParameterCount actual(rax);
499 // Function must be in rdi. 499 // Function must be in rdi.
500 __ InvokeFunction(rdi, actual, CALL_FUNCTION); 500 __ InvokeFunction(rdi, actual, CALL_FUNCTION);
501 } 501 }
502 502
503 // Exit the JS frame. Notice that this also removes the empty 503 // Exit the JS frame. Notice that this also removes the empty
504 // context and the function left on the stack by the code 504 // context and the function left on the stack by the code
505 // invocation. 505 // invocation.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 __ pop(rbx); // Discard copy of return address. 726 __ pop(rbx); // Discard copy of return address.
727 __ decq(rax); // One fewer argument (first argument is new receiver). 727 __ decq(rax); // One fewer argument (first argument is new receiver).
728 } 728 }
729 729
730 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. 730 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin.
731 { Label function; 731 { Label function;
732 __ testq(rdi, rdi); 732 __ testq(rdi, rdi);
733 __ j(not_zero, &function); 733 __ j(not_zero, &function);
734 __ Set(rbx, 0); 734 __ Set(rbx, 0);
735 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); 735 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION);
736 __ Jump(Handle<Code>(Isolate::Current()->builtins()->builtin( 736 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin(
737 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); 737 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET);
738 __ bind(&function); 738 __ bind(&function);
739 } 739 }
740 740
741 // 5b. Get the code to call from the function and check that the number of 741 // 5b. Get the code to call from the function and check that the number of
742 // expected arguments matches what we're providing. If so, jump 742 // expected arguments matches what we're providing. If so, jump
743 // (tail-call) to the code in register edx without checking arguments. 743 // (tail-call) to the code in register edx without checking arguments.
744 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 744 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
745 __ movsxlq(rbx, 745 __ movsxlq(rbx,
746 FieldOperand(rdx, 746 FieldOperand(rdx,
747 SharedFunctionInfo::kFormalParameterCountOffset)); 747 SharedFunctionInfo::kFormalParameterCountOffset));
748 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 748 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
749 __ cmpq(rax, rbx); 749 __ cmpq(rax, rbx);
750 __ j(not_equal, 750 __ j(not_equal,
751 Handle<Code>(Isolate::Current()->builtins()->builtin( 751 Handle<Code>(masm->isolate()->builtins()->builtin(
752 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); 752 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET);
753 753
754 ParameterCount expected(0); 754 ParameterCount expected(0);
755 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION); 755 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION);
756 } 756 }
757 757
758 758
759 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { 759 void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
760 // Stack at entry: 760 // Stack at entry:
761 // rsp: return address 761 // rsp: return address
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 __ push(rbx); 856 __ push(rbx);
857 857
858 // Copy all arguments from the array to the stack. 858 // Copy all arguments from the array to the stack.
859 Label entry, loop; 859 Label entry, loop;
860 __ movq(rax, Operand(rbp, kIndexOffset)); 860 __ movq(rax, Operand(rbp, kIndexOffset));
861 __ jmp(&entry); 861 __ jmp(&entry);
862 __ bind(&loop); 862 __ bind(&loop);
863 __ movq(rdx, Operand(rbp, kArgumentsOffset)); // load arguments 863 __ movq(rdx, Operand(rbp, kArgumentsOffset)); // load arguments
864 864
865 // Use inline caching to speed up access to arguments. 865 // Use inline caching to speed up access to arguments.
866 Handle<Code> ic(Isolate::Current()->builtins()->builtin( 866 Handle<Code> ic(masm->isolate()->builtins()->builtin(
867 Builtins::KeyedLoadIC_Initialize)); 867 Builtins::KeyedLoadIC_Initialize));
868 __ Call(ic, RelocInfo::CODE_TARGET); 868 __ Call(ic, RelocInfo::CODE_TARGET);
869 // It is important that we do not have a test instruction after the 869 // It is important that we do not have a test instruction after the
870 // call. A test instruction after the call is used to indicate that 870 // call. A test instruction after the call is used to indicate that
871 // we have generated an inline version of the keyed load. In this 871 // we have generated an inline version of the keyed load. In this
872 // case, we know that we are not generating a test instruction next. 872 // case, we know that we are not generating a test instruction next.
873 873
874 // Push the nth argument. 874 // Push the nth argument.
875 __ push(rax); 875 __ push(rax);
876 876
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 __ CmpObjectType(rbx, MAP_TYPE, rcx); 1258 __ CmpObjectType(rbx, MAP_TYPE, rcx);
1259 __ Check(equal, "Unexpected initial map for Array function"); 1259 __ Check(equal, "Unexpected initial map for Array function");
1260 } 1260 }
1261 1261
1262 // Run the native code for the Array function called as a normal function. 1262 // Run the native code for the Array function called as a normal function.
1263 ArrayNativeCode(masm, &generic_array_code); 1263 ArrayNativeCode(masm, &generic_array_code);
1264 1264
1265 // Jump to the generic array code in case the specialized code cannot handle 1265 // Jump to the generic array code in case the specialized code cannot handle
1266 // the construction. 1266 // the construction.
1267 __ bind(&generic_array_code); 1267 __ bind(&generic_array_code);
1268 Code* code = Isolate::Current()->builtins()->builtin( 1268 Code* code =
1269 Builtins::ArrayCodeGeneric); 1269 masm->isolate()->builtins()->builtin(Builtins::ArrayCodeGeneric);
1270 Handle<Code> array_code(code); 1270 Handle<Code> array_code(code);
1271 __ Jump(array_code, RelocInfo::CODE_TARGET); 1271 __ Jump(array_code, RelocInfo::CODE_TARGET);
1272 } 1272 }
1273 1273
1274 1274
1275 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { 1275 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) {
1276 // ----------- S t a t e ------------- 1276 // ----------- S t a t e -------------
1277 // -- rax : argc 1277 // -- rax : argc
1278 // -- rdi : constructor 1278 // -- rdi : constructor
1279 // -- rsp[0] : return address 1279 // -- rsp[0] : return address
(...skipping 13 matching lines...) Expand all
1293 __ CmpObjectType(rbx, MAP_TYPE, rcx); 1293 __ CmpObjectType(rbx, MAP_TYPE, rcx);
1294 __ Check(equal, "Unexpected initial map for Array function"); 1294 __ Check(equal, "Unexpected initial map for Array function");
1295 } 1295 }
1296 1296
1297 // Run the native code for the Array function called as constructor. 1297 // Run the native code for the Array function called as constructor.
1298 ArrayNativeCode(masm, &generic_constructor); 1298 ArrayNativeCode(masm, &generic_constructor);
1299 1299
1300 // Jump to the generic construct code in case the specialized code cannot 1300 // Jump to the generic construct code in case the specialized code cannot
1301 // handle the construction. 1301 // handle the construction.
1302 __ bind(&generic_constructor); 1302 __ bind(&generic_constructor);
1303 Code* code = Isolate::Current()->builtins()->builtin( 1303 Code* code =
1304 Builtins::JSConstructStubGeneric); 1304 masm->isolate()->builtins()->builtin(Builtins::JSConstructStubGeneric);
1305 Handle<Code> generic_construct_stub(code); 1305 Handle<Code> generic_construct_stub(code);
1306 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); 1306 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
1307 } 1307 }
1308 1308
1309 1309
1310 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { 1310 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
1311 // TODO(849): implement custom construct stub. 1311 // TODO(849): implement custom construct stub.
1312 // Generate a copy of the generic stub for now. 1312 // Generate a copy of the generic stub for now.
1313 Generate_JSConstructStubGeneric(masm); 1313 Generate_JSConstructStubGeneric(masm);
1314 } 1314 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); 1483 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR);
1484 generator.Generate(); 1484 generator.Generate();
1485 } 1485 }
1486 1486
1487 1487
1488 #undef __ 1488 #undef __
1489 1489
1490 } } // namespace v8::internal 1490 } } // namespace v8::internal
1491 1491
1492 #endif // V8_TARGET_ARCH_X64 1492 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698