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

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

Issue 6717018: Introduce accessors on builtins instance (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix tests and lint. 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/type-info.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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
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>(masm->isolate()->builtins()->builtin( 101 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
102 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); 102 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.
(...skipping 219 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>(masm->isolate()->builtins()->builtin( 342 Handle<Code> code =
343 Builtins::HandleApiCallConstruct)); 343 masm->isolate()->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.
353 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 353 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0)); 486 __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0));
487 __ push(Operand(kScratchRegister, 0)); // dereference handle 487 __ push(Operand(kScratchRegister, 0)); // dereference handle
488 __ addq(rcx, Immediate(1)); 488 __ addq(rcx, Immediate(1));
489 __ bind(&entry); 489 __ bind(&entry);
490 __ cmpq(rcx, rax); 490 __ cmpq(rcx, rax);
491 __ j(not_equal, &loop); 491 __ j(not_equal, &loop);
492 492
493 // Invoke the code. 493 // Invoke the code.
494 if (is_construct) { 494 if (is_construct) {
495 // Expects rdi to hold function pointer. 495 // Expects rdi to hold function pointer.
496 __ Call(Handle<Code>(masm->isolate()->builtins()->builtin( 496 __ Call(masm->isolate()->builtins()->JSConstructCall(),
497 Builtins::JSConstructCall)), RelocInfo::CODE_TARGET); 497 RelocInfo::CODE_TARGET);
498 } else { 498 } else {
499 ParameterCount actual(rax); 499 ParameterCount actual(rax);
500 // Function must be in rdi. 500 // Function must be in rdi.
501 __ InvokeFunction(rdi, actual, CALL_FUNCTION); 501 __ InvokeFunction(rdi, actual, CALL_FUNCTION);
502 } 502 }
503 503
504 // Exit the JS frame. Notice that this also removes the empty 504 // Exit the JS frame. Notice that this also removes the empty
505 // context and the function left on the stack by the code 505 // context and the function left on the stack by the code
506 // invocation. 506 // invocation.
507 __ LeaveInternalFrame(); 507 __ LeaveInternalFrame();
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 __ pop(rbx); // Discard copy of return address. 727 __ pop(rbx); // Discard copy of return address.
728 __ decq(rax); // One fewer argument (first argument is new receiver). 728 __ decq(rax); // One fewer argument (first argument is new receiver).
729 } 729 }
730 730
731 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. 731 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin.
732 { Label function; 732 { Label function;
733 __ testq(rdi, rdi); 733 __ testq(rdi, rdi);
734 __ j(not_zero, &function); 734 __ j(not_zero, &function);
735 __ Set(rbx, 0); 735 __ Set(rbx, 0);
736 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); 736 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION);
737 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin( 737 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
738 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); 738 RelocInfo::CODE_TARGET);
739 __ bind(&function); 739 __ bind(&function);
740 } 740 }
741 741
742 // 5b. Get the code to call from the function and check that the number of 742 // 5b. Get the code to call from the function and check that the number of
743 // expected arguments matches what we're providing. If so, jump 743 // expected arguments matches what we're providing. If so, jump
744 // (tail-call) to the code in register edx without checking arguments. 744 // (tail-call) to the code in register edx without checking arguments.
745 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 745 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
746 __ movsxlq(rbx, 746 __ movsxlq(rbx,
747 FieldOperand(rdx, 747 FieldOperand(rdx,
748 SharedFunctionInfo::kFormalParameterCountOffset)); 748 SharedFunctionInfo::kFormalParameterCountOffset));
749 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 749 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
750 __ cmpq(rax, rbx); 750 __ cmpq(rax, rbx);
751 __ j(not_equal, 751 __ j(not_equal,
752 Handle<Code>(masm->isolate()->builtins()->builtin( 752 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
753 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); 753 RelocInfo::CODE_TARGET);
754 754
755 ParameterCount expected(0); 755 ParameterCount expected(0);
756 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION); 756 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION);
757 } 757 }
758 758
759 759
760 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { 760 void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
761 // Stack at entry: 761 // Stack at entry:
762 // rsp: return address 762 // rsp: return address
763 // rsp+8: arguments 763 // rsp+8: arguments
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 __ push(rbx); 857 __ push(rbx);
858 858
859 // Copy all arguments from the array to the stack. 859 // Copy all arguments from the array to the stack.
860 Label entry, loop; 860 Label entry, loop;
861 __ movq(rax, Operand(rbp, kIndexOffset)); 861 __ movq(rax, Operand(rbp, kIndexOffset));
862 __ jmp(&entry); 862 __ jmp(&entry);
863 __ bind(&loop); 863 __ bind(&loop);
864 __ movq(rdx, Operand(rbp, kArgumentsOffset)); // load arguments 864 __ movq(rdx, Operand(rbp, kArgumentsOffset)); // load arguments
865 865
866 // Use inline caching to speed up access to arguments. 866 // Use inline caching to speed up access to arguments.
867 Handle<Code> ic(masm->isolate()->builtins()->builtin( 867 Handle<Code> ic =
868 Builtins::KeyedLoadIC_Initialize)); 868 masm->isolate()->builtins()->KeyedLoadIC_Initialize();
869 __ Call(ic, RelocInfo::CODE_TARGET); 869 __ Call(ic, RelocInfo::CODE_TARGET);
870 // It is important that we do not have a test instruction after the 870 // It is important that we do not have a test instruction after the
871 // call. A test instruction after the call is used to indicate that 871 // call. A test instruction after the call is used to indicate that
872 // we have generated an inline version of the keyed load. In this 872 // we have generated an inline version of the keyed load. In this
873 // case, we know that we are not generating a test instruction next. 873 // case, we know that we are not generating a test instruction next.
874 874
875 // Push the nth argument. 875 // Push the nth argument.
876 __ push(rax); 876 __ push(rax);
877 877
878 // Update the index on the stack and in register rax. 878 // Update the index on the stack and in register rax.
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 __ CmpObjectType(rbx, MAP_TYPE, rcx); 1260 __ CmpObjectType(rbx, MAP_TYPE, rcx);
1261 __ Check(equal, "Unexpected initial map for Array function"); 1261 __ Check(equal, "Unexpected initial map for Array function");
1262 } 1262 }
1263 1263
1264 // Run the native code for the Array function called as a normal function. 1264 // Run the native code for the Array function called as a normal function.
1265 ArrayNativeCode(masm, &generic_array_code); 1265 ArrayNativeCode(masm, &generic_array_code);
1266 1266
1267 // Jump to the generic array code in case the specialized code cannot handle 1267 // Jump to the generic array code in case the specialized code cannot handle
1268 // the construction. 1268 // the construction.
1269 __ bind(&generic_array_code); 1269 __ bind(&generic_array_code);
1270 Code* code = 1270 Handle<Code> array_code =
1271 masm->isolate()->builtins()->builtin(Builtins::ArrayCodeGeneric); 1271 masm->isolate()->builtins()->ArrayCodeGeneric();
1272 Handle<Code> array_code(code);
1273 __ Jump(array_code, RelocInfo::CODE_TARGET); 1272 __ Jump(array_code, RelocInfo::CODE_TARGET);
1274 } 1273 }
1275 1274
1276 1275
1277 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { 1276 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) {
1278 // ----------- S t a t e ------------- 1277 // ----------- S t a t e -------------
1279 // -- rax : argc 1278 // -- rax : argc
1280 // -- rdi : constructor 1279 // -- rdi : constructor
1281 // -- rsp[0] : return address 1280 // -- rsp[0] : return address
1282 // -- rsp[8] : last argument 1281 // -- rsp[8] : last argument
(...skipping 12 matching lines...) Expand all
1295 __ CmpObjectType(rbx, MAP_TYPE, rcx); 1294 __ CmpObjectType(rbx, MAP_TYPE, rcx);
1296 __ Check(equal, "Unexpected initial map for Array function"); 1295 __ Check(equal, "Unexpected initial map for Array function");
1297 } 1296 }
1298 1297
1299 // Run the native code for the Array function called as constructor. 1298 // Run the native code for the Array function called as constructor.
1300 ArrayNativeCode(masm, &generic_constructor); 1299 ArrayNativeCode(masm, &generic_constructor);
1301 1300
1302 // Jump to the generic construct code in case the specialized code cannot 1301 // Jump to the generic construct code in case the specialized code cannot
1303 // handle the construction. 1302 // handle the construction.
1304 __ bind(&generic_constructor); 1303 __ bind(&generic_constructor);
1305 Code* code = 1304 Handle<Code> generic_construct_stub =
1306 masm->isolate()->builtins()->builtin(Builtins::JSConstructStubGeneric); 1305 masm->isolate()->builtins()->JSConstructStubGeneric();
1307 Handle<Code> generic_construct_stub(code);
1308 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); 1306 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
1309 } 1307 }
1310 1308
1311 1309
1312 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { 1310 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
1313 // TODO(849): implement custom construct stub. 1311 // TODO(849): implement custom construct stub.
1314 // Generate a copy of the generic stub for now. 1312 // Generate a copy of the generic stub for now.
1315 Generate_JSConstructStubGeneric(masm); 1313 Generate_JSConstructStubGeneric(masm);
1316 } 1314 }
1317 1315
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); 1484 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR);
1487 generator.Generate(); 1485 generator.Generate();
1488 } 1486 }
1489 1487
1490 1488
1491 #undef __ 1489 #undef __
1492 1490
1493 } } // namespace v8::internal 1491 } } // namespace v8::internal
1494 1492
1495 #endif // V8_TARGET_ARCH_X64 1493 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/type-info.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698