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

Side by Side Diff: src/codegen-ia32.cc

Issue 16512: Experimental: begin using the register allocator across entering and... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 11 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 | « no previous file | src/virtual-frame-ia32.h » ('j') | src/virtual-frame-ia32.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 if (kDebug) { 188 if (kDebug) {
189 JumpTarget verified_true(this); 189 JumpTarget verified_true(this);
190 // Verify eax and esi are the same in debug mode 190 // Verify eax and esi are the same in debug mode
191 __ cmp(eax, Operand(esi)); 191 __ cmp(eax, Operand(esi));
192 verified_true.Branch(equal); 192 verified_true.Branch(equal);
193 __ int3(); 193 __ int3();
194 verified_true.Bind(); 194 verified_true.Bind();
195 } 195 }
196 // Update context local. 196 // Update context local.
197 __ mov(frame_->Context(), esi); 197 frame_->SaveContextRegister();
198 } 198 }
199 199
200 // TODO(1241774): Improve this code: 200 // TODO(1241774): Improve this code:
201 // 1) only needed if we have a context 201 // 1) only needed if we have a context
202 // 2) no need to recompute context ptr every single time 202 // 2) no need to recompute context ptr every single time
203 // 3) don't copy parameter operand code from SlotOperand! 203 // 3) don't copy parameter operand code from SlotOperand!
204 { 204 {
205 Comment cmnt2(masm_, "[ copy context parameters into .context"); 205 Comment cmnt2(masm_, "[ copy context parameters into .context");
206 206
207 // Note that iteration order is relevant here! If we have the same 207 // Note that iteration order is relevant here! If we have the same
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 } 1344 }
1345 1345
1346 // Record the position for debugging purposes. 1346 // Record the position for debugging purposes.
1347 CodeForSourcePosition(position); 1347 CodeForSourcePosition(position);
1348 1348
1349 // Use the shared code stub to call the function. 1349 // Use the shared code stub to call the function.
1350 CallFunctionStub call_function(arg_count); 1350 CallFunctionStub call_function(arg_count);
1351 frame_->CallStub(&call_function, arg_count + 1); 1351 frame_->CallStub(&call_function, arg_count + 1);
1352 1352
1353 // Restore context and pop function from the stack. 1353 // Restore context and pop function from the stack.
1354 __ mov(esi, frame_->Context()); 1354 frame_->RestoreContextRegister();
1355 __ mov(frame_->Top(), eax); 1355 __ mov(frame_->Top(), eax);
1356 } 1356 }
1357 1357
1358 1358
1359 void CodeGenerator::Branch(bool if_true, JumpTarget* target) { 1359 void CodeGenerator::Branch(bool if_true, JumpTarget* target) {
1360 ASSERT(has_cc()); 1360 ASSERT(has_cc());
1361 Condition cc = if_true ? cc_reg_ : NegateCondition(cc_reg_); 1361 Condition cc = if_true ? cc_reg_ : NegateCondition(cc_reg_);
1362 target->Branch(cc); 1362 target->Branch(cc);
1363 cc_reg_ = no_condition; 1363 cc_reg_ = no_condition;
1364 } 1364 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 // Check that the size of the code used for returning matches what is 1653 // Check that the size of the code used for returning matches what is
1654 // expected by the debugger. 1654 // expected by the debugger.
1655 ASSERT_EQ(Debug::kIa32JSReturnSequenceLength, 1655 ASSERT_EQ(Debug::kIa32JSReturnSequenceLength,
1656 __ SizeOfCodeGeneratedSince(&check_exit_codesize)); 1656 __ SizeOfCodeGeneratedSince(&check_exit_codesize));
1657 } 1657 }
1658 } 1658 }
1659 1659
1660 1660
1661 void CodeGenerator::VisitWithEnterStatement(WithEnterStatement* node) { 1661 void CodeGenerator::VisitWithEnterStatement(WithEnterStatement* node) {
1662 ASSERT(!in_spilled_code()); 1662 ASSERT(!in_spilled_code());
1663 VirtualFrame::SpilledScope spilled_scope(this);
1664 Comment cmnt(masm_, "[ WithEnterStatement"); 1663 Comment cmnt(masm_, "[ WithEnterStatement");
1665 CodeForStatement(node); 1664 CodeForStatement(node);
1666 LoadAndSpill(node->expression()); 1665 Load(node->expression());
1666 Result context(this);
1667 if (node->is_catch_block()) { 1667 if (node->is_catch_block()) {
1668 frame_->CallRuntime(Runtime::kPushCatchContext, 1); 1668 context = frame_->CallRuntime(Runtime::kPushCatchContext, 1);
1669 } else { 1669 } else {
1670 frame_->CallRuntime(Runtime::kPushContext, 1); 1670 context = frame_->CallRuntime(Runtime::kPushContext, 1);
1671 } 1671 }
1672 1672
1673 if (kDebug) { 1673 if (kDebug) {
1674 JumpTarget verified_true(this); 1674 JumpTarget verified_true(this);
1675 // Verify eax and esi are the same in debug mode 1675 // Verify that the result of the runtime call and the esi register are
1676 __ cmp(eax, Operand(esi)); 1676 // the same in debug mode.
1677 verified_true.Branch(equal); 1677 __ cmp(context.reg(), Operand(esi));
William Hesse 2009/01/06 12:04:08 Can't context.Unuse() go directly after the cmp in
Kevin Millikin (Chromium) 2009/01/06 12:10:28 Yes. Fixed.
1678 verified_true.Branch(equal, &context);
1679 frame_->SpillAll();
1678 __ int3(); 1680 __ int3();
1679 verified_true.Bind(); 1681 verified_true.Bind(&context);
1680 } 1682 }
1683 context.Unuse();
1681 1684
1682 // Update context local. 1685 // Update context local.
1683 __ mov(frame_->Context(), esi); 1686 frame_->SaveContextRegister();
1684 } 1687 }
1685 1688
1686 1689
1687 void CodeGenerator::VisitWithExitStatement(WithExitStatement* node) { 1690 void CodeGenerator::VisitWithExitStatement(WithExitStatement* node) {
1688 ASSERT(!in_spilled_code()); 1691 ASSERT(!in_spilled_code());
1689 VirtualFrame::SpilledScope spilled_scope(this);
1690 Comment cmnt(masm_, "[ WithExitStatement"); 1692 Comment cmnt(masm_, "[ WithExitStatement");
1691 CodeForStatement(node); 1693 CodeForStatement(node);
1692 // Pop context. 1694 // Pop context.
1693 __ mov(esi, ContextOperand(esi, Context::PREVIOUS_INDEX)); 1695 __ mov(esi, ContextOperand(esi, Context::PREVIOUS_INDEX));
1694 // Update context local. 1696 // Update context local.
1695 __ mov(frame_->Context(), esi); 1697 frame_->SaveContextRegister();
1696 } 1698 }
1697 1699
1698 1700
1699 int CodeGenerator::FastCaseSwitchMaxOverheadFactor() { 1701 int CodeGenerator::FastCaseSwitchMaxOverheadFactor() {
1700 return kFastSwitchMaxOverheadFactor; 1702 return kFastSwitchMaxOverheadFactor;
1701 } 1703 }
1702 1704
1703 1705
1704 int CodeGenerator::FastCaseSwitchMinCaseCount() { 1706 int CodeGenerator::FastCaseSwitchMinCaseCount() {
1705 return kFastSwitchMinCaseCount; 1707 return kFastSwitchMinCaseCount;
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
2633 } 2635 }
2634 } 2636 }
2635 2637
2636 2638
2637 void CodeGenerator::StoreToSlot(Slot* slot, InitState init_state) { 2639 void CodeGenerator::StoreToSlot(Slot* slot, InitState init_state) {
2638 if (slot->type() == Slot::LOOKUP) { 2640 if (slot->type() == Slot::LOOKUP) {
2639 ASSERT(slot->var()->mode() == Variable::DYNAMIC); 2641 ASSERT(slot->var()->mode() == Variable::DYNAMIC);
2640 2642
2641 // For now, just do a runtime call. 2643 // For now, just do a runtime call.
2642 VirtualFrame::SpilledScope spilled_scope(this); 2644 VirtualFrame::SpilledScope spilled_scope(this);
2643 frame_->EmitPush(frame_->Context()); 2645 frame_->EmitPush(esi);
2644 frame_->EmitPush(Immediate(slot->var()->name())); 2646 frame_->EmitPush(Immediate(slot->var()->name()));
2645 2647
2646 if (init_state == CONST_INIT) { 2648 if (init_state == CONST_INIT) {
2647 // Same as the case for a normal store, but ignores attribute 2649 // Same as the case for a normal store, but ignores attribute
2648 // (e.g. READ_ONLY) of context slot so that we can initialize const 2650 // (e.g. READ_ONLY) of context slot so that we can initialize const
2649 // properties (introduced via eval("const foo = (some expr);")). Also, 2651 // properties (introduced via eval("const foo = (some expr);")). Also,
2650 // uses the current function context instead of the top context. 2652 // uses the current function context instead of the top context.
2651 // 2653 //
2652 // Note that we must declare the foo upon entry of eval(), via a 2654 // Note that we must declare the foo upon entry of eval(), via a
2653 // context slot declaration, but we cannot initialize it at the same 2655 // context slot declaration, but we cannot initialize it at the same
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
3115 LoadAndSpill(args->at(i)); 3117 LoadAndSpill(args->at(i));
3116 } 3118 }
3117 3119
3118 // Setup the receiver register and call the IC initialization code. 3120 // Setup the receiver register and call the IC initialization code.
3119 Handle<Code> stub = (loop_nesting() > 0) 3121 Handle<Code> stub = (loop_nesting() > 0)
3120 ? ComputeCallInitializeInLoop(arg_count) 3122 ? ComputeCallInitializeInLoop(arg_count)
3121 : ComputeCallInitialize(arg_count); 3123 : ComputeCallInitialize(arg_count);
3122 CodeForSourcePosition(node->position()); 3124 CodeForSourcePosition(node->position());
3123 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET_CONTEXT, 3125 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET_CONTEXT,
3124 arg_count + 1); 3126 arg_count + 1);
3125 __ mov(esi, frame_->Context()); 3127 frame_->RestoreContextRegister();
3126 3128
3127 // Overwrite the function on the stack with the result. 3129 // Overwrite the function on the stack with the result.
3128 __ mov(frame_->Top(), eax); 3130 __ mov(frame_->Top(), eax);
3129 3131
3130 } else if (var != NULL && var->slot() != NULL && 3132 } else if (var != NULL && var->slot() != NULL &&
3131 var->slot()->type() == Slot::LOOKUP) { 3133 var->slot()->type() == Slot::LOOKUP) {
3132 // ---------------------------------- 3134 // ----------------------------------
3133 // JavaScript example: 'with (obj) foo(1, 2, 3)' // foo is in obj 3135 // JavaScript example: 'with (obj) foo(1, 2, 3)' // foo is in obj
3134 // ---------------------------------- 3136 // ----------------------------------
3135 3137
(...skipping 28 matching lines...) Expand all
3164 for (int i = 0; i < arg_count; i++) { 3166 for (int i = 0; i < arg_count; i++) {
3165 LoadAndSpill(args->at(i)); 3167 LoadAndSpill(args->at(i));
3166 } 3168 }
3167 3169
3168 // Call the IC initialization code. 3170 // Call the IC initialization code.
3169 Handle<Code> stub = (loop_nesting() > 0) 3171 Handle<Code> stub = (loop_nesting() > 0)
3170 ? ComputeCallInitializeInLoop(arg_count) 3172 ? ComputeCallInitializeInLoop(arg_count)
3171 : ComputeCallInitialize(arg_count); 3173 : ComputeCallInitialize(arg_count);
3172 CodeForSourcePosition(node->position()); 3174 CodeForSourcePosition(node->position());
3173 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, arg_count + 1); 3175 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, arg_count + 1);
3174 __ mov(esi, frame_->Context()); 3176 frame_->RestoreContextRegister();
3175 3177
3176 // Overwrite the function on the stack with the result. 3178 // Overwrite the function on the stack with the result.
3177 __ mov(frame_->Top(), eax); 3179 __ mov(frame_->Top(), eax);
3178 3180
3179 } else { 3181 } else {
3180 // ------------------------------------------- 3182 // -------------------------------------------
3181 // JavaScript example: 'array[index](1, 2, 3)' 3183 // JavaScript example: 'array[index](1, 2, 3)'
3182 // ------------------------------------------- 3184 // -------------------------------------------
3183 3185
3184 // Load the function to call from the property through a reference. 3186 // Load the function to call from the property through a reference.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
3292 __ mov(edx, FieldOperand(eax, FixedArray::kHeaderSize + kPointerSize)); 3294 __ mov(edx, FieldOperand(eax, FixedArray::kHeaderSize + kPointerSize));
3293 __ mov(frame_->ElementAt(arg_count), edx); 3295 __ mov(frame_->ElementAt(arg_count), edx);
3294 3296
3295 // Call the function. 3297 // Call the function.
3296 CodeForSourcePosition(node->position()); 3298 CodeForSourcePosition(node->position());
3297 3299
3298 CallFunctionStub call_function(arg_count); 3300 CallFunctionStub call_function(arg_count);
3299 frame_->CallStub(&call_function, arg_count + 1); 3301 frame_->CallStub(&call_function, arg_count + 1);
3300 3302
3301 // Restore context and pop function from the stack. 3303 // Restore context and pop function from the stack.
3302 __ mov(esi, frame_->Context()); 3304 frame_->RestoreContextRegister();
3303 __ mov(frame_->Top(), eax); 3305 __ mov(frame_->Top(), eax);
3304 } 3306 }
3305 3307
3306 3308
3307 void CodeGenerator::GenerateIsSmi(ZoneList<Expression*>* args) { 3309 void CodeGenerator::GenerateIsSmi(ZoneList<Expression*>* args) {
3308 ASSERT(args->length() == 1); 3310 ASSERT(args->length() == 1);
3309 LoadAndSpill(args->at(0)); 3311 LoadAndSpill(args->at(0));
3310 frame_->EmitPop(eax); 3312 frame_->EmitPop(eax);
3311 __ test(eax, Immediate(kSmiTagMask)); 3313 __ test(eax, Immediate(kSmiTagMask));
3312 cc_reg_ = zero; 3314 cc_reg_ = zero;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
3575 int arg_count = args->length(); 3577 int arg_count = args->length();
3576 for (int i = 0; i < arg_count; i++) { 3578 for (int i = 0; i < arg_count; i++) {
3577 LoadAndSpill(args->at(i)); 3579 LoadAndSpill(args->at(i));
3578 } 3580 }
3579 3581
3580 if (function == NULL) { 3582 if (function == NULL) {
3581 // Call the JS runtime function. 3583 // Call the JS runtime function.
3582 Handle<Code> stub = ComputeCallInitialize(arg_count); 3584 Handle<Code> stub = ComputeCallInitialize(arg_count);
3583 __ Set(eax, Immediate(args->length())); 3585 __ Set(eax, Immediate(args->length()));
3584 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, arg_count + 1); 3586 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, arg_count + 1);
3585 __ mov(esi, frame_->Context()); 3587 frame_->RestoreContextRegister();
3586 __ mov(frame_->Top(), eax); 3588 __ mov(frame_->Top(), eax);
3587 } else { 3589 } else {
3588 // Call the C runtime function. 3590 // Call the C runtime function.
3589 frame_->CallRuntime(function, arg_count); 3591 frame_->CallRuntime(function, arg_count);
3590 frame_->EmitPush(eax); 3592 frame_->EmitPush(eax);
3591 } 3593 }
3592 } 3594 }
3593 3595
3594 3596
3595 void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { 3597 void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) {
(...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after
5797 5799
5798 // Slow-case: Go through the JavaScript implementation. 5800 // Slow-case: Go through the JavaScript implementation.
5799 __ bind(&slow); 5801 __ bind(&slow);
5800 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); 5802 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION);
5801 } 5803 }
5802 5804
5803 5805
5804 #undef __ 5806 #undef __
5805 5807
5806 } } // namespace v8::internal 5808 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/virtual-frame-ia32.h » ('j') | src/virtual-frame-ia32.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698