Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 62fa571bbcdcd2e29e687b5d2ffc4604979cbab8..5aed9d16cdc8bfa7cc83df0ee8e7033c28ef22f4 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -969,7 +969,7 @@ HValue* HGraphBuilder::BuildAllocateElements(HContext* context, |
new(zone) HConstant(elements_size, Representation::Integer32()); |
AddInstruction(elements_size_value); |
HValue* mul = AddInstruction( |
- new(zone) HMul(context, capacity, elements_size_value)); |
+ HMul::NewHMul(zone, context, capacity, elements_size_value)); |
mul->ChangeRepresentation(Representation::Integer32()); |
mul->ClearFlag(HValue::kCanOverflow); |
@@ -977,7 +977,7 @@ HValue* HGraphBuilder::BuildAllocateElements(HContext* context, |
new(zone) HConstant(FixedArray::kHeaderSize, Representation::Integer32()); |
AddInstruction(header_size); |
HValue* total_size = AddInstruction( |
- new(zone) HAdd(context, mul, header_size)); |
+ HAdd::NewHAdd(zone, context, mul, header_size)); |
total_size->ChangeRepresentation(Representation::Integer32()); |
total_size->ClearFlag(HValue::kCanOverflow); |
@@ -7112,16 +7112,17 @@ void HOptimizedGraphBuilder::VisitProperty(Property* expr) { |
HValue* string = Pop(); |
AddInstruction(new(zone()) HCheckNonSmi(string)); |
AddInstruction(HCheckInstanceType::NewIsString(string, zone())); |
- instr = new(zone()) HStringLength(string); |
+ instr = HStringLength::NewHStringLength(zone(), string); |
} else if (expr->IsStringAccess()) { |
CHECK_ALIVE(VisitForValue(expr->key())); |
HValue* index = Pop(); |
HValue* string = Pop(); |
HValue* context = environment()->LookupContext(); |
- HStringCharCodeAt* char_code = |
+ HInstruction* char_code = |
BuildStringCharCodeAt(context, string, index); |
AddInstruction(char_code); |
- instr = new(zone()) HStringCharFromCode(context, char_code); |
+ instr = |
+ HStringCharFromCode::NewHStringCharFromCode(zone(), context, char_code); |
} else if (expr->IsFunctionPrototype()) { |
HValue* function = Pop(); |
@@ -7791,6 +7792,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, |
if (!FLAG_fast_math) break; |
// Fall through if FLAG_fast_math. |
case kMathRound: |
+ case kMathFloor: |
Jakob Kummerow
2013/02/20 15:31:04
good catch!
|
case kMathAbs: |
case kMathSqrt: |
case kMathLog: |
@@ -7801,8 +7803,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, |
HValue* argument = Pop(); |
HValue* context = environment()->LookupContext(); |
Drop(1); // Receiver. |
- HUnaryMathOperation* op = |
- new(zone()) HUnaryMathOperation(context, argument, id); |
+ HInstruction* op = HUnaryMathOperation::NewHUnaryMathOperation( |
+ zone(), context, argument, id); |
Jakob Kummerow
2013/02/20 15:31:04
nit: I'd indent 4 spaces relative to "HInstruction
|
op->set_position(expr->position()); |
if (drop_extra) Drop(1); // Optionally drop the function. |
ast_context()->ReturnInstruction(op, expr->id()); |
@@ -7839,15 +7841,15 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( |
oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK), |
expr->holder(), |
zone())); |
- HStringCharCodeAt* char_code = |
+ HInstruction* char_code = |
BuildStringCharCodeAt(context, string, index); |
if (id == kStringCharCodeAt) { |
ast_context()->ReturnInstruction(char_code, expr->id()); |
return true; |
} |
AddInstruction(char_code); |
- HStringCharFromCode* result = |
- new(zone()) HStringCharFromCode(context, char_code); |
+ HInstruction* result = HStringCharFromCode::NewHStringCharFromCode( |
+ zone(), context, char_code); |
ast_context()->ReturnInstruction(result, expr->id()); |
return true; |
} |
@@ -7868,8 +7870,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( |
HValue* argument = Pop(); |
HValue* context = environment()->LookupContext(); |
Drop(1); // Receiver. |
- HUnaryMathOperation* op = |
- new(zone()) HUnaryMathOperation(context, argument, id); |
+ HInstruction* op = HUnaryMathOperation::NewHUnaryMathOperation( |
+ zone(), context, argument, id); |
op->set_position(expr->position()); |
ast_context()->ReturnInstruction(op, expr->id()); |
return true; |
@@ -7887,31 +7889,31 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( |
if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) { |
double exponent = HConstant::cast(right)->DoubleValue(); |
if (exponent == 0.5) { |
- result = |
- new(zone()) HUnaryMathOperation(context, left, kMathPowHalf); |
+ result = HUnaryMathOperation::NewHUnaryMathOperation( |
+ zone(), context, left, kMathPowHalf); |
} else if (exponent == -0.5) { |
HConstant* double_one = |
new(zone()) HConstant(Handle<Object>(Smi::FromInt(1)), |
Representation::Double()); |
AddInstruction(double_one); |
- HUnaryMathOperation* square_root = |
- new(zone()) HUnaryMathOperation(context, left, kMathPowHalf); |
- AddInstruction(square_root); |
+ HInstruction* sqrt = HUnaryMathOperation::NewHUnaryMathOperation( |
+ zone(), context, left, kMathPowHalf); |
Jakob Kummerow
2013/02/20 15:31:04
nit: now this indentation is just inconsistent wit
Yang
2013/02/20 17:51:15
Done.
|
+ AddInstruction(sqrt); |
// MathPowHalf doesn't have side effects so there's no need for |
// an environment simulation here. |
- ASSERT(!square_root->HasObservableSideEffects()); |
- result = new(zone()) HDiv(context, double_one, square_root); |
+ ASSERT(!sqrt->HasObservableSideEffects()); |
+ result = HDiv::NewHDiv(zone(), context, double_one, sqrt); |
} else if (exponent == 2.0) { |
- result = new(zone()) HMul(context, left, left); |
+ result = HMul::NewHMul(zone(), context, left, left); |
} |
} else if (right->IsConstant() && |
HConstant::cast(right)->HasInteger32Value() && |
HConstant::cast(right)->Integer32Value() == 2) { |
- result = new(zone()) HMul(context, left, left); |
+ result = HMul::NewHMul(zone(), context, left, left); |
} |
if (result == NULL) { |
- result = new(zone()) HPower(left, right); |
+ result = HPower::NewHPower(zone(), left, right); |
} |
ast_context()->ReturnInstruction(result, expr->id()); |
return true; |
@@ -7939,7 +7941,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( |
HValue* context = environment()->LookupContext(); |
HMathMinMax::Operation op = (id == kMathMin) ? HMathMinMax::kMathMin |
: HMathMinMax::kMathMax; |
- HMathMinMax* result = new(zone()) HMathMinMax(context, left, right, op); |
+ HInstruction* result = HMathMinMax::NewHMathMinMax( |
+ zone(), context, left, right, op); |
ast_context()->ReturnInstruction(result, expr->id()); |
return true; |
} |
@@ -8618,7 +8621,7 @@ HInstruction* HOptimizedGraphBuilder::BuildIncrement( |
? graph()->GetConstant1() |
: graph()->GetConstantMinus1(); |
HValue* context = environment()->LookupContext(); |
- HInstruction* instr = new(zone()) HAdd(context, Top(), delta); |
+ HInstruction* instr = HAdd::NewHAdd(zone(), context, Top(), delta); |
// We can't insert a simulate here, because it would break deoptimization, |
// so the HAdd must not have side effects, so we must freeze its |
// representation. |
@@ -8814,10 +8817,22 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) { |
} |
-HStringCharCodeAt* HOptimizedGraphBuilder::BuildStringCharCodeAt( |
+HInstruction* HOptimizedGraphBuilder::BuildStringCharCodeAt( |
HValue* context, |
HValue* string, |
HValue* index) { |
+ if (string->IsConstant() && index->IsConstant()) { |
+ HConstant* c_string = HConstant::cast(string); |
+ HConstant* c_index = HConstant::cast(index); |
+ if (c_string->HasStringValue() && c_index->HasNumberValue()) { |
+ int32_t i = c_index->NumberValueAsInteger32(); |
+ Handle<String> s = c_string->StringValue(); |
+ if (i < 0 || i >= s->length()) { |
+ return new(zone()) HConstant(OS::nan_value(), Representation::Double()); |
+ } |
+ return new(zone()) HConstant(s->Get(i), Representation::Integer32()); |
+ } |
+ } |
AddInstruction(new(zone()) HCheckNonSmi(string)); |
AddInstruction(HCheckInstanceType::NewIsString(string, zone())); |
HStringLength* length = new(zone()) HStringLength(string); |
@@ -8908,7 +8923,7 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation( |
AddInstruction(HCheckInstanceType::NewIsString(left, zone())); |
AddInstruction(new(zone()) HCheckNonSmi(right)); |
AddInstruction(HCheckInstanceType::NewIsString(right, zone())); |
- instr = new(zone()) HStringAdd(context, left, right); |
+ instr = HStringAdd::NewHStringAdd(zone(), context, left, right); |
} else { |
instr = HAdd::NewHAdd(zone(), context, left, right); |
} |
@@ -9710,7 +9725,7 @@ void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar( |
HValue* index = Pop(); |
HValue* string = Pop(); |
HValue* context = environment()->LookupContext(); |
- HStringCharCodeAt* char_code = BuildStringCharCodeAt(context, string, index); |
+ HInstruction* char_code = BuildStringCharCodeAt(context, string, index); |
AddInstruction(char_code); |
HSeqStringSetChar* result = new(zone()) HSeqStringSetChar( |
String::TWO_BYTE_ENCODING, string, index, value); |
@@ -9768,7 +9783,7 @@ void HOptimizedGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { |
HValue* index = Pop(); |
HValue* string = Pop(); |
HValue* context = environment()->LookupContext(); |
- HStringCharCodeAt* result = BuildStringCharCodeAt(context, string, index); |
+ HInstruction* result = BuildStringCharCodeAt(context, string, index); |
return ast_context()->ReturnInstruction(result, call->id()); |
} |
@@ -9793,7 +9808,7 @@ void HOptimizedGraphBuilder::GenerateStringCharAt(CallRuntime* call) { |
HValue* index = Pop(); |
HValue* string = Pop(); |
HValue* context = environment()->LookupContext(); |
- HStringCharCodeAt* char_code = BuildStringCharCodeAt(context, string, index); |
+ HInstruction* char_code = BuildStringCharCodeAt(context, string, index); |
AddInstruction(char_code); |
HStringCharFromCode* result = |
new(zone()) HStringCharFromCode(context, char_code); |