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

Unified Diff: src/crankshaft/hydrogen.cc

Issue 2302283002: Forking the type system between Crankshaft & Turbofan. (Closed)
Patch Set: Nits. Created 4 years, 3 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/crankshaft/hydrogen.h ('k') | src/crankshaft/hydrogen-types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen.cc
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc
index c0c2fb23c193e5db6efef04bb8582183d84dc904..d559a7d3201ea138706cd019fe1c7eee6638d120 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -2129,8 +2129,7 @@ HValue* HGraphBuilder::BuildRegExpConstructResult(HValue* length,
return result;
}
-
-HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) {
+HValue* HGraphBuilder::BuildNumberToString(HValue* object, AstType* type) {
NoObservableSideEffectsScope scope(this);
// Convert constant numbers at compile time.
@@ -2180,7 +2179,7 @@ HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) {
}
if_objectissmi.Else();
{
- if (type->Is(Type::SignedSmall())) {
+ if (type->Is(AstType::SignedSmall())) {
if_objectissmi.Deopt(DeoptimizeReason::kExpectedSmi);
} else {
// Check if the object is a heap number.
@@ -2236,7 +2235,7 @@ HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) {
}
if_objectisnumber.Else();
{
- if (type->Is(Type::Number())) {
+ if (type->Is(AstType::Number())) {
if_objectisnumber.Deopt(DeoptimizeReason::kExpectedHeapNumber);
}
}
@@ -4999,7 +4998,7 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
CHECK_ALIVE(VisitForValue(stmt->tag()));
Add<HSimulate>(stmt->EntryId());
HValue* tag_value = Top();
- Type* tag_type = bounds_.get(stmt->tag()).lower;
+ AstType* tag_type = bounds_.get(stmt->tag()).lower;
// 1. Build all the tests, with dangling true branches
BailoutId default_id = BailoutId::None();
@@ -5016,8 +5015,8 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
if (current_block() == NULL) return Bailout(kUnsupportedSwitchStatement);
HValue* label_value = Pop();
- Type* label_type = bounds_.get(clause->label()).lower;
- Type* combined_type = clause->compare_type();
+ AstType* label_type = bounds_.get(clause->label()).lower;
+ AstType* combined_type = clause->compare_type();
HControlInstruction* compare = BuildCompareInstruction(
Token::EQ_STRICT, tag_value, label_value, tag_type, label_type,
combined_type,
@@ -6215,7 +6214,7 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::IsCompatible(
PropertyAccessInfo* info) {
if (!CanInlinePropertyAccess(map_)) return false;
- // Currently only handle Type::Number as a polymorphic case.
+ // Currently only handle AstType::Number as a polymorphic case.
// TODO(verwaest): Support monomorphic handling of numbers with a HCheckNumber
// instruction.
if (IsNumberType()) return false;
@@ -7812,7 +7811,7 @@ HValue* HOptimizedGraphBuilder::BuildNamedAccess(
}
HValue* checked_object;
- // Type::Number() is only supported by polymorphic load/call handling.
+ // AstType::Number() is only supported by polymorphic load/call handling.
DCHECK(!info.IsNumberType());
BuildCheckHeapObject(object);
if (AreStringTypes(maps)) {
@@ -10647,13 +10646,12 @@ void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) {
if (join != NULL) return ast_context()->ReturnValue(Pop());
}
-
-static Representation RepresentationFor(Type* type) {
+static Representation RepresentationFor(AstType* type) {
DisallowHeapAllocation no_allocation;
- if (type->Is(Type::None())) return Representation::None();
- if (type->Is(Type::SignedSmall())) return Representation::Smi();
- if (type->Is(Type::Signed32())) return Representation::Integer32();
- if (type->Is(Type::Number())) return Representation::Double();
+ if (type->Is(AstType::None())) return Representation::None();
+ if (type->Is(AstType::SignedSmall())) return Representation::Smi();
+ if (type->Is(AstType::Signed32())) return Representation::Integer32();
+ if (type->Is(AstType::Number())) return Representation::Double();
return Representation::Tagged();
}
@@ -10902,27 +10900,24 @@ bool CanBeZero(HValue* right) {
return true;
}
-
-HValue* HGraphBuilder::EnforceNumberType(HValue* number,
- Type* expected) {
- if (expected->Is(Type::SignedSmall())) {
+HValue* HGraphBuilder::EnforceNumberType(HValue* number, AstType* expected) {
+ if (expected->Is(AstType::SignedSmall())) {
return AddUncasted<HForceRepresentation>(number, Representation::Smi());
}
- if (expected->Is(Type::Signed32())) {
+ if (expected->Is(AstType::Signed32())) {
return AddUncasted<HForceRepresentation>(number,
Representation::Integer32());
}
return number;
}
-
-HValue* HGraphBuilder::TruncateToNumber(HValue* value, Type** expected) {
+HValue* HGraphBuilder::TruncateToNumber(HValue* value, AstType** expected) {
if (value->IsConstant()) {
HConstant* constant = HConstant::cast(value);
Maybe<HConstant*> number =
constant->CopyToTruncatedNumber(isolate(), zone());
if (number.IsJust()) {
- *expected = Type::Number();
+ *expected = AstType::Number();
return AddInstruction(number.FromJust());
}
}
@@ -10932,24 +10927,24 @@ HValue* HGraphBuilder::TruncateToNumber(HValue* value, Type** expected) {
// pushes with a NoObservableSideEffectsScope.
NoObservableSideEffectsScope no_effects(this);
- Type* expected_type = *expected;
+ AstType* expected_type = *expected;
// Separate the number type from the rest.
- Type* expected_obj =
- Type::Intersect(expected_type, Type::NonNumber(), zone());
- Type* expected_number =
- Type::Intersect(expected_type, Type::Number(), zone());
+ AstType* expected_obj =
+ AstType::Intersect(expected_type, AstType::NonNumber(), zone());
+ AstType* expected_number =
+ AstType::Intersect(expected_type, AstType::Number(), zone());
// We expect to get a number.
- // (We need to check first, since Type::None->Is(Type::Any()) == true.
- if (expected_obj->Is(Type::None())) {
- DCHECK(!expected_number->Is(Type::None()));
+ // (We need to check first, since AstType::None->Is(AstType::Any()) == true.
+ if (expected_obj->Is(AstType::None())) {
+ DCHECK(!expected_number->Is(AstType::None()));
return value;
}
- if (expected_obj->Is(Type::Undefined())) {
+ if (expected_obj->Is(AstType::Undefined())) {
// This is already done by HChange.
- *expected = Type::Union(expected_number, Type::Number(), zone());
+ *expected = AstType::Union(expected_number, AstType::Number(), zone());
return value;
}
@@ -10962,9 +10957,9 @@ HValue* HOptimizedGraphBuilder::BuildBinaryOperation(
HValue* left,
HValue* right,
PushBeforeSimulateBehavior push_sim_result) {
- Type* left_type = bounds_.get(expr->left()).lower;
- Type* right_type = bounds_.get(expr->right()).lower;
- Type* result_type = bounds_.get(expr).lower;
+ AstType* left_type = bounds_.get(expr->left()).lower;
+ AstType* right_type = bounds_.get(expr->right()).lower;
+ AstType* result_type = bounds_.get(expr).lower;
Maybe<int> fixed_right_arg = expr->fixed_right_arg();
Handle<AllocationSite> allocation_site = expr->allocation_site();
@@ -10990,12 +10985,10 @@ HValue* HOptimizedGraphBuilder::BuildBinaryOperation(
return result;
}
-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,
- BailoutId opt_id) {
+HValue* HGraphBuilder::BuildBinaryOperation(
+ Token::Value op, HValue* left, HValue* right, AstType* left_type,
+ AstType* right_type, AstType* result_type, Maybe<int> fixed_right_arg,
+ HAllocationMode allocation_mode, BailoutId opt_id) {
bool maybe_string_add = false;
if (op == Token::ADD) {
// If we are adding constant string with something for which we don't have
@@ -11003,18 +10996,18 @@ HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left,
// generate deopt instructions.
if (!left_type->IsInhabited() && right->IsConstant() &&
HConstant::cast(right)->HasStringValue()) {
- left_type = Type::String();
+ left_type = AstType::String();
}
if (!right_type->IsInhabited() && left->IsConstant() &&
HConstant::cast(left)->HasStringValue()) {
- right_type = Type::String();
+ right_type = AstType::String();
}
- maybe_string_add = (left_type->Maybe(Type::String()) ||
- left_type->Maybe(Type::Receiver()) ||
- right_type->Maybe(Type::String()) ||
- right_type->Maybe(Type::Receiver()));
+ maybe_string_add = (left_type->Maybe(AstType::String()) ||
+ left_type->Maybe(AstType::Receiver()) ||
+ right_type->Maybe(AstType::String()) ||
+ right_type->Maybe(AstType::Receiver()));
}
Representation left_rep = RepresentationFor(left_type);
@@ -11024,7 +11017,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left,
Add<HDeoptimize>(
DeoptimizeReason::kInsufficientTypeFeedbackForLHSOfBinaryOperation,
Deoptimizer::SOFT);
- left_type = Type::Any();
+ left_type = AstType::Any();
left_rep = RepresentationFor(left_type);
maybe_string_add = op == Token::ADD;
}
@@ -11033,7 +11026,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left,
Add<HDeoptimize>(
DeoptimizeReason::kInsufficientTypeFeedbackForRHSOfBinaryOperation,
Deoptimizer::SOFT);
- right_type = Type::Any();
+ right_type = AstType::Any();
right_rep = RepresentationFor(right_type);
maybe_string_add = op == Token::ADD;
}
@@ -11045,34 +11038,34 @@ HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left,
// Special case for string addition here.
if (op == Token::ADD &&
- (left_type->Is(Type::String()) || right_type->Is(Type::String()))) {
+ (left_type->Is(AstType::String()) || right_type->Is(AstType::String()))) {
// Validate type feedback for left argument.
- if (left_type->Is(Type::String())) {
+ if (left_type->Is(AstType::String())) {
left = BuildCheckString(left);
}
// Validate type feedback for right argument.
- if (right_type->Is(Type::String())) {
+ if (right_type->Is(AstType::String())) {
right = BuildCheckString(right);
}
// Convert left argument as necessary.
- if (left_type->Is(Type::Number())) {
- DCHECK(right_type->Is(Type::String()));
+ if (left_type->Is(AstType::Number())) {
+ DCHECK(right_type->Is(AstType::String()));
left = BuildNumberToString(left, left_type);
- } else if (!left_type->Is(Type::String())) {
- DCHECK(right_type->Is(Type::String()));
+ } else if (!left_type->Is(AstType::String())) {
+ DCHECK(right_type->Is(AstType::String()));
return AddUncasted<HStringAdd>(
left, right, allocation_mode.GetPretenureMode(),
STRING_ADD_CONVERT_LEFT, allocation_mode.feedback_site());
}
// Convert right argument as necessary.
- if (right_type->Is(Type::Number())) {
- DCHECK(left_type->Is(Type::String()));
+ if (right_type->Is(AstType::Number())) {
+ DCHECK(left_type->Is(AstType::String()));
right = BuildNumberToString(right, right_type);
- } else if (!right_type->Is(Type::String())) {
- DCHECK(left_type->Is(Type::String()));
+ } else if (!right_type->Is(AstType::String())) {
+ DCHECK(left_type->Is(AstType::String()));
return AddUncasted<HStringAdd>(
left, right, allocation_mode.GetPretenureMode(),
STRING_ADD_CONVERT_RIGHT, allocation_mode.feedback_site());
@@ -11230,8 +11223,8 @@ HValue* HGraphBuilder::BuildBinaryOperation(Token::Value op, HValue* left,
break;
case Token::BIT_OR: {
HValue *operand, *shift_amount;
- if (left_type->Is(Type::Signed32()) &&
- right_type->Is(Type::Signed32()) &&
+ if (left_type->Is(AstType::Signed32()) &&
+ right_type->Is(AstType::Signed32()) &&
MatchRotateRight(left, right, &operand, &shift_amount)) {
instr = AddUncasted<HRor>(operand, shift_amount);
} else {
@@ -11503,9 +11496,9 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
return ast_context()->ReturnControl(instr, expr->id());
}
- Type* left_type = bounds_.get(expr->left()).lower;
- Type* right_type = bounds_.get(expr->right()).lower;
- Type* combined_type = expr->combined_type();
+ AstType* left_type = bounds_.get(expr->left()).lower;
+ AstType* right_type = bounds_.get(expr->right()).lower;
+ AstType* combined_type = expr->combined_type();
CHECK_ALIVE(VisitForValue(expr->left()));
CHECK_ALIVE(VisitForValue(expr->right()));
@@ -11577,10 +11570,9 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
return ast_context()->ReturnControl(compare, expr->id());
}
-
HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
- Token::Value op, HValue* left, HValue* right, Type* left_type,
- Type* right_type, Type* combined_type, SourcePosition left_position,
+ Token::Value op, HValue* left, HValue* right, AstType* left_type,
+ AstType* right_type, AstType* combined_type, SourcePosition left_position,
SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result,
BailoutId bailout_id) {
// Cases handled below depend on collected type feedback. They should
@@ -11590,14 +11582,14 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
DeoptimizeReason::
kInsufficientTypeFeedbackForCombinedTypeOfBinaryOperation,
Deoptimizer::SOFT);
- combined_type = left_type = right_type = Type::Any();
+ combined_type = left_type = right_type = AstType::Any();
}
Representation left_rep = RepresentationFor(left_type);
Representation right_rep = RepresentationFor(right_type);
Representation combined_rep = RepresentationFor(combined_type);
- if (combined_type->Is(Type::Receiver())) {
+ if (combined_type->Is(AstType::Receiver())) {
if (Token::IsEqualityOp(op)) {
// HCompareObjectEqAndBranch can only deal with object, so
// exclude numbers.
@@ -11681,7 +11673,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
Bailout(kUnsupportedNonPrimitiveCompare);
return NULL;
}
- } else if (combined_type->Is(Type::InternalizedString()) &&
+ } else if (combined_type->Is(AstType::InternalizedString()) &&
Token::IsEqualityOp(op)) {
// If we have a constant argument, it should be consistent with the type
// feedback (otherwise we fail assertions in HCompareObjectEqAndBranch).
@@ -11702,7 +11694,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
HCompareObjectEqAndBranch* result =
New<HCompareObjectEqAndBranch>(left, right);
return result;
- } else if (combined_type->Is(Type::String())) {
+ } else if (combined_type->Is(AstType::String())) {
BuildCheckHeapObject(left);
Add<HCheckInstanceType>(left, HCheckInstanceType::IS_STRING);
BuildCheckHeapObject(right);
@@ -11710,7 +11702,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
HStringCompareAndBranch* result =
New<HStringCompareAndBranch>(left, right, op);
return result;
- } else if (combined_type->Is(Type::Boolean())) {
+ } else if (combined_type->Is(AstType::Boolean())) {
AddCheckMap(left, isolate()->factory()->boolean_map());
AddCheckMap(right, isolate()->factory()->boolean_map());
if (Token::IsEqualityOp(op)) {
@@ -12515,7 +12507,7 @@ void HOptimizedGraphBuilder::GenerateNumberToString(CallRuntime* call) {
DCHECK_EQ(1, call->arguments()->length());
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* number = Pop();
- HValue* result = BuildNumberToString(number, Type::Any());
+ HValue* result = BuildNumberToString(number, AstType::Any());
return ast_context()->ReturnValue(result);
}
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | src/crankshaft/hydrogen-types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698