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

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
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 4523 matching lines...) Expand 10 before | Expand all | Expand 10 after
7916 instr = HShl::NewHShl(zone(), context, left, right); 7927 instr = HShl::NewHShl(zone(), context, left, right);
7917 break; 7928 break;
7918 default: 7929 default:
7919 UNREACHABLE(); 7930 UNREACHABLE();
7920 } 7931 }
7921 7932
7922 // If we hit an uninitialized binary op stub we will get type info 7933 // If we hit an uninitialized binary op stub we will get type info
7923 // for a smi operation. If one of the operands is a constant string 7934 // for a smi operation. If one of the operands is a constant string
7924 // do not generate code assuming it is a smi operation. 7935 // do not generate code assuming it is a smi operation.
7925 if (info.IsSmi() && 7936 if (info.IsSmi() &&
7926 ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) || 7937 ((left->IsConstant() && HConstant::cast(left)->handle()->IsString()) ||
7927 (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) { 7938 (right->IsConstant() && HConstant::cast(right)->handle()->IsString()))) {
7928 return instr; 7939 return instr;
7929 } 7940 }
7930 Representation rep = ToRepresentation(info); 7941 Representation rep = ToRepresentation(info);
7931 // We only generate either int32 or generic tagged bitwise operations. 7942 // We only generate either int32 or generic tagged bitwise operations.
7932 if (instr->IsBitwiseBinaryOperation()) { 7943 if (instr->IsBitwiseBinaryOperation()) {
7933 HBitwiseBinaryOperation::cast(instr)-> 7944 HBitwiseBinaryOperation::cast(instr)->
7934 InitializeObservedInputRepresentation(rep); 7945 InitializeObservedInputRepresentation(rep);
7935 if (rep.IsDouble()) rep = Representation::Integer32(); 7946 if (rep.IsDouble()) rep = Representation::Integer32();
7936 } 7947 }
7937 TraceRepresentation(expr->op(), info, instr, rep); 7948 TraceRepresentation(expr->op(), info, instr, rep);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
8135 8146
8136 8147
8137 static bool MatchLiteralCompareTypeof(HValue* left, 8148 static bool MatchLiteralCompareTypeof(HValue* left,
8138 Token::Value op, 8149 Token::Value op,
8139 HValue* right, 8150 HValue* right,
8140 HTypeof** typeof_expr, 8151 HTypeof** typeof_expr,
8141 Handle<String>* check) { 8152 Handle<String>* check) {
8142 if (left->IsTypeof() && 8153 if (left->IsTypeof() &&
8143 Token::IsEqualityOp(op) && 8154 Token::IsEqualityOp(op) &&
8144 right->IsConstant() && 8155 right->IsConstant() &&
8145 HConstant::cast(right)->HasStringValue()) { 8156 HConstant::cast(right)->handle()->IsString()) {
8146 *typeof_expr = HTypeof::cast(left); 8157 *typeof_expr = HTypeof::cast(left);
8147 *check = Handle<String>::cast(HConstant::cast(right)->handle()); 8158 *check = Handle<String>::cast(HConstant::cast(right)->handle());
8148 return true; 8159 return true;
8149 } 8160 }
8150 return false; 8161 return false;
8151 } 8162 }
8152 8163
8153 8164
8154 static bool IsLiteralCompareTypeof(HValue* left, 8165 static bool IsLiteralCompareTypeof(HValue* left,
8155 Token::Value op, 8166 Token::Value op,
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after
9570 } 9581 }
9571 } 9582 }
9572 9583
9573 #ifdef DEBUG 9584 #ifdef DEBUG
9574 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9585 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9575 if (allocator_ != NULL) allocator_->Verify(); 9586 if (allocator_ != NULL) allocator_->Verify();
9576 #endif 9587 #endif
9577 } 9588 }
9578 9589
9579 } } // namespace v8::internal 9590 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698