OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "bootstrapper.h" | 30 #include "bootstrapper.h" |
31 #include "codegen-inl.h" | 31 #include "codegen-inl.h" |
32 #include "debug.h" | 32 #include "debug.h" |
| 33 #include "runtime.h" |
33 #include "scopes.h" | 34 #include "scopes.h" |
34 #include "runtime.h" | 35 #include "virtual-frame.h" |
35 | 36 |
36 namespace v8 { namespace internal { | 37 namespace v8 { namespace internal { |
37 | 38 |
38 #define __ masm_-> | 39 #define __ masm_-> |
39 | 40 |
40 // ------------------------------------------------------------------------- | 41 // ------------------------------------------------------------------------- |
41 // CodeGenState implementation. | 42 // CodeGenState implementation. |
42 | 43 |
43 CodeGenState::CodeGenState(CodeGenerator* owner) | 44 CodeGenState::CodeGenState(CodeGenerator* owner) |
44 : owner_(owner), | 45 : owner_(owner), |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 370 } |
370 // Check that last extension is NULL. | 371 // Check that last extension is NULL. |
371 __ ldr(tmp2, ContextOperand(context, Context::EXTENSION_INDEX)); | 372 __ ldr(tmp2, ContextOperand(context, Context::EXTENSION_INDEX)); |
372 __ tst(tmp2, tmp2); | 373 __ tst(tmp2, tmp2); |
373 slow->Branch(ne); | 374 slow->Branch(ne); |
374 __ ldr(tmp, ContextOperand(context, Context::FCONTEXT_INDEX)); | 375 __ ldr(tmp, ContextOperand(context, Context::FCONTEXT_INDEX)); |
375 return ContextOperand(tmp, slot->index()); | 376 return ContextOperand(tmp, slot->index()); |
376 } | 377 } |
377 | 378 |
378 | 379 |
| 380 void CodeGenerator::LoadConditionAndSpill(Expression* expression, |
| 381 TypeofState typeof_state, |
| 382 JumpTarget* true_target, |
| 383 JumpTarget* false_target, |
| 384 bool force_control) { |
| 385 ASSERT(in_spilled_code()); |
| 386 set_in_spilled_code(false); |
| 387 LoadCondition(expression, typeof_state, true_target, false_target, |
| 388 force_control); |
| 389 if (frame_ != NULL) { |
| 390 frame_->SpillAll(); |
| 391 } |
| 392 set_in_spilled_code(true); |
| 393 } |
| 394 |
| 395 |
379 // Loads a value on TOS. If it is a boolean value, the result may have been | 396 // Loads a value on TOS. If it is a boolean value, the result may have been |
380 // (partially) translated into branches, or it may have set the condition | 397 // (partially) translated into branches, or it may have set the condition |
381 // code register. If force_cc is set, the value is forced to set the | 398 // code register. If force_cc is set, the value is forced to set the |
382 // condition code register and no value is pushed. If the condition code | 399 // condition code register and no value is pushed. If the condition code |
383 // register was set, has_cc() is true and cc_reg_ contains the condition to | 400 // register was set, has_cc() is true and cc_reg_ contains the condition to |
384 // test for 'true'. | 401 // test for 'true'. |
385 void CodeGenerator::LoadCondition(Expression* x, | 402 void CodeGenerator::LoadCondition(Expression* x, |
386 TypeofState typeof_state, | 403 TypeofState typeof_state, |
387 JumpTarget* true_target, | 404 JumpTarget* true_target, |
388 JumpTarget* false_target, | 405 JumpTarget* false_target, |
(...skipping 25 matching lines...) Expand all Loading... |
414 // Convert the TOS value to a boolean in the condition code register. | 431 // Convert the TOS value to a boolean in the condition code register. |
415 ToBoolean(true_target, false_target); | 432 ToBoolean(true_target, false_target); |
416 } | 433 } |
417 ASSERT(!force_cc || !has_valid_frame() || has_cc()); | 434 ASSERT(!force_cc || !has_valid_frame() || has_cc()); |
418 ASSERT(!has_valid_frame() || | 435 ASSERT(!has_valid_frame() || |
419 (has_cc() && frame_->height() == original_height) || | 436 (has_cc() && frame_->height() == original_height) || |
420 (!has_cc() && frame_->height() == original_height + 1)); | 437 (!has_cc() && frame_->height() == original_height + 1)); |
421 } | 438 } |
422 | 439 |
423 | 440 |
| 441 void CodeGenerator::LoadAndSpill(Expression* expression, |
| 442 TypeofState typeof_state) { |
| 443 ASSERT(in_spilled_code()); |
| 444 set_in_spilled_code(false); |
| 445 Load(expression, typeof_state); |
| 446 frame_->SpillAll(); |
| 447 set_in_spilled_code(true); |
| 448 } |
| 449 |
| 450 |
424 void CodeGenerator::Load(Expression* x, TypeofState typeof_state) { | 451 void CodeGenerator::Load(Expression* x, TypeofState typeof_state) { |
425 #ifdef DEBUG | 452 #ifdef DEBUG |
426 int original_height = frame_->height(); | 453 int original_height = frame_->height(); |
427 #endif | 454 #endif |
428 ASSERT(!in_spilled_code()); | 455 ASSERT(!in_spilled_code()); |
429 JumpTarget true_target(this); | 456 JumpTarget true_target(this); |
430 JumpTarget false_target(this); | 457 JumpTarget false_target(this); |
431 LoadCondition(x, typeof_state, &true_target, &false_target, false); | 458 LoadCondition(x, typeof_state, &true_target, &false_target, false); |
432 | 459 |
433 if (has_cc()) { | 460 if (has_cc()) { |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 void CodeGenerator::CheckStack() { | 1133 void CodeGenerator::CheckStack() { |
1107 VirtualFrame::SpilledScope spilled_scope(this); | 1134 VirtualFrame::SpilledScope spilled_scope(this); |
1108 if (FLAG_check_stack) { | 1135 if (FLAG_check_stack) { |
1109 Comment cmnt(masm_, "[ check stack"); | 1136 Comment cmnt(masm_, "[ check stack"); |
1110 StackCheckStub stub; | 1137 StackCheckStub stub; |
1111 frame_->CallStub(&stub, 0); | 1138 frame_->CallStub(&stub, 0); |
1112 } | 1139 } |
1113 } | 1140 } |
1114 | 1141 |
1115 | 1142 |
| 1143 void CodeGenerator::VisitAndSpill(Statement* statement) { |
| 1144 ASSERT(in_spilled_code()); |
| 1145 set_in_spilled_code(false); |
| 1146 Visit(statement); |
| 1147 if (frame_ != NULL) { |
| 1148 frame_->SpillAll(); |
| 1149 } |
| 1150 set_in_spilled_code(true); |
| 1151 } |
| 1152 |
| 1153 |
| 1154 void CodeGenerator::VisitStatementsAndSpill(ZoneList<Statement*>* statements) { |
| 1155 ASSERT(in_spilled_code()); |
| 1156 set_in_spilled_code(false); |
| 1157 VisitStatements(statements); |
| 1158 if (frame_ != NULL) { |
| 1159 frame_->SpillAll(); |
| 1160 } |
| 1161 set_in_spilled_code(true); |
| 1162 } |
| 1163 |
| 1164 |
1116 void CodeGenerator::VisitStatements(ZoneList<Statement*>* statements) { | 1165 void CodeGenerator::VisitStatements(ZoneList<Statement*>* statements) { |
1117 #ifdef DEBUG | 1166 #ifdef DEBUG |
1118 int original_height = frame_->height(); | 1167 int original_height = frame_->height(); |
1119 #endif | 1168 #endif |
1120 VirtualFrame::SpilledScope spilled_scope(this); | 1169 VirtualFrame::SpilledScope spilled_scope(this); |
1121 for (int i = 0; frame_ != NULL && i < statements->length(); i++) { | 1170 for (int i = 0; frame_ != NULL && i < statements->length(); i++) { |
1122 VisitAndSpill(statements->at(i)); | 1171 VisitAndSpill(statements->at(i)); |
1123 } | 1172 } |
1124 ASSERT(!has_valid_frame() || frame_->height() == original_height); | 1173 ASSERT(!has_valid_frame() || frame_->height() == original_height); |
1125 } | 1174 } |
(...skipping 2841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3967 ASSERT(proxy->AsVariable()->is_global()); | 4016 ASSERT(proxy->AsVariable()->is_global()); |
3968 return proxy->name(); | 4017 return proxy->name(); |
3969 } else { | 4018 } else { |
3970 Literal* raw_name = property->key()->AsLiteral(); | 4019 Literal* raw_name = property->key()->AsLiteral(); |
3971 ASSERT(raw_name != NULL); | 4020 ASSERT(raw_name != NULL); |
3972 return Handle<String>(String::cast(*raw_name->handle())); | 4021 return Handle<String>(String::cast(*raw_name->handle())); |
3973 } | 4022 } |
3974 } | 4023 } |
3975 | 4024 |
3976 | 4025 |
| 4026 void Reference::GetValueAndSpill(TypeofState typeof_state) { |
| 4027 ASSERT(cgen_->in_spilled_code()); |
| 4028 cgen_->set_in_spilled_code(false); |
| 4029 GetValue(typeof_state); |
| 4030 cgen_->frame()->SpillAll(); |
| 4031 cgen_->set_in_spilled_code(true); |
| 4032 } |
| 4033 |
| 4034 |
3977 void Reference::GetValue(TypeofState typeof_state) { | 4035 void Reference::GetValue(TypeofState typeof_state) { |
3978 ASSERT(!cgen_->in_spilled_code()); | 4036 ASSERT(!cgen_->in_spilled_code()); |
3979 ASSERT(cgen_->HasValidEntryRegisters()); | 4037 ASSERT(cgen_->HasValidEntryRegisters()); |
3980 ASSERT(!is_illegal()); | 4038 ASSERT(!is_illegal()); |
3981 ASSERT(!cgen_->has_cc()); | 4039 ASSERT(!cgen_->has_cc()); |
3982 MacroAssembler* masm = cgen_->masm(); | 4040 MacroAssembler* masm = cgen_->masm(); |
3983 Property* property = expression_->AsProperty(); | 4041 Property* property = expression_->AsProperty(); |
3984 if (property != NULL) { | 4042 if (property != NULL) { |
3985 cgen_->CodeForSourcePosition(property->position()); | 4043 cgen_->CodeForSourcePosition(property->position()); |
3986 } | 4044 } |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5086 __ mov(r2, Operand(0)); | 5144 __ mov(r2, Operand(0)); |
5087 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); | 5145 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); |
5088 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), | 5146 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), |
5089 RelocInfo::CODE_TARGET); | 5147 RelocInfo::CODE_TARGET); |
5090 } | 5148 } |
5091 | 5149 |
5092 | 5150 |
5093 #undef __ | 5151 #undef __ |
5094 | 5152 |
5095 } } // namespace v8::internal | 5153 } } // namespace v8::internal |
OLD | NEW |