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 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 return result; | 1040 return result; |
1041 } | 1041 } |
1042 | 1042 |
1043 | 1043 |
1044 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 1044 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
1045 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 1045 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); |
1046 } | 1046 } |
1047 | 1047 |
1048 | 1048 |
1049 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | 1049 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
1050 HValue* v = instr->value(); | 1050 HValue* value = instr->value(); |
1051 if (v->EmitAtUses()) { | 1051 if (value->EmitAtUses()) { |
1052 ASSERT(v->IsConstant()); | 1052 ASSERT(value->IsConstant()); |
1053 ASSERT(!v->representation().IsDouble()); | 1053 ASSERT(!value->representation().IsDouble()); |
1054 HBasicBlock* successor = HConstant::cast(v)->ToBoolean() | 1054 HBasicBlock* successor = HConstant::cast(value)->ToBoolean() |
1055 ? instr->FirstSuccessor() | 1055 ? instr->FirstSuccessor() |
1056 : instr->SecondSuccessor(); | 1056 : instr->SecondSuccessor(); |
1057 return new(zone()) LGoto(successor->block_id()); | 1057 return new(zone()) LGoto(successor->block_id()); |
1058 } | 1058 } |
| 1059 |
| 1060 // Untagged integers or doubles, smis and booleans don't require a |
| 1061 // deoptimization environment nor a temp register. |
| 1062 Representation rep = value->representation(); |
| 1063 HType type = value->type(); |
| 1064 if (!rep.IsTagged() || type.IsSmi() || type.IsBoolean()) { |
| 1065 return new(zone()) LBranch(UseRegister(value), NULL); |
| 1066 } |
| 1067 |
1059 ToBooleanStub::Types expected = instr->expected_input_types(); | 1068 ToBooleanStub::Types expected = instr->expected_input_types(); |
1060 // We need a temporary register when we have to access the map *or* we have | 1069 // We need a temporary register when we have to access the map *or* we have |
1061 // no type info yet, in which case we handle all cases (including the ones | 1070 // no type info yet, in which case we handle all cases (including the ones |
1062 // involving maps). | 1071 // involving maps). |
1063 bool needs_temp = expected.NeedsMap() || expected.IsEmpty(); | 1072 bool needs_temp = expected.NeedsMap() || expected.IsEmpty(); |
1064 LOperand* temp = needs_temp ? TempRegister() : NULL; | 1073 LOperand* temp = needs_temp ? TempRegister() : NULL; |
1065 return AssignEnvironment(new(zone()) LBranch(UseRegister(v), temp)); | 1074 return AssignEnvironment(new(zone()) LBranch(UseRegister(value), temp)); |
1066 } | 1075 } |
1067 | 1076 |
1068 | 1077 |
1069 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { | 1078 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { |
1070 ASSERT(instr->value()->representation().IsTagged()); | 1079 ASSERT(instr->value()->representation().IsTagged()); |
1071 LOperand* value = UseRegisterAtStart(instr->value()); | 1080 LOperand* value = UseRegisterAtStart(instr->value()); |
1072 return new(zone()) LCmpMapAndBranch(value); | 1081 return new(zone()) LCmpMapAndBranch(value); |
1073 } | 1082 } |
1074 | 1083 |
1075 | 1084 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 if (instr->representation().IsInteger32()) { | 1390 if (instr->representation().IsInteger32()) { |
1382 ASSERT(instr->left()->representation().IsInteger32()); | 1391 ASSERT(instr->left()->representation().IsInteger32()); |
1383 ASSERT(instr->right()->representation().IsInteger32()); | 1392 ASSERT(instr->right()->representation().IsInteger32()); |
1384 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1393 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); |
1385 LOperand* right = UseOrConstant(instr->MostConstantOperand()); | 1394 LOperand* right = UseOrConstant(instr->MostConstantOperand()); |
1386 LOperand* temp = NULL; | 1395 LOperand* temp = NULL; |
1387 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1396 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1388 temp = TempRegister(); | 1397 temp = TempRegister(); |
1389 } | 1398 } |
1390 LMulI* mul = new(zone()) LMulI(left, right, temp); | 1399 LMulI* mul = new(zone()) LMulI(left, right, temp); |
1391 return AssignEnvironment(DefineSameAsFirst(mul)); | 1400 if (instr->CheckFlag(HValue::kCanOverflow) || |
| 1401 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1402 AssignEnvironment(mul); |
| 1403 } |
| 1404 return DefineSameAsFirst(mul); |
1392 } else if (instr->representation().IsDouble()) { | 1405 } else if (instr->representation().IsDouble()) { |
1393 return DoArithmeticD(Token::MUL, instr); | 1406 return DoArithmeticD(Token::MUL, instr); |
1394 } else { | 1407 } else { |
1395 ASSERT(instr->representation().IsTagged()); | 1408 ASSERT(instr->representation().IsTagged()); |
1396 return DoArithmeticT(Token::MUL, instr); | 1409 return DoArithmeticT(Token::MUL, instr); |
1397 } | 1410 } |
1398 } | 1411 } |
1399 | 1412 |
1400 | 1413 |
1401 LInstruction* LChunkBuilder::DoSub(HSub* instr) { | 1414 LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 | 1622 |
1610 LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { | 1623 LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { |
1611 LOperand* object = UseRegisterAtStart(instr->value()); | 1624 LOperand* object = UseRegisterAtStart(instr->value()); |
1612 return DefineAsRegister(new(zone()) LElementsKind(object)); | 1625 return DefineAsRegister(new(zone()) LElementsKind(object)); |
1613 } | 1626 } |
1614 | 1627 |
1615 | 1628 |
1616 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { | 1629 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { |
1617 LOperand* object = UseRegister(instr->value()); | 1630 LOperand* object = UseRegister(instr->value()); |
1618 LValueOf* result = new(zone()) LValueOf(object, TempRegister()); | 1631 LValueOf* result = new(zone()) LValueOf(object, TempRegister()); |
1619 return AssignEnvironment(DefineSameAsFirst(result)); | 1632 return DefineSameAsFirst(result); |
1620 } | 1633 } |
1621 | 1634 |
1622 | 1635 |
1623 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { | 1636 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { |
1624 return AssignEnvironment(new(zone()) LBoundsCheck( | 1637 return AssignEnvironment(new(zone()) LBoundsCheck( |
1625 UseRegisterOrConstantAtStart(instr->index()), | 1638 UseRegisterOrConstantAtStart(instr->index()), |
1626 UseAtStart(instr->length()))); | 1639 UseAtStart(instr->length()))); |
1627 } | 1640 } |
1628 | 1641 |
1629 | 1642 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 } | 1962 } |
1950 | 1963 |
1951 | 1964 |
1952 LInstruction* LChunkBuilder::DoLoadKeyedFastElement( | 1965 LInstruction* LChunkBuilder::DoLoadKeyedFastElement( |
1953 HLoadKeyedFastElement* instr) { | 1966 HLoadKeyedFastElement* instr) { |
1954 ASSERT(instr->representation().IsTagged()); | 1967 ASSERT(instr->representation().IsTagged()); |
1955 ASSERT(instr->key()->representation().IsInteger32()); | 1968 ASSERT(instr->key()->representation().IsInteger32()); |
1956 LOperand* obj = UseRegisterAtStart(instr->object()); | 1969 LOperand* obj = UseRegisterAtStart(instr->object()); |
1957 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 1970 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
1958 LLoadKeyedFastElement* result = new(zone()) LLoadKeyedFastElement(obj, key); | 1971 LLoadKeyedFastElement* result = new(zone()) LLoadKeyedFastElement(obj, key); |
1959 return AssignEnvironment(DefineAsRegister(result)); | 1972 if (instr->RequiresHoleCheck()) AssignEnvironment(result); |
| 1973 return DefineAsRegister(result); |
1960 } | 1974 } |
1961 | 1975 |
1962 | 1976 |
1963 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( | 1977 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( |
1964 HLoadKeyedFastDoubleElement* instr) { | 1978 HLoadKeyedFastDoubleElement* instr) { |
1965 ASSERT(instr->representation().IsDouble()); | 1979 ASSERT(instr->representation().IsDouble()); |
1966 ASSERT(instr->key()->representation().IsInteger32()); | 1980 ASSERT(instr->key()->representation().IsInteger32()); |
1967 LOperand* elements = UseRegisterAtStart(instr->elements()); | 1981 LOperand* elements = UseRegisterAtStart(instr->elements()); |
1968 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 1982 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
1969 LLoadKeyedFastDoubleElement* result = | 1983 LLoadKeyedFastDoubleElement* result = |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2374 LOperand* key = UseOrConstantAtStart(instr->key()); | 2388 LOperand* key = UseOrConstantAtStart(instr->key()); |
2375 LOperand* object = UseOrConstantAtStart(instr->object()); | 2389 LOperand* object = UseOrConstantAtStart(instr->object()); |
2376 LIn* result = new(zone()) LIn(context, key, object); | 2390 LIn* result = new(zone()) LIn(context, key, object); |
2377 return MarkAsCall(DefineFixed(result, eax), instr); | 2391 return MarkAsCall(DefineFixed(result, eax), instr); |
2378 } | 2392 } |
2379 | 2393 |
2380 | 2394 |
2381 } } // namespace v8::internal | 2395 } } // namespace v8::internal |
2382 | 2396 |
2383 #endif // V8_TARGET_ARCH_IA32 | 2397 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |