| Index: src/hydrogen.cc
|
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc
|
| index 62fa571bbcdcd2e29e687b5d2ffc4604979cbab8..3c34d2732aac496f594c774c0fcb87bf6e0a6902 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::New(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::New(zone, context, mul, header_size));
|
| total_size->ChangeRepresentation(Representation::Integer32());
|
| total_size->ClearFlag(HValue::kCanOverflow);
|
|
|
| @@ -7112,16 +7112,16 @@ 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::New(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::New(zone(), context, char_code);
|
|
|
| } else if (expr->IsFunctionPrototype()) {
|
| HValue* function = Pop();
|
| @@ -7791,6 +7791,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr,
|
| if (!FLAG_fast_math) break;
|
| // Fall through if FLAG_fast_math.
|
| case kMathRound:
|
| + case kMathFloor:
|
| case kMathAbs:
|
| case kMathSqrt:
|
| case kMathLog:
|
| @@ -7801,8 +7802,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::New(zone(), context, argument, id);
|
| op->set_position(expr->position());
|
| if (drop_extra) Drop(1); // Optionally drop the function.
|
| ast_context()->ReturnInstruction(op, expr->id());
|
| @@ -7839,15 +7840,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::New(zone(), context, char_code);
|
| ast_context()->ReturnInstruction(result, expr->id());
|
| return true;
|
| }
|
| @@ -7868,8 +7869,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::New(zone(), context, argument, id);
|
| op->set_position(expr->position());
|
| ast_context()->ReturnInstruction(op, expr->id());
|
| return true;
|
| @@ -7888,30 +7889,30 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
|
| double exponent = HConstant::cast(right)->DoubleValue();
|
| if (exponent == 0.5) {
|
| result =
|
| - new(zone()) HUnaryMathOperation(context, left, kMathPowHalf);
|
| + HUnaryMathOperation::New(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::New(zone(), context, left, kMathPowHalf);
|
| + 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::New(zone(), context, double_one, sqrt);
|
| } else if (exponent == 2.0) {
|
| - result = new(zone()) HMul(context, left, left);
|
| + result = HMul::New(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::New(zone(), context, left, left);
|
| }
|
|
|
| if (result == NULL) {
|
| - result = new(zone()) HPower(left, right);
|
| + result = HPower::New(zone(), left, right);
|
| }
|
| ast_context()->ReturnInstruction(result, expr->id());
|
| return true;
|
| @@ -7939,7 +7940,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::New(zone(), context, left, right, op);
|
| ast_context()->ReturnInstruction(result, expr->id());
|
| return true;
|
| }
|
| @@ -8513,7 +8515,7 @@ void HOptimizedGraphBuilder::VisitAdd(UnaryOperation* expr) {
|
| HValue* value = Pop();
|
| HValue* context = environment()->LookupContext();
|
| HInstruction* instr =
|
| - new(zone()) HMul(context, value, graph()->GetConstant1());
|
| + HMul::New(zone(), context, value, graph()->GetConstant1());
|
| return ast_context()->ReturnInstruction(instr, expr->id());
|
| }
|
|
|
| @@ -8523,14 +8525,16 @@ void HOptimizedGraphBuilder::VisitSub(UnaryOperation* expr) {
|
| HValue* value = Pop();
|
| HValue* context = environment()->LookupContext();
|
| HInstruction* instr =
|
| - new(zone()) HMul(context, value, graph()->GetConstantMinus1());
|
| + HMul::New(zone(), context, value, graph()->GetConstantMinus1());
|
| TypeInfo info = oracle()->UnaryType(expr);
|
| Representation rep = ToRepresentation(info);
|
| if (info.IsUninitialized()) {
|
| AddSoftDeoptimize();
|
| info = TypeInfo::Unknown();
|
| }
|
| - HBinaryOperation::cast(instr)->set_observed_input_representation(rep, rep);
|
| + if (instr->IsBinaryOperation()) {
|
| + HBinaryOperation::cast(instr)->set_observed_input_representation(rep, rep);
|
| + }
|
| return ast_context()->ReturnInstruction(instr, expr->id());
|
| }
|
|
|
| @@ -8618,7 +8622,7 @@ HInstruction* HOptimizedGraphBuilder::BuildIncrement(
|
| ? graph()->GetConstant1()
|
| : graph()->GetConstantMinus1();
|
| HValue* context = environment()->LookupContext();
|
| - HInstruction* instr = new(zone()) HAdd(context, Top(), delta);
|
| + HInstruction* instr = HAdd::New(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 +8818,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,26 +8924,26 @@ 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::New(zone(), context, left, right);
|
| } else {
|
| - instr = HAdd::NewHAdd(zone(), context, left, right);
|
| + instr = HAdd::New(zone(), context, left, right);
|
| }
|
| break;
|
| case Token::SUB:
|
| - instr = HSub::NewHSub(zone(), context, left, right);
|
| + instr = HSub::New(zone(), context, left, right);
|
| break;
|
| case Token::MUL:
|
| - instr = HMul::NewHMul(zone(), context, left, right);
|
| + instr = HMul::New(zone(), context, left, right);
|
| break;
|
| case Token::MOD:
|
| - instr = HMod::NewHMod(zone(), context, left, right);
|
| + instr = HMod::New(zone(), context, left, right);
|
| break;
|
| case Token::DIV:
|
| - instr = HDiv::NewHDiv(zone(), context, left, right);
|
| + instr = HDiv::New(zone(), context, left, right);
|
| break;
|
| case Token::BIT_XOR:
|
| case Token::BIT_AND:
|
| - instr = HBitwise::NewHBitwise(zone(), expr->op(), context, left, right);
|
| + instr = HBitwise::New(zone(), expr->op(), context, left, right);
|
| break;
|
| case Token::BIT_OR: {
|
| HValue* operand, *shift_amount;
|
| @@ -8935,22 +8951,22 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation(
|
| MatchRotateRight(left, right, &operand, &shift_amount)) {
|
| instr = new(zone()) HRor(context, operand, shift_amount);
|
| } else {
|
| - instr = HBitwise::NewHBitwise(zone(), expr->op(), context, left, right);
|
| + instr = HBitwise::New(zone(), expr->op(), context, left, right);
|
| }
|
| break;
|
| }
|
| case Token::SAR:
|
| - instr = HSar::NewHSar(zone(), context, left, right);
|
| + instr = HSar::New(zone(), context, left, right);
|
| break;
|
| case Token::SHR:
|
| - instr = HShr::NewHShr(zone(), context, left, right);
|
| + instr = HShr::New(zone(), context, left, right);
|
| if (FLAG_opt_safe_uint32_operations && instr->IsShr() &&
|
| CanBeZero(right)) {
|
| graph()->RecordUint32Instruction(instr);
|
| }
|
| break;
|
| case Token::SHL:
|
| - instr = HShl::NewHShl(zone(), context, left, right);
|
| + instr = HShl::New(zone(), context, left, right);
|
| break;
|
| default:
|
| UNREACHABLE();
|
| @@ -9710,7 +9726,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 +9784,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 +9809,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);
|
|
|