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

Unified Diff: src/hydrogen.cc

Issue 17229005: Convert UnaryOpStub to a HydrogenCodeStub (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: add some duckt tape for now to fix non-sse Created 7 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
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index a0133e41c4b3dd5b0f17535956ef04b46c734bd3..dd31c267306e8ce04a1501ea2cbc5acb8765722d 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1008,6 +1008,35 @@ HReturn* HGraphBuilder::AddReturn(HValue* value) {
}
+void HGraphBuilder::AddSoftDeoptimize() {
+ if (FLAG_always_opt) return;
+ if (current_block()->IsDeoptimizing()) return;
+ AddInstruction(new(zone()) HSoftDeoptimize());
+ current_block()->MarkAsDeoptimizing();
+ graph()->set_has_soft_deoptimize(true);
+}
+
+
+// TODO(rossberg): this should die eventually.
+Representation HGraphBuilder::ToRepresentation(TypeInfo info) {
+ if (info.IsUninitialized()) return Representation::None();
+ // TODO(verwaest): Return Smi rather than Integer32.
+ if (info.IsSmi()) return Representation::Integer32();
+ if (info.IsInteger32()) return Representation::Integer32();
+ if (info.IsDouble()) return Representation::Double();
+ if (info.IsNumber()) return Representation::Double();
+ return Representation::Tagged();
+}
+
+
+Representation HGraphBuilder::ToRepresentation(Handle<Type> type) {
+ if (type->Is(Type::None())) return Representation::None();
+ if (type->Is(Type::Integer32())) return Representation::Integer32();
+ if (type->Is(Type::Number())) return Representation::Double();
+ return Representation::Tagged();
+}
+
+
HBasicBlock* HGraphBuilder::CreateBasicBlock(HEnvironment* env) {
HBasicBlock* b = graph()->CreateBasicBlock();
b->SetInitialEnvironment(env);
@@ -1678,6 +1707,31 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context,
}
+HInstruction* HGraphBuilder::BuildSub(
+ HValue* value, Handle<Type> type, HValue* context) {
+ HInstruction* instr =
+ HMul::New(zone(), context, value, graph()->GetConstantMinus1());
+ Representation rep = ToRepresentation(type);
+ if (type->Is(Type::None())) {
+ AddSoftDeoptimize();
+ type = handle(Type::Any(), isolate());
+ }
+ if (instr->IsBinaryOperation()) {
+ HBinaryOperation::cast(instr)->set_observed_input_representation(1, rep);
+ HBinaryOperation::cast(instr)->set_observed_input_representation(2, rep);
+ }
+ return instr;
+}
+
+
+HInstruction* HGraphBuilder::BuildBitNot(HValue* value, Handle<Type> type) {
+ if (type->Is(Type::None())) {
+ AddSoftDeoptimize();
+ }
+ return new(zone()) HBitNot(value);
+}
+
+
void HGraphBuilder::BuildCompareNil(
HValue* value,
Handle<Type> type,
@@ -4663,15 +4717,6 @@ void HOptimizedGraphBuilder::PushAndAdd(HInstruction* instr) {
}
-void HOptimizedGraphBuilder::AddSoftDeoptimize() {
- if (FLAG_always_opt) return;
- if (current_block()->IsDeoptimizing()) return;
- AddInstruction(new(zone()) HSoftDeoptimize());
- current_block()->MarkAsDeoptimizing();
- graph()->set_has_soft_deoptimize(true);
-}
-
-
template <class Instruction>
HInstruction* HOptimizedGraphBuilder::PreProcessCall(Instruction* call) {
int count = call->argument_count();
@@ -9032,18 +9077,8 @@ void HOptimizedGraphBuilder::VisitSub(UnaryOperation* expr) {
CHECK_ALIVE(VisitForValue(expr->expression()));
HValue* value = Pop();
HValue* context = environment()->LookupContext();
- HInstruction* instr =
- HMul::New(zone(), context, value, graph()->GetConstantMinus1());
Handle<Type> type = expr->type();
- Representation rep = ToRepresentation(type);
- if (type->Is(Type::None())) {
- AddSoftDeoptimize();
- type = handle(Type::Any(), isolate());
- }
- if (instr->IsBinaryOperation()) {
- HBinaryOperation::cast(instr)->set_observed_input_representation(1, rep);
- HBinaryOperation::cast(instr)->set_observed_input_representation(2, rep);
- }
+ HInstruction* instr = BuildSub(value, type, context);
return ast_context()->ReturnInstruction(instr, expr->id());
}
@@ -9052,10 +9087,7 @@ void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) {
CHECK_ALIVE(VisitForValue(expr->expression()));
HValue* value = Pop();
Handle<Type> info = expr->type();
- if (info->Is(Type::None())) {
- AddSoftDeoptimize();
- }
- HInstruction* instr = new(zone()) HBitNot(value);
+ HInstruction* instr = BuildBitNot(value, info);
return ast_context()->ReturnInstruction(instr, expr->id());
}
@@ -9654,26 +9686,6 @@ void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) {
}
-// TODO(rossberg): this should die eventually.
-Representation HOptimizedGraphBuilder::ToRepresentation(TypeInfo info) {
- if (info.IsUninitialized()) return Representation::None();
- // TODO(verwaest): Return Smi rather than Integer32.
- if (info.IsSmi()) return Representation::Integer32();
- if (info.IsInteger32()) return Representation::Integer32();
- if (info.IsDouble()) return Representation::Double();
- if (info.IsNumber()) return Representation::Double();
- return Representation::Tagged();
-}
-
-
-Representation HOptimizedGraphBuilder::ToRepresentation(Handle<Type> type) {
- if (type->Is(Type::None())) return Representation::None();
- if (type->Is(Type::Integer32())) return Representation::Integer32();
- if (type->Is(Type::Number())) return Representation::Double();
- return Representation::Tagged();
-}
-
-
void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr,
HTypeof* typeof_expr,
Handle<String> check) {

Powered by Google App Engine
This is Rietveld 408576698