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

Side by Side Diff: src/hydrogen.cc

Issue 22184004: Desugar bitwise negation into XOR and kill all UnaryOp stuff. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, 1710 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant,
1711 static_cast<HValue*>(NULL), kind); 1711 static_cast<HValue*>(NULL), kind);
1712 Add<HStoreKeyed>(object_elements, key_constant, value, kind); 1712 Add<HStoreKeyed>(object_elements, key_constant, value, kind);
1713 } 1713 }
1714 } 1714 }
1715 1715
1716 return object; 1716 return object;
1717 } 1717 }
1718 1718
1719 1719
1720 HInstruction* HGraphBuilder::BuildUnaryMathOp(
1721 HValue* input, Handle<Type> type, Token::Value operation) {
1722 ASSERT_EQ(Token::BIT_NOT, operation);
1723 // We only handle the numeric cases here
1724 type = handle(
1725 Type::Intersect(type, handle(Type::Number(), isolate())), isolate());
1726 if (type->Is(Type::None())) {
1727 Add<HDeoptimize>(Deoptimizer::SOFT);
1728 }
1729 return New<HBitNot>(input);
1730 }
1731
1732
1733 void HGraphBuilder::BuildCompareNil( 1720 void HGraphBuilder::BuildCompareNil(
1734 HValue* value, 1721 HValue* value,
1735 Handle<Type> type, 1722 Handle<Type> type,
1736 int position, 1723 int position,
1737 HIfContinuation* continuation) { 1724 HIfContinuation* continuation) {
1738 IfBuilder if_nil(this, position); 1725 IfBuilder if_nil(this, position);
1739 bool needs_or = false; 1726 bool needs_or = false;
1740 if (type->Maybe(Type::Null())) { 1727 if (type->Maybe(Type::Null())) {
1741 if (needs_or) if_nil.Or(); 1728 if (needs_or) if_nil.Or();
1742 if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull()); 1729 if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull());
(...skipping 5477 matching lines...) Expand 10 before | Expand all | Expand 10 after
7220 7207
7221 7208
7222 void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { 7209 void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) {
7223 ASSERT(!HasStackOverflow()); 7210 ASSERT(!HasStackOverflow());
7224 ASSERT(current_block() != NULL); 7211 ASSERT(current_block() != NULL);
7225 ASSERT(current_block()->HasPredecessor()); 7212 ASSERT(current_block()->HasPredecessor());
7226 switch (expr->op()) { 7213 switch (expr->op()) {
7227 case Token::DELETE: return VisitDelete(expr); 7214 case Token::DELETE: return VisitDelete(expr);
7228 case Token::VOID: return VisitVoid(expr); 7215 case Token::VOID: return VisitVoid(expr);
7229 case Token::TYPEOF: return VisitTypeof(expr); 7216 case Token::TYPEOF: return VisitTypeof(expr);
7230 case Token::BIT_NOT: return VisitBitNot(expr);
7231 case Token::NOT: return VisitNot(expr); 7217 case Token::NOT: return VisitNot(expr);
7232 default: UNREACHABLE(); 7218 default: UNREACHABLE();
7233 } 7219 }
7234 } 7220 }
7235 7221
7236 7222
7237 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { 7223 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) {
7238 Property* prop = expr->expression()->AsProperty(); 7224 Property* prop = expr->expression()->AsProperty();
7239 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 7225 VariableProxy* proxy = expr->expression()->AsVariableProxy();
7240 if (prop != NULL) { 7226 if (prop != NULL) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
7282 7268
7283 void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) { 7269 void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) {
7284 CHECK_ALIVE(VisitForTypeOf(expr->expression())); 7270 CHECK_ALIVE(VisitForTypeOf(expr->expression()));
7285 HValue* value = Pop(); 7271 HValue* value = Pop();
7286 HValue* context = environment()->context(); 7272 HValue* context = environment()->context();
7287 HInstruction* instr = new(zone()) HTypeof(context, value); 7273 HInstruction* instr = new(zone()) HTypeof(context, value);
7288 return ast_context()->ReturnInstruction(instr, expr->id()); 7274 return ast_context()->ReturnInstruction(instr, expr->id());
7289 } 7275 }
7290 7276
7291 7277
7292 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) {
7293 CHECK_ALIVE(VisitForValue(expr->expression()));
7294 Handle<Type> operand_type = expr->expression()->bounds().lower;
7295 HValue* value = TruncateToNumber(Pop(), &operand_type);
7296 HInstruction* instr = BuildUnaryMathOp(value, operand_type, Token::BIT_NOT);
7297 return ast_context()->ReturnInstruction(instr, expr->id());
7298 }
7299
7300
7301 void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) { 7278 void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) {
7302 if (ast_context()->IsTest()) { 7279 if (ast_context()->IsTest()) {
7303 TestContext* context = TestContext::cast(ast_context()); 7280 TestContext* context = TestContext::cast(ast_context());
7304 VisitForControl(expr->expression(), 7281 VisitForControl(expr->expression(),
7305 context->if_false(), 7282 context->if_false(),
7306 context->if_true()); 7283 context->if_true());
7307 return; 7284 return;
7308 } 7285 }
7309 7286
7310 if (ast_context()->IsEffect()) { 7287 if (ast_context()->IsEffect()) {
(...skipping 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after
9727 if (ShouldProduceTraceOutput()) { 9704 if (ShouldProduceTraceOutput()) {
9728 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9705 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9729 } 9706 }
9730 9707
9731 #ifdef DEBUG 9708 #ifdef DEBUG
9732 graph_->Verify(false); // No full verify. 9709 graph_->Verify(false); // No full verify.
9733 #endif 9710 #endif
9734 } 9711 }
9735 9712
9736 } } // namespace v8::internal 9713 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | src/hydrogen-uint32-analysis.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698