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

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

Issue 8932004: Implement target cache for constructor calls. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Vyacheslav Egorov. Created 8 years, 10 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
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, masm->isolate()), 1); 72 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), 1);
73 } 73 }
74 74
75 75
76 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
77 // ----------- S t a t e -------------
78 // -- rax: number of arguments
79 // -- rdi: constructor function
80 // -----------------------------------
81
82 Label slow, non_function_call;
83 // Check that function is not a smi.
84 __ JumpIfSmi(rdi, &non_function_call);
85 // Check that function is a JSFunction.
86 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
87 __ j(not_equal, &slow);
88
89 // Jump to the function-specific construct stub.
90 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
91 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kConstructStubOffset));
92 __ lea(rbx, FieldOperand(rbx, Code::kHeaderSize));
93 __ jmp(rbx);
94
95 // rdi: called object
96 // rax: number of arguments
97 // rcx: object map
98 Label do_call;
99 __ bind(&slow);
100 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE);
101 __ j(not_equal, &non_function_call);
102 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR);
103 __ jmp(&do_call);
104
105 __ bind(&non_function_call);
106 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR);
107 __ bind(&do_call);
108 // Set expected number of arguments to zero (not changing rax).
109 __ Set(rbx, 0);
110 __ SetCallKind(rcx, CALL_AS_METHOD);
111 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
112 RelocInfo::CODE_TARGET);
113 }
114
115
116 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 76 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
117 bool is_api_function, 77 bool is_api_function,
118 bool count_constructions) { 78 bool count_constructions) {
79 // ----------- S t a t e -------------
80 // -- rax: number of arguments
81 // -- rdi: constructor function
82 // -----------------------------------
83
119 // Should never count constructions for api objects. 84 // Should never count constructions for api objects.
120 ASSERT(!is_api_function || !count_constructions); 85 ASSERT(!is_api_function || !count_constructions);
121 86
122 // Enter a construct frame. 87 // Enter a construct frame.
123 { 88 {
124 FrameScope scope(masm, StackFrame::CONSTRUCT); 89 FrameScope scope(masm, StackFrame::CONSTRUCT);
125 90
126 // Store a smi-tagged arguments count on the stack. 91 // Store a smi-tagged arguments count on the stack.
127 __ Integer32ToSmi(rax, rax); 92 __ Integer32ToSmi(rax, rax);
128 __ push(rax); 93 __ push(rax);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0)); 473 __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0));
509 __ push(Operand(kScratchRegister, 0)); // dereference handle 474 __ push(Operand(kScratchRegister, 0)); // dereference handle
510 __ addq(rcx, Immediate(1)); 475 __ addq(rcx, Immediate(1));
511 __ bind(&entry); 476 __ bind(&entry);
512 __ cmpq(rcx, rax); 477 __ cmpq(rcx, rax);
513 __ j(not_equal, &loop); 478 __ j(not_equal, &loop);
514 479
515 // Invoke the code. 480 // Invoke the code.
516 if (is_construct) { 481 if (is_construct) {
517 // Expects rdi to hold function pointer. 482 // Expects rdi to hold function pointer.
518 __ Call(masm->isolate()->builtins()->JSConstructCall(), 483 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS);
519 RelocInfo::CODE_TARGET); 484 __ CallStub(&stub);
520 } else { 485 } else {
521 ParameterCount actual(rax); 486 ParameterCount actual(rax);
522 // Function must be in rdi. 487 // Function must be in rdi.
523 __ InvokeFunction(rdi, actual, CALL_FUNCTION, 488 __ InvokeFunction(rdi, actual, CALL_FUNCTION,
524 NullCallWrapper(), CALL_AS_METHOD); 489 NullCallWrapper(), CALL_AS_METHOD);
525 } 490 }
526 // Exit the internal frame. Notice that this also removes the empty 491 // Exit the internal frame. Notice that this also removes the empty
527 // context and the function left on the stack by the code 492 // context and the function left on the stack by the code
528 // invocation. 493 // invocation.
529 } 494 }
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); 1581 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR);
1617 generator.Generate(); 1582 generator.Generate();
1618 } 1583 }
1619 1584
1620 1585
1621 #undef __ 1586 #undef __
1622 1587
1623 } } // namespace v8::internal 1588 } } // namespace v8::internal
1624 1589
1625 #endif // V8_TARGET_ARCH_X64 1590 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/type-info.cc ('K') | « 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