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

Side by Side Diff: src/hydrogen.cc

Issue 10544196: Defer creating Handles for HConstants to the code generation phase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review Created 8 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/hydrogen-instructions.h » ('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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 if (!pointer->is_set()) { 572 if (!pointer->is_set()) {
573 HConstant* constant = new(zone()) HConstant(value, 573 HConstant* constant = new(zone()) HConstant(value,
574 Representation::Tagged()); 574 Representation::Tagged());
575 constant->InsertAfter(GetConstantUndefined()); 575 constant->InsertAfter(GetConstantUndefined());
576 pointer->set(constant); 576 pointer->set(constant);
577 } 577 }
578 return pointer->get(); 578 return pointer->get();
579 } 579 }
580 580
581 581
582 HConstant* HGraph::GetConstantInt32(SetOncePointer<HConstant>* pointer,
583 int32_t value) {
584 if (!pointer->is_set()) {
585 HConstant* constant =
586 new(zone()) HConstant(value, Representation::Integer32());
587 constant->InsertAfter(GetConstantUndefined());
588 pointer->set(constant);
589 }
590 return pointer->get();
591 }
592
593
582 HConstant* HGraph::GetConstant1() { 594 HConstant* HGraph::GetConstant1() {
583 return GetConstant(&constant_1_, Handle<Smi>(Smi::FromInt(1))); 595 return GetConstantInt32(&constant_1_, 1);
584 } 596 }
585 597
586 598
587 HConstant* HGraph::GetConstantMinus1() { 599 HConstant* HGraph::GetConstantMinus1() {
588 return GetConstant(&constant_minus1_, Handle<Smi>(Smi::FromInt(-1))); 600 return GetConstantInt32(&constant_minus1_, -1);
589 } 601 }
590 602
591 603
592 HConstant* HGraph::GetConstantTrue() { 604 HConstant* HGraph::GetConstantTrue() {
593 return GetConstant(&constant_true_, isolate()->factory()->true_value()); 605 return GetConstant(&constant_true_, isolate()->factory()->true_value());
594 } 606 }
595 607
596 608
597 HConstant* HGraph::GetConstantFalse() { 609 HConstant* HGraph::GetConstantFalse() {
598 return GetConstant(&constant_false_, isolate()->factory()->false_value()); 610 return GetConstant(&constant_false_, isolate()->factory()->false_value());
(...skipping 2772 matching lines...) Expand 10 before | Expand all | Expand 10 after
3371 BoundsCheckBbData* next_in_bb_; 3383 BoundsCheckBbData* next_in_bb_;
3372 BoundsCheckBbData* father_in_dt_; 3384 BoundsCheckBbData* father_in_dt_;
3373 3385
3374 void BuildOffsetAdd(HBoundsCheck* check, 3386 void BuildOffsetAdd(HBoundsCheck* check,
3375 HAdd** add, 3387 HAdd** add,
3376 HConstant** constant, 3388 HConstant** constant,
3377 HValue* original_value, 3389 HValue* original_value,
3378 Representation representation, 3390 Representation representation,
3379 int32_t new_offset) { 3391 int32_t new_offset) {
3380 HConstant* new_constant = new(BasicBlock()->zone()) 3392 HConstant* new_constant = new(BasicBlock()->zone())
3381 HConstant(Handle<Object>(Smi::FromInt(new_offset)), 3393 HConstant(new_offset, Representation::Integer32());
3382 Representation::Integer32());
3383 if (*add == NULL) { 3394 if (*add == NULL) {
3384 new_constant->InsertBefore(check); 3395 new_constant->InsertBefore(check);
3385 *add = new(BasicBlock()->zone()) HAdd(NULL, 3396 *add = new(BasicBlock()->zone()) HAdd(NULL,
3386 original_value, 3397 original_value,
3387 new_constant); 3398 new_constant);
3388 (*add)->AssumeRepresentation(representation); 3399 (*add)->AssumeRepresentation(representation);
3389 (*add)->InsertBefore(check); 3400 (*add)->InsertBefore(check);
3390 } else { 3401 } else {
3391 new_constant->InsertBefore(*add); 3402 new_constant->InsertBefore(*add);
3392 (*constant)->DeleteAndReplaceWith(new_constant); 3403 (*constant)->DeleteAndReplaceWith(new_constant);
(...skipping 4508 matching lines...) Expand 10 before | Expand all | Expand 10 after
7901 instr = HShl::NewHShl(zone(), context, left, right); 7912 instr = HShl::NewHShl(zone(), context, left, right);
7902 break; 7913 break;
7903 default: 7914 default:
7904 UNREACHABLE(); 7915 UNREACHABLE();
7905 } 7916 }
7906 7917
7907 // If we hit an uninitialized binary op stub we will get type info 7918 // If we hit an uninitialized binary op stub we will get type info
7908 // for a smi operation. If one of the operands is a constant string 7919 // for a smi operation. If one of the operands is a constant string
7909 // do not generate code assuming it is a smi operation. 7920 // do not generate code assuming it is a smi operation.
7910 if (info.IsSmi() && 7921 if (info.IsSmi() &&
7911 ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) || 7922 ((left->IsConstant() && HConstant::cast(left)->handle()->IsString()) ||
7912 (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) { 7923 (right->IsConstant() && HConstant::cast(right)->handle()->IsString()))) {
7913 return instr; 7924 return instr;
7914 } 7925 }
7915 Representation rep = ToRepresentation(info); 7926 Representation rep = ToRepresentation(info);
7916 // We only generate either int32 or generic tagged bitwise operations. 7927 // We only generate either int32 or generic tagged bitwise operations.
7917 if (instr->IsBitwiseBinaryOperation()) { 7928 if (instr->IsBitwiseBinaryOperation()) {
7918 HBitwiseBinaryOperation::cast(instr)-> 7929 HBitwiseBinaryOperation::cast(instr)->
7919 InitializeObservedInputRepresentation(rep); 7930 InitializeObservedInputRepresentation(rep);
7920 if (rep.IsDouble()) rep = Representation::Integer32(); 7931 if (rep.IsDouble()) rep = Representation::Integer32();
7921 } 7932 }
7922 TraceRepresentation(expr->op(), info, instr, rep); 7933 TraceRepresentation(expr->op(), info, instr, rep);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
8120 8131
8121 8132
8122 static bool MatchLiteralCompareTypeof(HValue* left, 8133 static bool MatchLiteralCompareTypeof(HValue* left,
8123 Token::Value op, 8134 Token::Value op,
8124 HValue* right, 8135 HValue* right,
8125 HTypeof** typeof_expr, 8136 HTypeof** typeof_expr,
8126 Handle<String>* check) { 8137 Handle<String>* check) {
8127 if (left->IsTypeof() && 8138 if (left->IsTypeof() &&
8128 Token::IsEqualityOp(op) && 8139 Token::IsEqualityOp(op) &&
8129 right->IsConstant() && 8140 right->IsConstant() &&
8130 HConstant::cast(right)->HasStringValue()) { 8141 HConstant::cast(right)->handle()->IsString()) {
8131 *typeof_expr = HTypeof::cast(left); 8142 *typeof_expr = HTypeof::cast(left);
8132 *check = Handle<String>::cast(HConstant::cast(right)->handle()); 8143 *check = Handle<String>::cast(HConstant::cast(right)->handle());
8133 return true; 8144 return true;
8134 } 8145 }
8135 return false; 8146 return false;
8136 } 8147 }
8137 8148
8138 8149
8139 static bool IsLiteralCompareTypeof(HValue* left, 8150 static bool IsLiteralCompareTypeof(HValue* left,
8140 Token::Value op, 8151 Token::Value op,
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after
9555 } 9566 }
9556 } 9567 }
9557 9568
9558 #ifdef DEBUG 9569 #ifdef DEBUG
9559 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9570 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9560 if (allocator_ != NULL) allocator_->Verify(); 9571 if (allocator_ != NULL) allocator_->Verify();
9561 #endif 9572 #endif
9562 } 9573 }
9563 9574
9564 } } // namespace v8::internal 9575 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698