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

Unified Diff: src/virtual-frame-ia32.cc

Issue 42638: In the IA32 code genrator, handle call ICs and constructor calls the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/virtual-frame-ia32.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/virtual-frame-ia32.cc
===================================================================
--- src/virtual-frame-ia32.cc (revision 1615)
+++ src/virtual-frame-ia32.cc (working copy)
@@ -725,7 +725,7 @@
}
-Result VirtualFrame::RawCallStub(CodeStub* stub, int frame_arg_count) {
+Result VirtualFrame::RawCallStub(CodeStub* stub) {
ASSERT(cgen_->HasValidEntryRegisters());
__ CallStub(stub);
Result result = cgen_->allocator()->Allocate(eax);
@@ -734,22 +734,20 @@
}
-Result VirtualFrame::CallRuntime(Runtime::Function* f,
- int frame_arg_count) {
- PrepareForCall(frame_arg_count, frame_arg_count);
+Result VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) {
+ PrepareForCall(arg_count, arg_count);
ASSERT(cgen_->HasValidEntryRegisters());
- __ CallRuntime(f, frame_arg_count);
+ __ CallRuntime(f, arg_count);
Result result = cgen_->allocator()->Allocate(eax);
ASSERT(result.is_valid());
return result;
}
-Result VirtualFrame::CallRuntime(Runtime::FunctionId id,
- int frame_arg_count) {
- PrepareForCall(frame_arg_count, frame_arg_count);
+Result VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) {
+ PrepareForCall(arg_count, arg_count);
ASSERT(cgen_->HasValidEntryRegisters());
- __ CallRuntime(id, frame_arg_count);
+ __ CallRuntime(id, arg_count);
Result result = cgen_->allocator()->Allocate(eax);
ASSERT(result.is_valid());
return result;
@@ -758,8 +756,8 @@
Result VirtualFrame::InvokeBuiltin(Builtins::JavaScript id,
InvokeFlag flag,
- int frame_arg_count) {
- PrepareForCall(frame_arg_count, frame_arg_count);
+ int arg_count) {
+ PrepareForCall(arg_count, arg_count);
ASSERT(cgen_->HasValidEntryRegisters());
__ InvokeBuiltin(id, flag);
Result result = cgen_->allocator()->Allocate(eax);
@@ -845,32 +843,46 @@
}
-Result VirtualFrame::CallCodeObject(Handle<Code> code,
- RelocInfo::Mode rmode,
- Result* arg0,
- Result* arg1,
- int dropped_args) {
- int spilled_args = 1;
- switch (code->kind()) {
- case Code::BUILTIN:
- ASSERT(*code == Builtins::builtin(Builtins::JSConstructCall));
- ASSERT(arg0->reg().is(eax));
- ASSERT(arg1->reg().is(edi));
- spilled_args = dropped_args + 1;
- break;
- default:
- // No other types of code objects are called with values
- // in exactly two registers.
- UNREACHABLE();
- break;
- }
- PrepareForCall(spilled_args, dropped_args);
- arg0->Unuse();
- arg1->Unuse();
- return RawCallCodeObject(code, rmode);
+Result VirtualFrame::CallCallIC(RelocInfo::Mode mode,
+ int arg_count,
+ int loop_nesting) {
+ // Arguments, receiver, and function name are on top of the frame.
+ // The IC expects them on the stack. It does not drop the function
+ // name slot (but it does drop the rest).
+ Handle<Code> ic = (loop_nesting > 0)
+ ? cgen_->ComputeCallInitializeInLoop(arg_count)
+ : cgen_->ComputeCallInitialize(arg_count);
+ // Spill args, receiver, and function. The call will drop args and
+ // receiver.
+ PrepareForCall(arg_count + 2, arg_count + 1);
+ return RawCallCodeObject(ic, mode);
}
+Result VirtualFrame::CallConstructor(int arg_count) {
+ // Arguments, receiver, and function are on top of the frame. The
+ // IC expects arg count in eax, function in edi, and the arguments
+ // and receiver on the stack.
+ Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall));
+ // Duplicate the function before preparing the frame.
+ PushElementAt(arg_count + 1);
+ Result function = Pop();
+ PrepareForCall(arg_count + 1, arg_count + 1); // Spill args and receiver.
+ function.ToRegister(edi);
+
+ // Constructors are called with the number of arguments in register
+ // eax for now. Another option would be to have separate construct
+ // call trampolines per different arguments counts encountered.
+ Result num_args = cgen_->allocator()->Allocate(eax);
+ ASSERT(num_args.is_valid());
+ __ Set(num_args.reg(), Immediate(arg_count));
+
+ function.Unuse();
+ num_args.Unuse();
+ return RawCallCodeObject(ic, RelocInfo::CONSTRUCT_CALL);
+}
+
+
void VirtualFrame::Drop(int count) {
ASSERT(height() >= count);
int num_virtual_elements = (elements_.length() - 1) - stack_pointer_;
« no previous file with comments | « src/virtual-frame-ia32.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698