| OLD | NEW |
| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 void LCmpIDAndBranch::PrintDataTo(StringStream* stream) { | 208 void LCmpIDAndBranch::PrintDataTo(StringStream* stream) { |
| 209 stream->Add("if "); | 209 stream->Add("if "); |
| 210 InputAt(0)->PrintTo(stream); | 210 InputAt(0)->PrintTo(stream); |
| 211 stream->Add(" %s ", Token::String(op())); | 211 stream->Add(" %s ", Token::String(op())); |
| 212 InputAt(1)->PrintTo(stream); | 212 InputAt(1)->PrintTo(stream); |
| 213 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); | 213 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 void LIsNullAndBranch::PrintDataTo(StringStream* stream) { | 217 void LIsNilAndBranch::PrintDataTo(StringStream* stream) { |
| 218 stream->Add("if "); | 218 stream->Add("if "); |
| 219 InputAt(0)->PrintTo(stream); | 219 InputAt(0)->PrintTo(stream); |
| 220 stream->Add(is_strict() ? " === null" : " == null"); | 220 stream->Add(kind() == kStrictEquality ? " === " : " == "); |
| 221 stream->Add(nil() == kNullValue ? "null" : "undefined"); |
| 221 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); | 222 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); |
| 222 } | 223 } |
| 223 | 224 |
| 224 | 225 |
| 225 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) { | 226 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) { |
| 226 stream->Add("if is_object("); | 227 stream->Add("if is_object("); |
| 227 InputAt(0)->PrintTo(stream); | 228 InputAt(0)->PrintTo(stream); |
| 228 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); | 229 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); |
| 229 } | 230 } |
| 230 | 231 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 template<int I, int T> | 700 template<int I, int T> |
| 700 LInstruction* LChunkBuilder::DefineFixedDouble( | 701 LInstruction* LChunkBuilder::DefineFixedDouble( |
| 701 LTemplateInstruction<1, I, T>* instr, | 702 LTemplateInstruction<1, I, T>* instr, |
| 702 XMMRegister reg) { | 703 XMMRegister reg) { |
| 703 return Define(instr, ToUnallocated(reg)); | 704 return Define(instr, ToUnallocated(reg)); |
| 704 } | 705 } |
| 705 | 706 |
| 706 | 707 |
| 707 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 708 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
| 708 HEnvironment* hydrogen_env = current_block_->last_environment(); | 709 HEnvironment* hydrogen_env = current_block_->last_environment(); |
| 709 instr->set_environment(CreateEnvironment(hydrogen_env)); | 710 int argument_index_accumulator = 0; |
| 711 instr->set_environment(CreateEnvironment(hydrogen_env, |
| 712 &argument_index_accumulator)); |
| 710 return instr; | 713 return instr; |
| 711 } | 714 } |
| 712 | 715 |
| 713 | 716 |
| 714 LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment( | 717 LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment( |
| 715 LInstruction* instr, int ast_id) { | 718 LInstruction* instr, int ast_id) { |
| 716 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | 719 ASSERT(instruction_pending_deoptimization_environment_ == NULL); |
| 717 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); | 720 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); |
| 718 instruction_pending_deoptimization_environment_ = instr; | 721 instruction_pending_deoptimization_environment_ = instr; |
| 719 pending_deoptimization_ast_id_ = ast_id; | 722 pending_deoptimization_ast_id_ = ast_id; |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 985 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 983 instr = AssignEnvironment(instr); | 986 instr = AssignEnvironment(instr); |
| 984 } | 987 } |
| 985 instr->set_hydrogen_value(current); | 988 instr->set_hydrogen_value(current); |
| 986 chunk_->AddInstruction(instr, current_block_); | 989 chunk_->AddInstruction(instr, current_block_); |
| 987 } | 990 } |
| 988 current_instruction_ = old_current; | 991 current_instruction_ = old_current; |
| 989 } | 992 } |
| 990 | 993 |
| 991 | 994 |
| 992 LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) { | 995 LEnvironment* LChunkBuilder::CreateEnvironment( |
| 996 HEnvironment* hydrogen_env, |
| 997 int* argument_index_accumulator) { |
| 993 if (hydrogen_env == NULL) return NULL; | 998 if (hydrogen_env == NULL) return NULL; |
| 994 | 999 |
| 995 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer()); | 1000 LEnvironment* outer = |
| 1001 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); |
| 996 int ast_id = hydrogen_env->ast_id(); | 1002 int ast_id = hydrogen_env->ast_id(); |
| 997 ASSERT(ast_id != AstNode::kNoNumber); | 1003 ASSERT(ast_id != AstNode::kNoNumber); |
| 998 int value_count = hydrogen_env->length(); | 1004 int value_count = hydrogen_env->length(); |
| 999 LEnvironment* result = new LEnvironment(hydrogen_env->closure(), | 1005 LEnvironment* result = new LEnvironment(hydrogen_env->closure(), |
| 1000 ast_id, | 1006 ast_id, |
| 1001 hydrogen_env->parameter_count(), | 1007 hydrogen_env->parameter_count(), |
| 1002 argument_count_, | 1008 argument_count_, |
| 1003 value_count, | 1009 value_count, |
| 1004 outer); | 1010 outer); |
| 1005 int argument_index = 0; | |
| 1006 for (int i = 0; i < value_count; ++i) { | 1011 for (int i = 0; i < value_count; ++i) { |
| 1007 if (hydrogen_env->is_special_index(i)) continue; | 1012 if (hydrogen_env->is_special_index(i)) continue; |
| 1008 | 1013 |
| 1009 HValue* value = hydrogen_env->values()->at(i); | 1014 HValue* value = hydrogen_env->values()->at(i); |
| 1010 LOperand* op = NULL; | 1015 LOperand* op = NULL; |
| 1011 if (value->IsArgumentsObject()) { | 1016 if (value->IsArgumentsObject()) { |
| 1012 op = NULL; | 1017 op = NULL; |
| 1013 } else if (value->IsPushArgument()) { | 1018 } else if (value->IsPushArgument()) { |
| 1014 op = new LArgument(argument_index++); | 1019 op = new LArgument((*argument_index_accumulator)++); |
| 1015 } else { | 1020 } else { |
| 1016 op = UseAny(value); | 1021 op = UseAny(value); |
| 1017 } | 1022 } |
| 1018 result->AddValue(op, value->representation()); | 1023 result->AddValue(op, value->representation()); |
| 1019 } | 1024 } |
| 1020 | 1025 |
| 1021 return result; | 1026 return result; |
| 1022 } | 1027 } |
| 1023 | 1028 |
| 1024 | 1029 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 return new LCmpObjectEqAndBranch(left, right); | 1434 return new LCmpObjectEqAndBranch(left, right); |
| 1430 } | 1435 } |
| 1431 | 1436 |
| 1432 | 1437 |
| 1433 LInstruction* LChunkBuilder::DoCompareConstantEqAndBranch( | 1438 LInstruction* LChunkBuilder::DoCompareConstantEqAndBranch( |
| 1434 HCompareConstantEqAndBranch* instr) { | 1439 HCompareConstantEqAndBranch* instr) { |
| 1435 return new LCmpConstantEqAndBranch(UseRegisterAtStart(instr->value())); | 1440 return new LCmpConstantEqAndBranch(UseRegisterAtStart(instr->value())); |
| 1436 } | 1441 } |
| 1437 | 1442 |
| 1438 | 1443 |
| 1439 LInstruction* LChunkBuilder::DoIsNullAndBranch(HIsNullAndBranch* instr) { | 1444 LInstruction* LChunkBuilder::DoIsNilAndBranch(HIsNilAndBranch* instr) { |
| 1440 ASSERT(instr->value()->representation().IsTagged()); | 1445 ASSERT(instr->value()->representation().IsTagged()); |
| 1441 LOperand* temp = instr->is_strict() ? NULL : TempRegister(); | 1446 LOperand* temp = instr->kind() == kStrictEquality ? NULL : TempRegister(); |
| 1442 return new LIsNullAndBranch(UseRegisterAtStart(instr->value()), temp); | 1447 return new LIsNilAndBranch(UseRegisterAtStart(instr->value()), temp); |
| 1443 } | 1448 } |
| 1444 | 1449 |
| 1445 | 1450 |
| 1446 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { | 1451 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { |
| 1447 ASSERT(instr->value()->representation().IsTagged()); | 1452 ASSERT(instr->value()->representation().IsTagged()); |
| 1448 return new LIsObjectAndBranch(UseRegisterAtStart(instr->value())); | 1453 return new LIsObjectAndBranch(UseRegisterAtStart(instr->value())); |
| 1449 } | 1454 } |
| 1450 | 1455 |
| 1451 | 1456 |
| 1452 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) { | 1457 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1482 LInstruction* LChunkBuilder::DoHasCachedArrayIndexAndBranch( | 1487 LInstruction* LChunkBuilder::DoHasCachedArrayIndexAndBranch( |
| 1483 HHasCachedArrayIndexAndBranch* instr) { | 1488 HHasCachedArrayIndexAndBranch* instr) { |
| 1484 ASSERT(instr->value()->representation().IsTagged()); | 1489 ASSERT(instr->value()->representation().IsTagged()); |
| 1485 return new LHasCachedArrayIndexAndBranch(UseRegisterAtStart(instr->value())); | 1490 return new LHasCachedArrayIndexAndBranch(UseRegisterAtStart(instr->value())); |
| 1486 } | 1491 } |
| 1487 | 1492 |
| 1488 | 1493 |
| 1489 LInstruction* LChunkBuilder::DoClassOfTestAndBranch( | 1494 LInstruction* LChunkBuilder::DoClassOfTestAndBranch( |
| 1490 HClassOfTestAndBranch* instr) { | 1495 HClassOfTestAndBranch* instr) { |
| 1491 return new LClassOfTestAndBranch(UseTempRegister(instr->value()), | 1496 return new LClassOfTestAndBranch(UseTempRegister(instr->value()), |
| 1497 TempRegister(), |
| 1492 TempRegister()); | 1498 TempRegister()); |
| 1493 } | 1499 } |
| 1494 | 1500 |
| 1495 | 1501 |
| 1496 LInstruction* LChunkBuilder::DoJSArrayLength(HJSArrayLength* instr) { | 1502 LInstruction* LChunkBuilder::DoJSArrayLength(HJSArrayLength* instr) { |
| 1497 LOperand* array = UseRegisterAtStart(instr->value()); | 1503 LOperand* array = UseRegisterAtStart(instr->value()); |
| 1498 return DefineAsRegister(new LJSArrayLength(array)); | 1504 return DefineAsRegister(new LJSArrayLength(array)); |
| 1499 } | 1505 } |
| 1500 | 1506 |
| 1501 | 1507 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 return DefineAsRegister(new LConstantT); | 1715 return DefineAsRegister(new LConstantT); |
| 1710 } else { | 1716 } else { |
| 1711 UNREACHABLE(); | 1717 UNREACHABLE(); |
| 1712 return NULL; | 1718 return NULL; |
| 1713 } | 1719 } |
| 1714 } | 1720 } |
| 1715 | 1721 |
| 1716 | 1722 |
| 1717 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { | 1723 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { |
| 1718 LLoadGlobalCell* result = new LLoadGlobalCell; | 1724 LLoadGlobalCell* result = new LLoadGlobalCell; |
| 1719 return instr->check_hole_value() | 1725 return instr->RequiresHoleCheck() |
| 1720 ? AssignEnvironment(DefineAsRegister(result)) | 1726 ? AssignEnvironment(DefineAsRegister(result)) |
| 1721 : DefineAsRegister(result); | 1727 : DefineAsRegister(result); |
| 1722 } | 1728 } |
| 1723 | 1729 |
| 1724 | 1730 |
| 1725 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) { | 1731 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) { |
| 1726 LOperand* global_object = UseFixed(instr->global_object(), rax); | 1732 LOperand* global_object = UseFixed(instr->global_object(), rax); |
| 1727 LLoadGlobalGeneric* result = new LLoadGlobalGeneric(global_object); | 1733 LLoadGlobalGeneric* result = new LLoadGlobalGeneric(global_object); |
| 1728 return MarkAsCall(DefineFixed(result, rax), instr); | 1734 return MarkAsCall(DefineFixed(result, rax), instr); |
| 1729 } | 1735 } |
| 1730 | 1736 |
| 1731 | 1737 |
| 1732 LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) { | 1738 LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) { |
| 1733 LStoreGlobalCell* result = | 1739 LStoreGlobalCell* result = |
| 1734 new LStoreGlobalCell(UseRegister(instr->value()), TempRegister()); | 1740 new LStoreGlobalCell(UseTempRegister(instr->value()), |
| 1735 return instr->check_hole_value() ? AssignEnvironment(result) : result; | 1741 TempRegister(), |
| 1742 TempRegister()); |
| 1743 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result; |
| 1736 } | 1744 } |
| 1737 | 1745 |
| 1738 | 1746 |
| 1739 LInstruction* LChunkBuilder::DoStoreGlobalGeneric(HStoreGlobalGeneric* instr) { | 1747 LInstruction* LChunkBuilder::DoStoreGlobalGeneric(HStoreGlobalGeneric* instr) { |
| 1740 LOperand* global_object = UseFixed(instr->global_object(), rdx); | 1748 LOperand* global_object = UseFixed(instr->global_object(), rdx); |
| 1741 LOperand* value = UseFixed(instr->value(), rax); | 1749 LOperand* value = UseFixed(instr->value(), rax); |
| 1742 LStoreGlobalGeneric* result = new LStoreGlobalGeneric(global_object, value); | 1750 LStoreGlobalGeneric* result = new LStoreGlobalGeneric(global_object, value); |
| 1743 return MarkAsCall(result, instr); | 1751 return MarkAsCall(result, instr); |
| 1744 } | 1752 } |
| 1745 | 1753 |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2169 LOperand* key = UseOrConstantAtStart(instr->key()); | 2177 LOperand* key = UseOrConstantAtStart(instr->key()); |
| 2170 LOperand* object = UseOrConstantAtStart(instr->object()); | 2178 LOperand* object = UseOrConstantAtStart(instr->object()); |
| 2171 LIn* result = new LIn(key, object); | 2179 LIn* result = new LIn(key, object); |
| 2172 return MarkAsCall(DefineFixed(result, rax), instr); | 2180 return MarkAsCall(DefineFixed(result, rax), instr); |
| 2173 } | 2181 } |
| 2174 | 2182 |
| 2175 | 2183 |
| 2176 } } // namespace v8::internal | 2184 } } // namespace v8::internal |
| 2177 | 2185 |
| 2178 #endif // V8_TARGET_ARCH_X64 | 2186 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |