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

Side by Side Diff: src/hydrogen.cc

Issue 19518008: Merged r15610, r15723, r15724, r15725, r15728 into 3.18 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.18
Patch Set: Created 7 years, 5 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
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 10347 matching lines...) Expand 10 before | Expand all | Expand 10 after
10358 if (info.IsUninitialized()) return Representation::None(); 10358 if (info.IsUninitialized()) return Representation::None();
10359 if (info.IsSmi()) return Representation::Integer32(); 10359 if (info.IsSmi()) return Representation::Integer32();
10360 if (info.IsInteger32()) return Representation::Integer32(); 10360 if (info.IsInteger32()) return Representation::Integer32();
10361 if (info.IsDouble()) return Representation::Double(); 10361 if (info.IsDouble()) return Representation::Double();
10362 if (info.IsNumber()) return Representation::Double(); 10362 if (info.IsNumber()) return Representation::Double();
10363 return Representation::Tagged(); 10363 return Representation::Tagged();
10364 } 10364 }
10365 10365
10366 10366
10367 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, 10367 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr,
10368 HTypeof* typeof_expr, 10368 Expression* sub_expr,
10369 Handle<String> check) { 10369 Handle<String> check) {
10370 // Note: The HTypeof itself is removed during canonicalization, if possible. 10370 CHECK_ALIVE(VisitForTypeOf(sub_expr));
10371 HValue* value = typeof_expr->value(); 10371 HValue* value = Pop();
10372 HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check); 10372 HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check);
10373 instr->set_position(expr->position()); 10373 instr->set_position(expr->position());
10374 return ast_context()->ReturnControl(instr, expr->id()); 10374 return ast_context()->ReturnControl(instr, expr->id());
10375 } 10375 }
10376 10376
10377 10377
10378 static bool MatchLiteralCompareNil(HValue* left,
10379 Token::Value op,
10380 HValue* right,
10381 Handle<Object> nil,
10382 HValue** expr) {
10383 if (left->IsConstant() &&
10384 HConstant::cast(left)->handle().is_identical_to(nil) &&
10385 Token::IsEqualityOp(op)) {
10386 *expr = right;
10387 return true;
10388 }
10389 return false;
10390 }
10391
10392
10393 static bool MatchLiteralCompareTypeof(HValue* left,
10394 Token::Value op,
10395 HValue* right,
10396 HTypeof** typeof_expr,
10397 Handle<String>* check) {
10398 if (left->IsTypeof() &&
10399 Token::IsEqualityOp(op) &&
10400 right->IsConstant() &&
10401 HConstant::cast(right)->handle()->IsString()) {
10402 *typeof_expr = HTypeof::cast(left);
10403 *check = Handle<String>::cast(HConstant::cast(right)->handle());
10404 return true;
10405 }
10406 return false;
10407 }
10408
10409
10410 static bool IsLiteralCompareTypeof(HValue* left,
10411 Token::Value op,
10412 HValue* right,
10413 HTypeof** typeof_expr,
10414 Handle<String>* check) {
10415 return MatchLiteralCompareTypeof(left, op, right, typeof_expr, check) ||
10416 MatchLiteralCompareTypeof(right, op, left, typeof_expr, check);
10417 }
10418
10419
10420 static bool IsLiteralCompareNil(HValue* left,
10421 Token::Value op,
10422 HValue* right,
10423 Handle<Object> nil,
10424 HValue** expr) {
10425 return MatchLiteralCompareNil(left, op, right, nil, expr) ||
10426 MatchLiteralCompareNil(right, op, left, nil, expr);
10427 }
10428
10429
10430 static bool IsLiteralCompareBool(HValue* left, 10378 static bool IsLiteralCompareBool(HValue* left,
10431 Token::Value op, 10379 Token::Value op,
10432 HValue* right) { 10380 HValue* right) {
10433 return op == Token::EQ_STRICT && 10381 return op == Token::EQ_STRICT &&
10434 ((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) || 10382 ((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) ||
10435 (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean())); 10383 (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean()));
10436 } 10384 }
10437 10385
10438 10386
10439 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { 10387 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
10440 ASSERT(!HasStackOverflow()); 10388 ASSERT(!HasStackOverflow());
10441 ASSERT(current_block() != NULL); 10389 ASSERT(current_block() != NULL);
10442 ASSERT(current_block()->HasPredecessor()); 10390 ASSERT(current_block()->HasPredecessor());
10391
10392 // Check for a few fast cases. The AST visiting behavior must be in sync
10393 // with the full codegen: We don't push both left and right values onto
10394 // the expression stack when one side is a special-case literal.
10395 Expression* sub_expr = NULL;
10396 Handle<String> check;
10397 if (expr->IsLiteralCompareTypeof(&sub_expr, &check)) {
10398 return HandleLiteralCompareTypeof(expr, sub_expr, check);
10399 }
10400 if (expr->IsLiteralCompareUndefined(&sub_expr, isolate())) {
10401 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue);
10402 }
10403 if (expr->IsLiteralCompareNull(&sub_expr)) {
10404 return HandleLiteralCompareNil(expr, sub_expr, kNullValue);
10405 }
10406
10443 if (IsClassOfTest(expr)) { 10407 if (IsClassOfTest(expr)) {
10444 CallRuntime* call = expr->left()->AsCallRuntime(); 10408 CallRuntime* call = expr->left()->AsCallRuntime();
10445 ASSERT(call->arguments()->length() == 1); 10409 ASSERT(call->arguments()->length() == 1);
10446 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 10410 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
10447 HValue* value = Pop(); 10411 HValue* value = Pop();
10448 Literal* literal = expr->right()->AsLiteral(); 10412 Literal* literal = expr->right()->AsLiteral();
10449 Handle<String> rhs = Handle<String>::cast(literal->handle()); 10413 Handle<String> rhs = Handle<String>::cast(literal->handle());
10450 HClassOfTestAndBranch* instr = 10414 HClassOfTestAndBranch* instr =
10451 new(zone()) HClassOfTestAndBranch(value, rhs); 10415 new(zone()) HClassOfTestAndBranch(value, rhs);
10452 instr->set_position(expr->position()); 10416 instr->set_position(expr->position());
(...skipping 13 matching lines...) Expand all
10466 } 10430 }
10467 10431
10468 CHECK_ALIVE(VisitForValue(expr->left())); 10432 CHECK_ALIVE(VisitForValue(expr->left()));
10469 CHECK_ALIVE(VisitForValue(expr->right())); 10433 CHECK_ALIVE(VisitForValue(expr->right()));
10470 10434
10471 HValue* context = environment()->LookupContext(); 10435 HValue* context = environment()->LookupContext();
10472 HValue* right = Pop(); 10436 HValue* right = Pop();
10473 HValue* left = Pop(); 10437 HValue* left = Pop();
10474 Token::Value op = expr->op(); 10438 Token::Value op = expr->op();
10475 10439
10476 HTypeof* typeof_expr = NULL;
10477 Handle<String> check;
10478 if (IsLiteralCompareTypeof(left, op, right, &typeof_expr, &check)) {
10479 return HandleLiteralCompareTypeof(expr, typeof_expr, check);
10480 }
10481 HValue* sub_expr = NULL;
10482 Factory* f = isolate()->factory();
10483 if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) {
10484 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue);
10485 }
10486 if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) {
10487 return HandleLiteralCompareNil(expr, sub_expr, kNullValue);
10488 }
10489 if (IsLiteralCompareBool(left, op, right)) { 10440 if (IsLiteralCompareBool(left, op, right)) {
10490 HCompareObjectEqAndBranch* result = 10441 HCompareObjectEqAndBranch* result =
10491 new(zone()) HCompareObjectEqAndBranch(left, right); 10442 new(zone()) HCompareObjectEqAndBranch(left, right);
10492 result->set_position(expr->position()); 10443 result->set_position(expr->position());
10493 return ast_context()->ReturnControl(result, expr->id()); 10444 return ast_context()->ReturnControl(result, expr->id());
10494 } 10445 }
10495 10446
10496 if (op == Token::INSTANCEOF) { 10447 if (op == Token::INSTANCEOF) {
10497 // Check to see if the rhs of the instanceof is a global function not 10448 // Check to see if the rhs of the instanceof is a global function not
10498 // residing in new space. If it is we assume that the function will stay the 10449 // residing in new space. If it is we assume that the function will stay the
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
10584 new(zone()) HCompareIDAndBranch(left, right, op); 10535 new(zone()) HCompareIDAndBranch(left, right, op);
10585 result->set_observed_input_representation(left_rep, right_rep); 10536 result->set_observed_input_representation(left_rep, right_rep);
10586 result->set_position(expr->position()); 10537 result->set_position(expr->position());
10587 return ast_context()->ReturnControl(result, expr->id()); 10538 return ast_context()->ReturnControl(result, expr->id());
10588 } 10539 }
10589 } 10540 }
10590 } 10541 }
10591 10542
10592 10543
10593 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, 10544 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr,
10594 HValue* value, 10545 Expression* sub_expr,
10595 NilValue nil) { 10546 NilValue nil) {
10596 ASSERT(!HasStackOverflow()); 10547 ASSERT(!HasStackOverflow());
10597 ASSERT(current_block() != NULL); 10548 ASSERT(current_block() != NULL);
10598 ASSERT(current_block()->HasPredecessor()); 10549 ASSERT(current_block()->HasPredecessor());
10550 CHECK_ALIVE(VisitForValue(sub_expr));
10551 HValue* value = Pop();
10599 EqualityKind kind = 10552 EqualityKind kind =
10600 expr->op() == Token::EQ_STRICT ? kStrictEquality : kNonStrictEquality; 10553 expr->op() == Token::EQ_STRICT ? kStrictEquality : kNonStrictEquality;
10601 HIfContinuation continuation; 10554 HIfContinuation continuation;
10602 TypeFeedbackId id = expr->CompareOperationFeedbackId(); 10555 TypeFeedbackId id = expr->CompareOperationFeedbackId();
10603 CompareNilICStub::Types types; 10556 CompareNilICStub::Types types;
10604 if (kind == kStrictEquality) { 10557 if (kind == kStrictEquality) {
10605 if (nil == kNullValue) { 10558 if (nil == kNullValue) {
10606 types = CompareNilICStub::kCompareAgainstNull; 10559 types = CompareNilICStub::kCompareAgainstNull;
10607 } else { 10560 } else {
10608 types = CompareNilICStub::kCompareAgainstUndefined; 10561 types = CompareNilICStub::kCompareAgainstUndefined;
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
12225 } 12178 }
12226 } 12179 }
12227 12180
12228 #ifdef DEBUG 12181 #ifdef DEBUG
12229 if (graph_ != NULL) graph_->Verify(false); // No full verify. 12182 if (graph_ != NULL) graph_->Verify(false); // No full verify.
12230 if (allocator_ != NULL) allocator_->Verify(); 12183 if (allocator_ != NULL) allocator_->Verify();
12231 #endif 12184 #endif
12232 } 12185 }
12233 12186
12234 } } // namespace v8::internal 12187 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698