From b7c0b738c78bd30ab074a0954329a5101a42dae8 Mon Sep 17 00:00:00 2001 From: "whesse@chromium.org" Date: Fri, 30 Oct 2009 11:32:42 +0000 Subject: [PATCH] Add void operator to fast compiler. Review URL: http://codereview.chromium.org/342055 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3186 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/fast-codegen-arm.cc | 26 ++++++++++++++++++++++++++ src/compiler.cc | 8 +++++++- src/fast-codegen.cc | 5 ----- src/ia32/fast-codegen-ia32.cc | 25 +++++++++++++++++++++++++ src/x64/fast-codegen-x64.cc | 25 +++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 6 deletions(-) diff --git a/src/arm/fast-codegen-arm.cc b/src/arm/fast-codegen-arm.cc index 3871d1ba8..ebf15aad5 100644 --- a/src/arm/fast-codegen-arm.cc +++ b/src/arm/fast-codegen-arm.cc @@ -723,6 +723,32 @@ void FastCodeGenerator::VisitCallRuntime(CallRuntime* expr) { } +void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { + Comment cmnt(masm_, "[ UnaryOperation"); + + switch (expr->op()) { + case Token::VOID: + Visit(expr->expression()); + ASSERT_EQ(Expression::kEffect, expr->expression()->context()); + switch (expr->context()) { + case Expression::kUninitialized: + UNREACHABLE(); + break; + case Expression::kValue: + __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); + __ push(ip); + break; + case Expression::kEffect: + break; + } + break; + + default: + UNREACHABLE(); + } +} + + void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { switch (expr->op()) { case Token::COMMA: diff --git a/src/compiler.cc b/src/compiler.cc index d8168ec5c..38a41a2ba 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -825,7 +825,13 @@ void CodeGenSelector::VisitCallRuntime(CallRuntime* expr) { void CodeGenSelector::VisitUnaryOperation(UnaryOperation* expr) { - BAILOUT("UnaryOperation"); + switch (expr->op()) { + case Token::VOID: + ProcessExpression(expr->expression(), Expression::kEffect); + break; + default: + BAILOUT("UnaryOperation"); + } } diff --git a/src/fast-codegen.cc b/src/fast-codegen.cc index 551ffab93..397fe3409 100644 --- a/src/fast-codegen.cc +++ b/src/fast-codegen.cc @@ -324,11 +324,6 @@ void FastCodeGenerator::VisitThrow(Throw* expr) { } -void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { - UNREACHABLE(); -} - - void FastCodeGenerator::VisitCountOperation(CountOperation* expr) { UNREACHABLE(); } diff --git a/src/ia32/fast-codegen-ia32.cc b/src/ia32/fast-codegen-ia32.cc index 6a19ae36b..01f8bd499 100644 --- a/src/ia32/fast-codegen-ia32.cc +++ b/src/ia32/fast-codegen-ia32.cc @@ -729,6 +729,31 @@ void FastCodeGenerator::VisitCallRuntime(CallRuntime* expr) { } +void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { + Comment cmnt(masm_, "[ UnaryOperation"); + + switch (expr->op()) { + case Token::VOID: + Visit(expr->expression()); + ASSERT_EQ(Expression::kEffect, expr->expression()->context()); + switch (expr->context()) { + case Expression::kUninitialized: + UNREACHABLE(); + break; + case Expression::kValue: + __ push(Immediate(Factory::undefined_value())); + break; + case Expression::kEffect: + break; + } + break; + + default: + UNREACHABLE(); + } +} + + void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { switch (expr->op()) { case Token::COMMA: diff --git a/src/x64/fast-codegen-x64.cc b/src/x64/fast-codegen-x64.cc index 4bbb42d43..5ea11fc22 100644 --- a/src/x64/fast-codegen-x64.cc +++ b/src/x64/fast-codegen-x64.cc @@ -741,6 +741,31 @@ void FastCodeGenerator::VisitCallRuntime(CallRuntime* expr) { } +void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { + Comment cmnt(masm_, "[ UnaryOperation"); + + switch (expr->op()) { + case Token::VOID: + Visit(expr->expression()); + ASSERT_EQ(Expression::kEffect, expr->expression()->context()); + switch (expr->context()) { + case Expression::kUninitialized: + UNREACHABLE(); + break; + case Expression::kValue: + __ PushRoot(Heap::kUndefinedValueRootIndex); + break; + case Expression::kEffect: + break; + } + break; + + default: + UNREACHABLE(); + } +} + + void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { switch (expr->op()) { case Token::COMMA: -- 2.34.1