Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Unified Diff: src/hydrogen.cc

Issue 1144183004: [strong] Refactor ObjectStrength into a replacement for strong boolean args (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback and rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 9bbafb224977b436edc15841689f0331d908c196..810a8b92210d4bb2389d024490c65b0b88e22eb1 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -10312,8 +10312,8 @@ HInstruction* HOptimizedGraphBuilder::BuildIncrement(
HConstant* delta = (expr->op() == Token::INC)
? graph()->GetConstant1()
: graph()->GetConstantMinus1();
- HInstruction* instr = AddUncasted<HAdd>(Top(), delta,
- function_language_mode());
+ HInstruction* instr =
+ AddUncasted<HAdd>(Top(), delta, strength(function_language_mode()));
if (instr->IsAdd()) {
HAdd* add = HAdd::cast(instr);
add->set_observed_input_representation(1, rep);
@@ -10607,7 +10607,7 @@ HValue* HOptimizedGraphBuilder::BuildBinaryOperation(
HValue* result = HGraphBuilder::BuildBinaryOperation(
expr->op(), left, right, left_type, right_type, result_type,
- fixed_right_arg, allocation_mode, function_language_mode());
+ fixed_right_arg, allocation_mode, strength(function_language_mode()));
// Add a simulate after instructions with observable side effects, and
// after phis, which are the result of BuildBinaryOperation when we
// inlined some complex subgraph.
@@ -10624,16 +10624,12 @@ HValue* HOptimizedGraphBuilder::BuildBinaryOperation(
}
-HValue* HGraphBuilder::BuildBinaryOperation(
- Token::Value op,
- HValue* left,
- HValue* right,
- Type* left_type,
- Type* right_type,
- Type* result_type,
- Maybe<int> fixed_right_arg,
- HAllocationMode allocation_mode,
- LanguageMode language_mode) {
+HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left,
+ HValue* right, Type* left_type,
+ Type* right_type, Type* result_type,
+ Maybe<int> fixed_right_arg,
+ HAllocationMode allocation_mode,
+ Strength strength) {
bool maybe_string_add = false;
if (op == Token::ADD) {
// If we are adding constant string with something for which we don't have
@@ -10695,27 +10691,27 @@ HValue* HGraphBuilder::BuildBinaryOperation(
}
// Convert left argument as necessary.
- if (left_type->Is(Type::Number()) && !is_strong(language_mode)) {
+ if (left_type->Is(Type::Number()) && !is_strong(strength)) {
DCHECK(right_type->Is(Type::String()));
left = BuildNumberToString(left, left_type);
} else if (!left_type->Is(Type::String())) {
DCHECK(right_type->Is(Type::String()));
- HValue* function = AddLoadJSBuiltin(is_strong(language_mode) ?
- Builtins::STRING_ADD_RIGHT_STRONG :
- Builtins::STRING_ADD_RIGHT);
+ HValue* function = AddLoadJSBuiltin(
+ is_strong(strength) ? Builtins::STRING_ADD_RIGHT_STRONG
+ : Builtins::STRING_ADD_RIGHT);
Add<HPushArguments>(left, right);
return AddUncasted<HInvokeFunction>(function, 2);
}
// Convert right argument as necessary.
- if (right_type->Is(Type::Number()) && !is_strong(language_mode)) {
+ if (right_type->Is(Type::Number()) && !is_strong(strength)) {
DCHECK(left_type->Is(Type::String()));
right = BuildNumberToString(right, right_type);
} else if (!right_type->Is(Type::String())) {
DCHECK(left_type->Is(Type::String()));
- HValue* function = AddLoadJSBuiltin(is_strong(language_mode) ?
- Builtins::STRING_ADD_LEFT_STRONG :
- Builtins::STRING_ADD_LEFT);
+ HValue* function = AddLoadJSBuiltin(is_strong(strength)
+ ? Builtins::STRING_ADD_LEFT_STRONG
+ : Builtins::STRING_ADD_LEFT);
Add<HPushArguments>(left, right);
return AddUncasted<HInvokeFunction>(function, 2);
}
@@ -10733,7 +10729,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(
if (!right_string.is_null() && right_string->length() == 0) return left;
if (!left_string.is_null() && !right_string.is_null()) {
return AddUncasted<HStringAdd>(
- left, right, language_mode, allocation_mode.GetPretenureMode(),
+ left, right, strength, allocation_mode.GetPretenureMode(),
STRING_ADD_CHECK_NONE, allocation_mode.feedback_site());
}
@@ -10762,7 +10758,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(
// Fallback to using the string add stub.
return AddUncasted<HStringAdd>(
- left, right, language_mode, allocation_mode.GetPretenureMode(),
+ left, right, strength, allocation_mode.GetPretenureMode(),
STRING_ADD_CHECK_NONE, allocation_mode.feedback_site());
}
@@ -10781,20 +10777,20 @@ HValue* HGraphBuilder::BuildBinaryOperation(
// inline several instructions (including the two pushes) for every tagged
// operation in optimized code, which is more expensive, than a stub call.
if (graph()->info()->IsStub() && is_non_primitive) {
- HValue* function = AddLoadJSBuiltin(
- BinaryOpIC::TokenToJSBuiltin(op, language_mode));
+ HValue* function =
+ AddLoadJSBuiltin(BinaryOpIC::TokenToJSBuiltin(op, strength));
Add<HPushArguments>(left, right);
instr = AddUncasted<HInvokeFunction>(function, 2);
} else {
switch (op) {
case Token::ADD:
- instr = AddUncasted<HAdd>(left, right, language_mode);
+ instr = AddUncasted<HAdd>(left, right, strength);
break;
case Token::SUB:
- instr = AddUncasted<HSub>(left, right, language_mode);
+ instr = AddUncasted<HSub>(left, right, strength);
break;
case Token::MUL:
- instr = AddUncasted<HMul>(left, right, language_mode);
+ instr = AddUncasted<HMul>(left, right, strength);
break;
case Token::MOD: {
if (fixed_right_arg.IsJust() &&
@@ -10807,38 +10803,38 @@ HValue* HGraphBuilder::BuildBinaryOperation(
if_same.ElseDeopt(Deoptimizer::kUnexpectedRHSOfBinaryOperation);
right = fixed_right;
}
- instr = AddUncasted<HMod>(left, right, language_mode);
+ instr = AddUncasted<HMod>(left, right, strength);
break;
}
case Token::DIV:
- instr = AddUncasted<HDiv>(left, right, language_mode);
+ instr = AddUncasted<HDiv>(left, right, strength);
break;
case Token::BIT_XOR:
case Token::BIT_AND:
- instr = AddUncasted<HBitwise>(op, left, right, language_mode);
+ instr = AddUncasted<HBitwise>(op, left, right, strength);
break;
case Token::BIT_OR: {
HValue* operand, *shift_amount;
if (left_type->Is(Type::Signed32()) &&
right_type->Is(Type::Signed32()) &&
MatchRotateRight(left, right, &operand, &shift_amount)) {
- instr = AddUncasted<HRor>(operand, shift_amount, language_mode);
+ instr = AddUncasted<HRor>(operand, shift_amount, strength);
} else {
- instr = AddUncasted<HBitwise>(op, left, right, language_mode);
+ instr = AddUncasted<HBitwise>(op, left, right, strength);
}
break;
}
case Token::SAR:
- instr = AddUncasted<HSar>(left, right, language_mode);
+ instr = AddUncasted<HSar>(left, right, strength);
break;
case Token::SHR:
- instr = AddUncasted<HShr>(left, right, language_mode);
+ instr = AddUncasted<HShr>(left, right, strength);
if (instr->IsShr() && CanBeZero(right)) {
graph()->RecordUint32Instruction(instr);
}
break;
case Token::SHL:
- instr = AddUncasted<HShl>(left, right, language_mode);
+ instr = AddUncasted<HShl>(left, right, strength);
break;
default:
UNREACHABLE();
@@ -11226,8 +11222,8 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
return result;
} else {
if (combined_rep.IsTagged() || combined_rep.IsNone()) {
- HCompareGeneric* result =
- Add<HCompareGeneric>(left, right, op, function_language_mode());
+ HCompareGeneric* result = Add<HCompareGeneric>(
+ left, right, op, strength(function_language_mode()));
result->set_observed_input_representation(1, left_rep);
result->set_observed_input_representation(2, right_rep);
if (result->HasObservableSideEffects()) {
@@ -12087,8 +12083,8 @@ void HOptimizedGraphBuilder::GenerateStringAdd(CallRuntime* call) {
CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
HValue* right = Pop();
HValue* left = Pop();
- HInstruction* result = NewUncasted<HStringAdd>(left, right,
- function_language_mode());
+ HInstruction* result =
+ NewUncasted<HStringAdd>(left, right, strength(function_language_mode()));
return ast_context()->ReturnInstruction(result, call->id());
}
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698