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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 void LCmpIDAndBranch::PrintDataTo(StringStream* stream) { | 206 void LCmpIDAndBranch::PrintDataTo(StringStream* stream) { |
207 stream->Add("if "); | 207 stream->Add("if "); |
208 InputAt(0)->PrintTo(stream); | 208 InputAt(0)->PrintTo(stream); |
209 stream->Add(" %s ", Token::String(op())); | 209 stream->Add(" %s ", Token::String(op())); |
210 InputAt(1)->PrintTo(stream); | 210 InputAt(1)->PrintTo(stream); |
211 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); | 211 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); |
212 } | 212 } |
213 | 213 |
214 | 214 |
215 void LIsNullAndBranch::PrintDataTo(StringStream* stream) { | 215 void LIsNilAndBranch::PrintDataTo(StringStream* stream) { |
216 stream->Add("if "); | 216 stream->Add("if "); |
217 InputAt(0)->PrintTo(stream); | 217 InputAt(0)->PrintTo(stream); |
218 stream->Add(is_strict() ? " === null" : " == null"); | 218 stream->Add(kind() == kStrictEquality ? " === " : " == "); |
| 219 stream->Add(nil() == kNullValue ? "null" : "undefined"); |
219 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); | 220 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); |
220 } | 221 } |
221 | 222 |
222 | 223 |
223 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) { | 224 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) { |
224 stream->Add("if is_object("); | 225 stream->Add("if is_object("); |
225 InputAt(0)->PrintTo(stream); | 226 InputAt(0)->PrintTo(stream); |
226 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); | 227 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); |
227 } | 228 } |
228 | 229 |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 | 705 |
705 template<int I, int T> | 706 template<int I, int T> |
706 LInstruction* LChunkBuilder::DefineFixedDouble( | 707 LInstruction* LChunkBuilder::DefineFixedDouble( |
707 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) { | 708 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) { |
708 return Define(instr, ToUnallocated(reg)); | 709 return Define(instr, ToUnallocated(reg)); |
709 } | 710 } |
710 | 711 |
711 | 712 |
712 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 713 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
713 HEnvironment* hydrogen_env = current_block_->last_environment(); | 714 HEnvironment* hydrogen_env = current_block_->last_environment(); |
714 instr->set_environment(CreateEnvironment(hydrogen_env)); | 715 int argument_index_accumulator = 0; |
| 716 instr->set_environment(CreateEnvironment(hydrogen_env, |
| 717 &argument_index_accumulator)); |
715 return instr; | 718 return instr; |
716 } | 719 } |
717 | 720 |
718 | 721 |
719 LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment( | 722 LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment( |
720 LInstruction* instr, int ast_id) { | 723 LInstruction* instr, int ast_id) { |
721 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | 724 ASSERT(instruction_pending_deoptimization_environment_ == NULL); |
722 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); | 725 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); |
723 instruction_pending_deoptimization_environment_ = instr; | 726 instruction_pending_deoptimization_environment_ = instr; |
724 pending_deoptimization_ast_id_ = ast_id; | 727 pending_deoptimization_ast_id_ = ast_id; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 990 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
988 instr = AssignEnvironment(instr); | 991 instr = AssignEnvironment(instr); |
989 } | 992 } |
990 instr->set_hydrogen_value(current); | 993 instr->set_hydrogen_value(current); |
991 chunk_->AddInstruction(instr, current_block_); | 994 chunk_->AddInstruction(instr, current_block_); |
992 } | 995 } |
993 current_instruction_ = old_current; | 996 current_instruction_ = old_current; |
994 } | 997 } |
995 | 998 |
996 | 999 |
997 LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) { | 1000 LEnvironment* LChunkBuilder::CreateEnvironment( |
| 1001 HEnvironment* hydrogen_env, |
| 1002 int* argument_index_accumulator) { |
998 if (hydrogen_env == NULL) return NULL; | 1003 if (hydrogen_env == NULL) return NULL; |
999 | 1004 |
1000 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer()); | 1005 LEnvironment* outer = |
| 1006 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); |
1001 int ast_id = hydrogen_env->ast_id(); | 1007 int ast_id = hydrogen_env->ast_id(); |
1002 ASSERT(ast_id != AstNode::kNoNumber); | 1008 ASSERT(ast_id != AstNode::kNoNumber); |
1003 int value_count = hydrogen_env->length(); | 1009 int value_count = hydrogen_env->length(); |
1004 LEnvironment* result = new LEnvironment(hydrogen_env->closure(), | 1010 LEnvironment* result = new LEnvironment(hydrogen_env->closure(), |
1005 ast_id, | 1011 ast_id, |
1006 hydrogen_env->parameter_count(), | 1012 hydrogen_env->parameter_count(), |
1007 argument_count_, | 1013 argument_count_, |
1008 value_count, | 1014 value_count, |
1009 outer); | 1015 outer); |
1010 int argument_index = 0; | |
1011 for (int i = 0; i < value_count; ++i) { | 1016 for (int i = 0; i < value_count; ++i) { |
1012 if (hydrogen_env->is_special_index(i)) continue; | 1017 if (hydrogen_env->is_special_index(i)) continue; |
1013 | 1018 |
1014 HValue* value = hydrogen_env->values()->at(i); | 1019 HValue* value = hydrogen_env->values()->at(i); |
1015 LOperand* op = NULL; | 1020 LOperand* op = NULL; |
1016 if (value->IsArgumentsObject()) { | 1021 if (value->IsArgumentsObject()) { |
1017 op = NULL; | 1022 op = NULL; |
1018 } else if (value->IsPushArgument()) { | 1023 } else if (value->IsPushArgument()) { |
1019 op = new LArgument(argument_index++); | 1024 op = new LArgument((*argument_index_accumulator)++); |
1020 } else { | 1025 } else { |
1021 op = UseAny(value); | 1026 op = UseAny(value); |
1022 } | 1027 } |
1023 result->AddValue(op, value->representation()); | 1028 result->AddValue(op, value->representation()); |
1024 } | 1029 } |
1025 | 1030 |
1026 return result; | 1031 return result; |
1027 } | 1032 } |
1028 | 1033 |
1029 | 1034 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 return new LCmpObjectEqAndBranch(left, right); | 1442 return new LCmpObjectEqAndBranch(left, right); |
1438 } | 1443 } |
1439 | 1444 |
1440 | 1445 |
1441 LInstruction* LChunkBuilder::DoCompareConstantEqAndBranch( | 1446 LInstruction* LChunkBuilder::DoCompareConstantEqAndBranch( |
1442 HCompareConstantEqAndBranch* instr) { | 1447 HCompareConstantEqAndBranch* instr) { |
1443 return new LCmpConstantEqAndBranch(UseRegisterAtStart(instr->value())); | 1448 return new LCmpConstantEqAndBranch(UseRegisterAtStart(instr->value())); |
1444 } | 1449 } |
1445 | 1450 |
1446 | 1451 |
1447 LInstruction* LChunkBuilder::DoIsNullAndBranch(HIsNullAndBranch* instr) { | 1452 LInstruction* LChunkBuilder::DoIsNilAndBranch(HIsNilAndBranch* instr) { |
1448 ASSERT(instr->value()->representation().IsTagged()); | 1453 ASSERT(instr->value()->representation().IsTagged()); |
1449 return new LIsNullAndBranch(UseRegisterAtStart(instr->value())); | 1454 return new LIsNilAndBranch(UseRegisterAtStart(instr->value())); |
1450 } | 1455 } |
1451 | 1456 |
1452 | 1457 |
1453 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { | 1458 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { |
1454 ASSERT(instr->value()->representation().IsTagged()); | 1459 ASSERT(instr->value()->representation().IsTagged()); |
1455 LOperand* temp = TempRegister(); | 1460 LOperand* temp = TempRegister(); |
1456 return new LIsObjectAndBranch(UseRegisterAtStart(instr->value()), temp); | 1461 return new LIsObjectAndBranch(UseRegisterAtStart(instr->value()), temp); |
1457 } | 1462 } |
1458 | 1463 |
1459 | 1464 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 return DefineAsRegister(new LConstantT); | 1732 return DefineAsRegister(new LConstantT); |
1728 } else { | 1733 } else { |
1729 UNREACHABLE(); | 1734 UNREACHABLE(); |
1730 return NULL; | 1735 return NULL; |
1731 } | 1736 } |
1732 } | 1737 } |
1733 | 1738 |
1734 | 1739 |
1735 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { | 1740 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { |
1736 LLoadGlobalCell* result = new LLoadGlobalCell; | 1741 LLoadGlobalCell* result = new LLoadGlobalCell; |
1737 return instr->check_hole_value() | 1742 return instr->RequiresHoleCheck() |
1738 ? AssignEnvironment(DefineAsRegister(result)) | 1743 ? AssignEnvironment(DefineAsRegister(result)) |
1739 : DefineAsRegister(result); | 1744 : DefineAsRegister(result); |
1740 } | 1745 } |
1741 | 1746 |
1742 | 1747 |
1743 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) { | 1748 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) { |
1744 LOperand* global_object = UseFixed(instr->global_object(), r0); | 1749 LOperand* global_object = UseFixed(instr->global_object(), r0); |
1745 LLoadGlobalGeneric* result = new LLoadGlobalGeneric(global_object); | 1750 LLoadGlobalGeneric* result = new LLoadGlobalGeneric(global_object); |
1746 return MarkAsCall(DefineFixed(result, r0), instr); | 1751 return MarkAsCall(DefineFixed(result, r0), instr); |
1747 } | 1752 } |
1748 | 1753 |
1749 | 1754 |
1750 LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) { | 1755 LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) { |
1751 if (instr->check_hole_value()) { | 1756 LOperand* temp = TempRegister(); |
1752 LOperand* temp = TempRegister(); | 1757 LOperand* value = UseTempRegister(instr->value()); |
1753 LOperand* value = UseRegister(instr->value()); | 1758 LInstruction* result = new LStoreGlobalCell(value, temp); |
1754 return AssignEnvironment(new LStoreGlobalCell(value, temp)); | 1759 if (instr->RequiresHoleCheck()) result = AssignEnvironment(result); |
1755 } else { | 1760 return result; |
1756 LOperand* value = UseRegisterAtStart(instr->value()); | |
1757 return new LStoreGlobalCell(value, NULL); | |
1758 } | |
1759 } | 1761 } |
1760 | 1762 |
1761 | 1763 |
1762 LInstruction* LChunkBuilder::DoStoreGlobalGeneric(HStoreGlobalGeneric* instr) { | 1764 LInstruction* LChunkBuilder::DoStoreGlobalGeneric(HStoreGlobalGeneric* instr) { |
1763 LOperand* global_object = UseFixed(instr->global_object(), r1); | 1765 LOperand* global_object = UseFixed(instr->global_object(), r1); |
1764 LOperand* value = UseFixed(instr->value(), r0); | 1766 LOperand* value = UseFixed(instr->value(), r0); |
1765 LStoreGlobalGeneric* result = | 1767 LStoreGlobalGeneric* result = |
1766 new LStoreGlobalGeneric(global_object, value); | 1768 new LStoreGlobalGeneric(global_object, value); |
1767 return MarkAsCall(result, instr); | 1769 return MarkAsCall(result, instr); |
1768 } | 1770 } |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2182 | 2184 |
2183 LInstruction* LChunkBuilder::DoIn(HIn* instr) { | 2185 LInstruction* LChunkBuilder::DoIn(HIn* instr) { |
2184 LOperand* key = UseRegisterAtStart(instr->key()); | 2186 LOperand* key = UseRegisterAtStart(instr->key()); |
2185 LOperand* object = UseRegisterAtStart(instr->object()); | 2187 LOperand* object = UseRegisterAtStart(instr->object()); |
2186 LIn* result = new LIn(key, object); | 2188 LIn* result = new LIn(key, object); |
2187 return MarkAsCall(DefineFixed(result, r0), instr); | 2189 return MarkAsCall(DefineFixed(result, r0), instr); |
2188 } | 2190 } |
2189 | 2191 |
2190 | 2192 |
2191 } } // namespace v8::internal | 2193 } } // namespace v8::internal |
OLD | NEW |