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

Side by Side Diff: src/hydrogen.cc

Issue 868883002: Remove the dependency of Zone on Isolate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation issues Created 5 years, 11 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
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-bch.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/hydrogen.h" 5 #include "src/hydrogen.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 646 }
647 647
648 #endif 648 #endif
649 649
650 650
651 HConstant* HGraph::GetConstant(SetOncePointer<HConstant>* pointer, 651 HConstant* HGraph::GetConstant(SetOncePointer<HConstant>* pointer,
652 int32_t value) { 652 int32_t value) {
653 if (!pointer->is_set()) { 653 if (!pointer->is_set()) {
654 // Can't pass GetInvalidContext() to HConstant::New, because that will 654 // Can't pass GetInvalidContext() to HConstant::New, because that will
655 // recursively call GetConstant 655 // recursively call GetConstant
656 HConstant* constant = HConstant::New(zone(), NULL, value); 656 HConstant* constant = HConstant::New(isolate(), zone(), NULL, value);
657 constant->InsertAfter(entry_block()->first()); 657 constant->InsertAfter(entry_block()->first());
658 pointer->set(constant); 658 pointer->set(constant);
659 return constant; 659 return constant;
660 } 660 }
661 return ReinsertConstantIfNecessary(pointer->get()); 661 return ReinsertConstantIfNecessary(pointer->get());
662 } 662 }
663 663
664 664
665 HConstant* HGraph::ReinsertConstantIfNecessary(HConstant* constant) { 665 HConstant* HGraph::ReinsertConstantIfNecessary(HConstant* constant) {
666 if (!constant->IsLinked()) { 666 if (!constant->IsLinked()) {
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 } 1020 }
1021 builder()->GotoNoSimulate(current->block_, merge_block); 1021 builder()->GotoNoSimulate(current->block_, merge_block);
1022 } 1022 }
1023 current = current->next_; 1023 current = current->next_;
1024 } 1024 }
1025 1025
1026 // Merge deopt blocks, padding when necessary. 1026 // Merge deopt blocks, padding when necessary.
1027 current = merge_at_join_blocks_; 1027 current = merge_at_join_blocks_;
1028 while (current != NULL) { 1028 while (current != NULL) {
1029 if (current->deopt_ && current->block_ != NULL) { 1029 if (current->deopt_ && current->block_ != NULL) {
1030 current->block_->FinishExit(HAbnormalExit::New(builder()->zone(), NULL), 1030 current->block_->FinishExit(
1031 HSourcePosition::Unknown()); 1031 HAbnormalExit::New(builder()->isolate(), builder()->zone(), NULL),
1032 HSourcePosition::Unknown());
1032 } 1033 }
1033 current = current->next_; 1034 current = current->next_;
1034 } 1035 }
1035 builder()->set_current_block(merge_block); 1036 builder()->set_current_block(merge_block);
1036 } 1037 }
1037 1038
1038 1039
1039 HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder) { 1040 HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder) {
1040 Initialize(builder, NULL, kWhileTrue, NULL); 1041 Initialize(builder, NULL, kWhileTrue, NULL);
1041 } 1042 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 body_block_ = builder_->CreateBasicBlock(body_env); 1092 body_block_ = builder_->CreateBasicBlock(body_env);
1092 exit_block_ = builder_->CreateBasicBlock(exit_env); 1093 exit_block_ = builder_->CreateBasicBlock(exit_env);
1093 1094
1094 builder_->set_current_block(header_block_); 1095 builder_->set_current_block(header_block_);
1095 env->Pop(); 1096 env->Pop();
1096 builder_->FinishCurrentBlock(builder_->New<HCompareNumericAndBranch>( 1097 builder_->FinishCurrentBlock(builder_->New<HCompareNumericAndBranch>(
1097 phi_, terminating, token, body_block_, exit_block_)); 1098 phi_, terminating, token, body_block_, exit_block_));
1098 1099
1099 builder_->set_current_block(body_block_); 1100 builder_->set_current_block(body_block_);
1100 if (direction_ == kPreIncrement || direction_ == kPreDecrement) { 1101 if (direction_ == kPreIncrement || direction_ == kPreDecrement) {
1102 Isolate* isolate = builder_->isolate();
1101 HValue* one = builder_->graph()->GetConstant1(); 1103 HValue* one = builder_->graph()->GetConstant1();
1102 if (direction_ == kPreIncrement) { 1104 if (direction_ == kPreIncrement) {
1103 increment_ = HAdd::New(zone(), context_, phi_, one); 1105 increment_ = HAdd::New(isolate, zone(), context_, phi_, one);
1104 } else { 1106 } else {
1105 increment_ = HSub::New(zone(), context_, phi_, one); 1107 increment_ = HSub::New(isolate, zone(), context_, phi_, one);
1106 } 1108 }
1107 increment_->ClearFlag(HValue::kCanOverflow); 1109 increment_->ClearFlag(HValue::kCanOverflow);
1108 builder_->AddInstruction(increment_); 1110 builder_->AddInstruction(increment_);
1109 return increment_; 1111 return increment_;
1110 } else { 1112 } else {
1111 return phi_; 1113 return phi_;
1112 } 1114 }
1113 } 1115 }
1114 1116
1115 1117
(...skipping 21 matching lines...) Expand all
1137 1139
1138 builder_->GotoNoSimulate(exit_trampoline_block_); 1140 builder_->GotoNoSimulate(exit_trampoline_block_);
1139 builder_->set_current_block(NULL); 1141 builder_->set_current_block(NULL);
1140 } 1142 }
1141 1143
1142 1144
1143 void HGraphBuilder::LoopBuilder::EndBody() { 1145 void HGraphBuilder::LoopBuilder::EndBody() {
1144 DCHECK(!finished_); 1146 DCHECK(!finished_);
1145 1147
1146 if (direction_ == kPostIncrement || direction_ == kPostDecrement) { 1148 if (direction_ == kPostIncrement || direction_ == kPostDecrement) {
1149 Isolate* isolate = builder_->isolate();
1147 if (direction_ == kPostIncrement) { 1150 if (direction_ == kPostIncrement) {
1148 increment_ = HAdd::New(zone(), context_, phi_, increment_amount_); 1151 increment_ =
1152 HAdd::New(isolate, zone(), context_, phi_, increment_amount_);
1149 } else { 1153 } else {
1150 increment_ = HSub::New(zone(), context_, phi_, increment_amount_); 1154 increment_ =
1155 HSub::New(isolate, zone(), context_, phi_, increment_amount_);
1151 } 1156 }
1152 increment_->ClearFlag(HValue::kCanOverflow); 1157 increment_->ClearFlag(HValue::kCanOverflow);
1153 builder_->AddInstruction(increment_); 1158 builder_->AddInstruction(increment_);
1154 } 1159 }
1155 1160
1156 if (direction_ != kWhileTrue) { 1161 if (direction_ != kWhileTrue) {
1157 // Push the new increment value on the expression stack to merge into 1162 // Push the new increment value on the expression stack to merge into
1158 // the phi. 1163 // the phi.
1159 builder_->environment()->Push(increment_); 1164 builder_->environment()->Push(increment_);
1160 } 1165 }
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2541 } 2546 }
2542 2547
2543 2548
2544 HValue* HGraphBuilder::BuildCalculateElementsSize(ElementsKind kind, 2549 HValue* HGraphBuilder::BuildCalculateElementsSize(ElementsKind kind,
2545 HValue* capacity) { 2550 HValue* capacity) {
2546 int elements_size = IsFastDoubleElementsKind(kind) 2551 int elements_size = IsFastDoubleElementsKind(kind)
2547 ? kDoubleSize 2552 ? kDoubleSize
2548 : kPointerSize; 2553 : kPointerSize;
2549 2554
2550 HConstant* elements_size_value = Add<HConstant>(elements_size); 2555 HConstant* elements_size_value = Add<HConstant>(elements_size);
2551 HInstruction* mul = HMul::NewImul(zone(), context(), 2556 HInstruction* mul =
2552 capacity->ActualValue(), 2557 HMul::NewImul(isolate(), zone(), context(), capacity->ActualValue(),
2553 elements_size_value); 2558 elements_size_value);
2554 AddInstruction(mul); 2559 AddInstruction(mul);
2555 mul->ClearFlag(HValue::kCanOverflow); 2560 mul->ClearFlag(HValue::kCanOverflow);
2556 2561
2557 STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize); 2562 STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize);
2558 2563
2559 HConstant* header_size = Add<HConstant>(FixedArray::kHeaderSize); 2564 HConstant* header_size = Add<HConstant>(FixedArray::kHeaderSize);
2560 HValue* total_size = AddUncasted<HAdd>(mul, header_size); 2565 HValue* total_size = AddUncasted<HAdd>(mul, header_size);
2561 total_size->ClearFlag(HValue::kCanOverflow); 2566 total_size->ClearFlag(HValue::kCanOverflow);
2562 return total_size; 2567 return total_size;
2563 } 2568 }
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 initial_function_state_(this, info, NORMAL_RETURN, 0), 3342 initial_function_state_(this, info, NORMAL_RETURN, 0),
3338 ast_context_(NULL), 3343 ast_context_(NULL),
3339 break_scope_(NULL), 3344 break_scope_(NULL),
3340 inlined_count_(0), 3345 inlined_count_(0),
3341 globals_(10, info->zone()), 3346 globals_(10, info->zone()),
3342 osr_(new(info->zone()) HOsrBuilder(this)) { 3347 osr_(new(info->zone()) HOsrBuilder(this)) {
3343 // This is not initialized in the initializer list because the 3348 // This is not initialized in the initializer list because the
3344 // constructor for the initial state relies on function_state_ == NULL 3349 // constructor for the initial state relies on function_state_ == NULL
3345 // to know it's the initial state. 3350 // to know it's the initial state.
3346 function_state_ = &initial_function_state_; 3351 function_state_ = &initial_function_state_;
3347 InitializeAstVisitor(info->zone()); 3352 InitializeAstVisitor(info->isolate(), info->zone());
3348 if (FLAG_hydrogen_track_positions) { 3353 if (FLAG_hydrogen_track_positions) {
3349 SetSourcePosition(info->shared_info()->start_position()); 3354 SetSourcePosition(info->shared_info()->start_position());
3350 } 3355 }
3351 } 3356 }
3352 3357
3353 3358
3354 HBasicBlock* HOptimizedGraphBuilder::CreateJoin(HBasicBlock* first, 3359 HBasicBlock* HOptimizedGraphBuilder::CreateJoin(HBasicBlock* first,
3355 HBasicBlock* second, 3360 HBasicBlock* second,
3356 BailoutId join_id) { 3361 BailoutId join_id) {
3357 if (first == NULL) { 3362 if (first == NULL) {
(...skipping 4157 matching lines...) Expand 10 before | Expand all | Expand 10 after
7515 Handle<Map> receiver_map) { 7520 Handle<Map> receiver_map) {
7516 if (!holder.is_null()) { 7521 if (!holder.is_null()) {
7517 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype())); 7522 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype()));
7518 BuildCheckPrototypeMaps(prototype, holder); 7523 BuildCheckPrototypeMaps(prototype, holder);
7519 } 7524 }
7520 } 7525 }
7521 7526
7522 7527
7523 HInstruction* HOptimizedGraphBuilder::NewPlainFunctionCall( 7528 HInstruction* HOptimizedGraphBuilder::NewPlainFunctionCall(
7524 HValue* fun, int argument_count, bool pass_argument_count) { 7529 HValue* fun, int argument_count, bool pass_argument_count) {
7525 return New<HCallJSFunction>( 7530 return New<HCallJSFunction>(fun, argument_count, pass_argument_count);
7526 fun, argument_count, pass_argument_count);
7527 } 7531 }
7528 7532
7529 7533
7530 HInstruction* HOptimizedGraphBuilder::NewArgumentAdaptorCall( 7534 HInstruction* HOptimizedGraphBuilder::NewArgumentAdaptorCall(
7531 HValue* fun, HValue* context, 7535 HValue* fun, HValue* context,
7532 int argument_count, HValue* expected_param_count) { 7536 int argument_count, HValue* expected_param_count) {
7533 ArgumentAdaptorDescriptor descriptor(isolate()); 7537 ArgumentAdaptorDescriptor descriptor(isolate());
7534 HValue* arity = Add<HConstant>(argument_count - 1); 7538 HValue* arity = Add<HConstant>(argument_count - 1);
7535 7539
7536 HValue* op_vals[] = { context, fun, arity, expected_param_count }; 7540 HValue* op_vals[] = { context, fun, arity, expected_param_count };
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
8200 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); 8204 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id);
8201 ast_context()->ReturnInstruction(op, expr->id()); 8205 ast_context()->ReturnInstruction(op, expr->id());
8202 return true; 8206 return true;
8203 } 8207 }
8204 break; 8208 break;
8205 case kMathImul: 8209 case kMathImul:
8206 if (expr->arguments()->length() == 2) { 8210 if (expr->arguments()->length() == 2) {
8207 HValue* right = Pop(); 8211 HValue* right = Pop();
8208 HValue* left = Pop(); 8212 HValue* left = Pop();
8209 Drop(2); // Receiver and function. 8213 Drop(2); // Receiver and function.
8210 HInstruction* op = HMul::NewImul(zone(), context(), left, right); 8214 HInstruction* op =
8215 HMul::NewImul(isolate(), zone(), context(), left, right);
8211 ast_context()->ReturnInstruction(op, expr->id()); 8216 ast_context()->ReturnInstruction(op, expr->id());
8212 return true; 8217 return true;
8213 } 8218 }
8214 break; 8219 break;
8215 default: 8220 default:
8216 // Not supported for inlining yet. 8221 // Not supported for inlining yet.
8217 break; 8222 break;
8218 } 8223 }
8219 return false; 8224 return false;
8220 } 8225 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
8325 HInstruction* result = NewUncasted<HMathMinMax>(left, right, op); 8330 HInstruction* result = NewUncasted<HMathMinMax>(left, right, op);
8326 ast_context()->ReturnInstruction(result, expr->id()); 8331 ast_context()->ReturnInstruction(result, expr->id());
8327 return true; 8332 return true;
8328 } 8333 }
8329 break; 8334 break;
8330 case kMathImul: 8335 case kMathImul:
8331 if (argument_count == 3) { 8336 if (argument_count == 3) {
8332 HValue* right = Pop(); 8337 HValue* right = Pop();
8333 HValue* left = Pop(); 8338 HValue* left = Pop();
8334 Drop(2); // Receiver and function. 8339 Drop(2); // Receiver and function.
8335 HInstruction* result = HMul::NewImul(zone(), context(), left, right); 8340 HInstruction* result =
8341 HMul::NewImul(isolate(), zone(), context(), left, right);
8336 ast_context()->ReturnInstruction(result, expr->id()); 8342 ast_context()->ReturnInstruction(result, expr->id());
8337 return true; 8343 return true;
8338 } 8344 }
8339 break; 8345 break;
8340 case kArrayPop: { 8346 case kArrayPop: {
8341 if (receiver_map.is_null()) return false; 8347 if (receiver_map.is_null()) return false;
8342 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; 8348 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false;
8343 ElementsKind elements_kind = receiver_map->elements_kind(); 8349 ElementsKind elements_kind = receiver_map->elements_kind();
8344 if (JSArray::IsReadOnlyLengthDescriptor(receiver_map)) return false; 8350 if (JSArray::IsReadOnlyLengthDescriptor(receiver_map)) return false;
8345 if (!IsFastElementsKind(elements_kind)) return false; 8351 if (!IsFastElementsKind(elements_kind)) return false;
(...skipping 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after
10360 return AddUncasted<HForceRepresentation>(number, 10366 return AddUncasted<HForceRepresentation>(number,
10361 Representation::Integer32()); 10367 Representation::Integer32());
10362 } 10368 }
10363 return number; 10369 return number;
10364 } 10370 }
10365 10371
10366 10372
10367 HValue* HGraphBuilder::TruncateToNumber(HValue* value, Type** expected) { 10373 HValue* HGraphBuilder::TruncateToNumber(HValue* value, Type** expected) {
10368 if (value->IsConstant()) { 10374 if (value->IsConstant()) {
10369 HConstant* constant = HConstant::cast(value); 10375 HConstant* constant = HConstant::cast(value);
10370 Maybe<HConstant*> number = constant->CopyToTruncatedNumber(zone()); 10376 Maybe<HConstant*> number =
10377 constant->CopyToTruncatedNumber(isolate(), zone());
10371 if (number.has_value) { 10378 if (number.has_value) {
10372 *expected = Type::Number(zone()); 10379 *expected = Type::Number(zone());
10373 return AddInstruction(number.value); 10380 return AddInstruction(number.value);
10374 } 10381 }
10375 } 10382 }
10376 10383
10377 // We put temporary values on the stack, which don't correspond to anything 10384 // We put temporary values on the stack, which don't correspond to anything
10378 // in baseline code. Since nothing is observable we avoid recording those 10385 // in baseline code. Since nothing is observable we avoid recording those
10379 // pushes with a NoObservableSideEffectsScope. 10386 // pushes with a NoObservableSideEffectsScope.
10380 NoObservableSideEffectsScope no_effects(this); 10387 NoObservableSideEffectsScope no_effects(this);
(...skipping 3082 matching lines...) Expand 10 before | Expand all | Expand 10 after
13463 if (ShouldProduceTraceOutput()) { 13470 if (ShouldProduceTraceOutput()) {
13464 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13471 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13465 } 13472 }
13466 13473
13467 #ifdef DEBUG 13474 #ifdef DEBUG
13468 graph_->Verify(false); // No full verify. 13475 graph_->Verify(false); // No full verify.
13469 #endif 13476 #endif
13470 } 13477 }
13471 13478
13472 } } // namespace v8::internal 13479 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-bch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698