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

Side by Side Diff: src/hydrogen.cc

Issue 10910161: Partial ia32 implementation of optimized try/catch (by Kevin Millikin) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed build. Created 8 years, 3 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 3923 matching lines...) Expand 10 before | Expand all | Expand 10 after
3934 } 3934 }
3935 3935
3936 3936
3937 void HGraphBuilder::VisitBlock(Block* stmt) { 3937 void HGraphBuilder::VisitBlock(Block* stmt) {
3938 ASSERT(!HasStackOverflow()); 3938 ASSERT(!HasStackOverflow());
3939 ASSERT(current_block() != NULL); 3939 ASSERT(current_block() != NULL);
3940 ASSERT(current_block()->HasPredecessor()); 3940 ASSERT(current_block()->HasPredecessor());
3941 if (stmt->scope() != NULL) { 3941 if (stmt->scope() != NULL) {
3942 return Bailout("ScopedBlock"); 3942 return Bailout("ScopedBlock");
3943 } 3943 }
3944 BreakAndContinueInfo break_info(stmt); 3944 BreakAndContinueInfo break_info(stmt, 0);
3945 { BreakAndContinueScope push(&break_info, this); 3945 { BreakAndContinueScope push(&break_info, this);
3946 CHECK_BAILOUT(VisitStatements(stmt->statements())); 3946 CHECK_BAILOUT(VisitStatements(stmt->statements()));
3947 } 3947 }
3948 HBasicBlock* break_block = break_info.break_block(); 3948 HBasicBlock* break_block = break_info.break_block();
3949 if (break_block != NULL) { 3949 if (break_block != NULL) {
3950 if (current_block() != NULL) current_block()->Goto(break_block); 3950 if (current_block() != NULL) current_block()->Goto(break_block);
3951 break_block->SetJoinId(stmt->ExitId()); 3951 break_block->SetJoinId(stmt->ExitId());
3952 set_current_block(break_block); 3952 set_current_block(break_block);
3953 } 3953 }
3954 } 3954 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4001 } else { 4001 } else {
4002 cond_false = NULL; 4002 cond_false = NULL;
4003 } 4003 }
4004 4004
4005 HBasicBlock* join = CreateJoin(cond_true, cond_false, stmt->IfId()); 4005 HBasicBlock* join = CreateJoin(cond_true, cond_false, stmt->IfId());
4006 set_current_block(join); 4006 set_current_block(join);
4007 } 4007 }
4008 } 4008 }
4009 4009
4010 4010
4011 HBasicBlock* HGraphBuilder::BreakAndContinueScope::Get( 4011 void HGraphBuilder::BreakAndContinueScope::UnwindReturn() {
4012 BreakableStatement* stmt,
4013 BreakType type,
4014 int* drop_extra) {
4015 *drop_extra = 0;
4016 BreakAndContinueScope* current = this; 4012 BreakAndContinueScope* current = this;
4017 while (current != NULL && current->info()->target() != stmt) { 4013 while (current != NULL) {
4018 *drop_extra += current->info()->drop_extra(); 4014 TryCatchStatement* try_catch =
4015 current->info()->statement()->AsTryCatchStatement();
4016 if (try_catch != NULL) {
4017 HLeaveTry* leave = new(owner()->zone()) HLeaveTry;
4018 owner()->AddInstruction(leave);
4019 owner()->environment()->RemoveExceptionHandler();
4020 owner()->AddSimulate(try_catch->TryExitId());
4021 }
4022 current = current->next();
4023 }
4024 }
4025
4026
4027 void HGraphBuilder::BreakAndContinueScope::Unwind(BreakableStatement* target,
4028 BreakType type) {
4029 BreakAndContinueScope* current = this;
4030 while (current != NULL && current->info()->statement() != target) {
4031 TryCatchStatement* try_catch =
4032 current->info()->statement()->AsTryCatchStatement();
4033 if (try_catch != NULL) {
4034 HLeaveTry* leave = new(owner()->zone()) HLeaveTry;
4035 owner()->AddInstruction(leave);
4036 owner()->environment()->RemoveExceptionHandler();
4037 owner()->AddSimulate(try_catch->TryExitId());
4038 }
4039 owner()->Drop(current->info()->drop_extra());
4019 current = current->next(); 4040 current = current->next();
4020 } 4041 }
4021 ASSERT(current != NULL); // Always found (unless stack is malformed). 4042 ASSERT(current != NULL); // Always found (unless stack is malformed).
4022 4043
4023 if (type == BREAK) { 4044 if (type == BREAK) {
4024 *drop_extra += current->info()->drop_extra(); 4045 owner()->Drop(current->info()->drop_extra());
4025 } 4046 }
4026 4047
4027 HBasicBlock* block = NULL; 4048 HBasicBlock* block = NULL;
4028 switch (type) { 4049 switch (type) {
4029 case BREAK: 4050 case BREAK:
4030 block = current->info()->break_block(); 4051 block = current->info()->break_block();
4031 if (block == NULL) { 4052 if (block == NULL) {
4032 block = current->owner()->graph()->CreateBasicBlock(); 4053 block = current->owner()->graph()->CreateBasicBlock();
4033 current->info()->set_break_block(block); 4054 current->info()->set_break_block(block);
4034 } 4055 }
4035 break; 4056 break;
4036 4057
4037 case CONTINUE: 4058 case CONTINUE:
4038 block = current->info()->continue_block(); 4059 block = current->info()->continue_block();
4039 if (block == NULL) { 4060 if (block == NULL) {
4040 block = current->owner()->graph()->CreateBasicBlock(); 4061 block = current->owner()->graph()->CreateBasicBlock();
4041 current->info()->set_continue_block(block); 4062 current->info()->set_continue_block(block);
4042 } 4063 }
4043 break; 4064 break;
4044 } 4065 }
4045 4066 owner()->current_block()->Goto(block);
4046 return block; 4067 owner()->set_current_block(NULL);
4047 } 4068 }
4048 4069
4049 4070
4050 void HGraphBuilder::VisitContinueStatement(ContinueStatement* stmt) { 4071 void HGraphBuilder::VisitContinueStatement(ContinueStatement* stmt) {
4051 ASSERT(!HasStackOverflow()); 4072 ASSERT(!HasStackOverflow());
4052 ASSERT(current_block() != NULL); 4073 ASSERT(current_block() != NULL);
4053 ASSERT(current_block()->HasPredecessor()); 4074 ASSERT(current_block()->HasPredecessor());
4054 int drop_extra = 0; 4075 break_scope()->Unwind(stmt->target(), CONTINUE);
4055 HBasicBlock* continue_block = break_scope()->Get(stmt->target(),
4056 CONTINUE,
4057 &drop_extra);
4058 Drop(drop_extra);
4059 current_block()->Goto(continue_block);
4060 set_current_block(NULL);
4061 } 4076 }
4062 4077
4063 4078
4064 void HGraphBuilder::VisitBreakStatement(BreakStatement* stmt) { 4079 void HGraphBuilder::VisitBreakStatement(BreakStatement* stmt) {
4065 ASSERT(!HasStackOverflow()); 4080 ASSERT(!HasStackOverflow());
4066 ASSERT(current_block() != NULL); 4081 ASSERT(current_block() != NULL);
4067 ASSERT(current_block()->HasPredecessor()); 4082 ASSERT(current_block()->HasPredecessor());
4068 int drop_extra = 0; 4083 break_scope()->Unwind(stmt->target(), BREAK);
4069 HBasicBlock* break_block = break_scope()->Get(stmt->target(),
4070 BREAK,
4071 &drop_extra);
4072 Drop(drop_extra);
4073 current_block()->Goto(break_block);
4074 set_current_block(NULL);
4075 } 4084 }
4076 4085
4077 4086
4078 void HGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) { 4087 void HGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) {
4079 ASSERT(!HasStackOverflow()); 4088 ASSERT(!HasStackOverflow());
4080 ASSERT(current_block() != NULL); 4089 ASSERT(current_block() != NULL);
4081 ASSERT(current_block()->HasPredecessor()); 4090 ASSERT(current_block()->HasPredecessor());
4082 FunctionState* state = function_state(); 4091 FunctionState* state = function_state();
4083 AstContext* context = call_context(); 4092 AstContext* context = call_context();
4084 if (context == NULL) { 4093 if (context == NULL) {
4085 // Not an inlined return, so an actual one. 4094 // Not an inlined return, so an actual one.
4086 CHECK_ALIVE(VisitForValue(stmt->expression())); 4095 CHECK_ALIVE(VisitForValue(stmt->expression()));
4087 HValue* result = environment()->Pop(); 4096 HValue* result = environment()->Pop();
4097 break_scope()->UnwindReturn();
4088 current_block()->FinishExit(new(zone()) HReturn(result)); 4098 current_block()->FinishExit(new(zone()) HReturn(result));
4089 } else if (state->inlining_kind() == CONSTRUCT_CALL_RETURN) { 4099 } else if (state->inlining_kind() == CONSTRUCT_CALL_RETURN) {
4090 // Return from an inlined construct call. In a test context the return value 4100 // Return from an inlined construct call. In a test context the return value
4091 // will always evaluate to true, in a value context the return value needs 4101 // will always evaluate to true, in a value context the return value needs
4092 // to be a JSObject. 4102 // to be a JSObject.
4093 if (context->IsTest()) { 4103 if (context->IsTest()) {
4094 TestContext* test = TestContext::cast(context); 4104 TestContext* test = TestContext::cast(context);
4095 CHECK_ALIVE(VisitForEffect(stmt->expression())); 4105 CHECK_ALIVE(VisitForEffect(stmt->expression()));
4096 current_block()->Goto(test->if_true(), state); 4106 current_block()->Goto(test->if_true(), state);
4097 } else if (context->IsEffect()) { 4107 } else if (context->IsEffect()) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
4270 if (not_string_block != NULL) { 4280 if (not_string_block != NULL) {
4271 BailoutId join_id = !default_id.IsNone() ? default_id : stmt->ExitId(); 4281 BailoutId join_id = !default_id.IsNone() ? default_id : stmt->ExitId();
4272 last_block = CreateJoin(last_block, not_string_block, join_id); 4282 last_block = CreateJoin(last_block, not_string_block, join_id);
4273 } 4283 }
4274 4284
4275 // 3. Loop over the clauses and the linked list of tests in lockstep, 4285 // 3. Loop over the clauses and the linked list of tests in lockstep,
4276 // translating the clause bodies. 4286 // translating the clause bodies.
4277 HBasicBlock* curr_test_block = first_test_block; 4287 HBasicBlock* curr_test_block = first_test_block;
4278 HBasicBlock* fall_through_block = NULL; 4288 HBasicBlock* fall_through_block = NULL;
4279 4289
4280 BreakAndContinueInfo break_info(stmt); 4290 BreakAndContinueInfo break_info(stmt, 0);
4281 { BreakAndContinueScope push(&break_info, this); 4291 { BreakAndContinueScope push(&break_info, this);
4282 for (int i = 0; i < clause_count; ++i) { 4292 for (int i = 0; i < clause_count; ++i) {
4283 CaseClause* clause = clauses->at(i); 4293 CaseClause* clause = clauses->at(i);
4284 4294
4285 // Identify the block where normal (non-fall-through) control flow 4295 // Identify the block where normal (non-fall-through) control flow
4286 // goes to. 4296 // goes to.
4287 HBasicBlock* normal_block = NULL; 4297 HBasicBlock* normal_block = NULL;
4288 if (clause->is_default()) { 4298 if (clause->is_default()) {
4289 if (last_block != NULL) { 4299 if (last_block != NULL) {
4290 normal_block = last_block; 4300 normal_block = last_block;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4414 ASSERT(!HasStackOverflow()); 4424 ASSERT(!HasStackOverflow());
4415 ASSERT(current_block() != NULL); 4425 ASSERT(current_block() != NULL);
4416 ASSERT(current_block()->HasPredecessor()); 4426 ASSERT(current_block()->HasPredecessor());
4417 ASSERT(current_block() != NULL); 4427 ASSERT(current_block() != NULL);
4418 bool osr_entry = PreProcessOsrEntry(stmt); 4428 bool osr_entry = PreProcessOsrEntry(stmt);
4419 HBasicBlock* loop_entry = CreateLoopHeaderBlock(); 4429 HBasicBlock* loop_entry = CreateLoopHeaderBlock();
4420 current_block()->Goto(loop_entry); 4430 current_block()->Goto(loop_entry);
4421 set_current_block(loop_entry); 4431 set_current_block(loop_entry);
4422 if (osr_entry) graph()->set_osr_loop_entry(loop_entry); 4432 if (osr_entry) graph()->set_osr_loop_entry(loop_entry);
4423 4433
4424 BreakAndContinueInfo break_info(stmt); 4434 BreakAndContinueInfo break_info(stmt, 0);
4425 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); 4435 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info));
4426 HBasicBlock* body_exit = 4436 HBasicBlock* body_exit =
4427 JoinContinue(stmt, current_block(), break_info.continue_block()); 4437 JoinContinue(stmt, current_block(), break_info.continue_block());
4428 HBasicBlock* loop_successor = NULL; 4438 HBasicBlock* loop_successor = NULL;
4429 if (body_exit != NULL && !stmt->cond()->ToBooleanIsTrue()) { 4439 if (body_exit != NULL && !stmt->cond()->ToBooleanIsTrue()) {
4430 set_current_block(body_exit); 4440 set_current_block(body_exit);
4431 // The block for a true condition, the actual predecessor block of the 4441 // The block for a true condition, the actual predecessor block of the
4432 // back edge. 4442 // back edge.
4433 body_exit = graph()->CreateBasicBlock(); 4443 body_exit = graph()->CreateBasicBlock();
4434 loop_successor = graph()->CreateBasicBlock(); 4444 loop_successor = graph()->CreateBasicBlock();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 body_entry->SetJoinId(stmt->BodyId()); 4485 body_entry->SetJoinId(stmt->BodyId());
4476 set_current_block(body_entry); 4486 set_current_block(body_entry);
4477 } 4487 }
4478 if (loop_successor->HasPredecessor()) { 4488 if (loop_successor->HasPredecessor()) {
4479 loop_successor->SetJoinId(stmt->ExitId()); 4489 loop_successor->SetJoinId(stmt->ExitId());
4480 } else { 4490 } else {
4481 loop_successor = NULL; 4491 loop_successor = NULL;
4482 } 4492 }
4483 } 4493 }
4484 4494
4485 BreakAndContinueInfo break_info(stmt); 4495 BreakAndContinueInfo break_info(stmt, 0);
4486 if (current_block() != NULL) { 4496 if (current_block() != NULL) {
4487 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); 4497 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info));
4488 } 4498 }
4489 HBasicBlock* body_exit = 4499 HBasicBlock* body_exit =
4490 JoinContinue(stmt, current_block(), break_info.continue_block()); 4500 JoinContinue(stmt, current_block(), break_info.continue_block());
4491 HBasicBlock* loop_exit = CreateLoop(stmt, 4501 HBasicBlock* loop_exit = CreateLoop(stmt,
4492 loop_entry, 4502 loop_entry,
4493 body_exit, 4503 body_exit,
4494 loop_successor, 4504 loop_successor,
4495 break_info.break_block()); 4505 break_info.break_block());
(...skipping 24 matching lines...) Expand all
4520 body_entry->SetJoinId(stmt->BodyId()); 4530 body_entry->SetJoinId(stmt->BodyId());
4521 set_current_block(body_entry); 4531 set_current_block(body_entry);
4522 } 4532 }
4523 if (loop_successor->HasPredecessor()) { 4533 if (loop_successor->HasPredecessor()) {
4524 loop_successor->SetJoinId(stmt->ExitId()); 4534 loop_successor->SetJoinId(stmt->ExitId());
4525 } else { 4535 } else {
4526 loop_successor = NULL; 4536 loop_successor = NULL;
4527 } 4537 }
4528 } 4538 }
4529 4539
4530 BreakAndContinueInfo break_info(stmt); 4540 BreakAndContinueInfo break_info(stmt, 0);
4531 if (current_block() != NULL) { 4541 if (current_block() != NULL) {
4532 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); 4542 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info));
4533 } 4543 }
4534 HBasicBlock* body_exit = 4544 HBasicBlock* body_exit =
4535 JoinContinue(stmt, current_block(), break_info.continue_block()); 4545 JoinContinue(stmt, current_block(), break_info.continue_block());
4536 4546
4537 if (stmt->next() != NULL && body_exit != NULL) { 4547 if (stmt->next() != NULL && body_exit != NULL) {
4538 set_current_block(body_exit); 4548 set_current_block(body_exit);
4539 CHECK_BAILOUT(Visit(stmt->next())); 4549 CHECK_BAILOUT(Visit(stmt->next()));
4540 body_exit = current_block(); 4550 body_exit = current_block();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4665 break_info.break_block()); 4675 break_info.break_block());
4666 4676
4667 set_current_block(loop_exit); 4677 set_current_block(loop_exit);
4668 } 4678 }
4669 4679
4670 4680
4671 void HGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { 4681 void HGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) {
4672 ASSERT(!HasStackOverflow()); 4682 ASSERT(!HasStackOverflow());
4673 ASSERT(current_block() != NULL); 4683 ASSERT(current_block() != NULL);
4674 ASSERT(current_block()->HasPredecessor()); 4684 ASSERT(current_block()->HasPredecessor());
4675 return Bailout("TryCatchStatement"); 4685 if (!FLAG_crankshaft_try_support) {
4686 Bailout("try statement support disabled");
4687 return;
4688 }
4689 HEnterTry* enter = new(zone()) HEnterTry(stmt->index());
4690 AddInstruction(enter);
4691 environment()->AddExceptionHandler();
4692 AddSimulate(stmt->TryEntryId());
4693 BreakAndContinueInfo try_info(stmt, 0);
4694 { BreakAndContinueScope push(&try_info, this);
4695 CHECK_BAILOUT(Visit(stmt->try_block()));
4696 }
4697 if (current_block() != NULL) {
4698 HLeaveTry* leave = new(zone()) HLeaveTry;
4699 AddInstruction(leave);
4700 environment()->RemoveExceptionHandler();
4701 AddSimulate(stmt->TryExitId());
4702 }
4676 } 4703 }
4677 4704
4678 4705
4679 void HGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) { 4706 void HGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
4680 ASSERT(!HasStackOverflow()); 4707 ASSERT(!HasStackOverflow());
4681 ASSERT(current_block() != NULL); 4708 ASSERT(current_block() != NULL);
4682 ASSERT(current_block()->HasPredecessor()); 4709 ASSERT(current_block()->HasPredecessor());
4683 return Bailout("TryFinallyStatement"); 4710 return Bailout("TryFinallyStatement");
4684 } 4711 }
4685 4712
(...skipping 4697 matching lines...) Expand 10 before | Expand all | Expand 10 after
9383 Scope* scope, 9410 Scope* scope,
9384 Handle<JSFunction> closure, 9411 Handle<JSFunction> closure,
9385 Zone* zone) 9412 Zone* zone)
9386 : closure_(closure), 9413 : closure_(closure),
9387 values_(0, zone), 9414 values_(0, zone),
9388 assigned_variables_(4, zone), 9415 assigned_variables_(4, zone),
9389 frame_type_(JS_FUNCTION), 9416 frame_type_(JS_FUNCTION),
9390 parameter_count_(0), 9417 parameter_count_(0),
9391 specials_count_(1), 9418 specials_count_(1),
9392 local_count_(0), 9419 local_count_(0),
9420 handler_count_(0),
9393 outer_(outer), 9421 outer_(outer),
9394 pop_count_(0), 9422 pop_count_(0),
9395 push_count_(0), 9423 push_count_(0),
9396 ast_id_(BailoutId::None()), 9424 ast_id_(BailoutId::None()),
9397 zone_(zone) { 9425 zone_(zone) {
9398 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0); 9426 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0);
9399 } 9427 }
9400 9428
9401 9429
9402 HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone) 9430 HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone)
9403 : values_(0, zone), 9431 : values_(0, zone),
9404 assigned_variables_(0, zone), 9432 assigned_variables_(0, zone),
9405 frame_type_(JS_FUNCTION), 9433 frame_type_(JS_FUNCTION),
9406 parameter_count_(0), 9434 parameter_count_(0),
9407 specials_count_(1), 9435 specials_count_(1),
9408 local_count_(0), 9436 local_count_(0),
9437 handler_count_(0),
9409 outer_(NULL), 9438 outer_(NULL),
9410 pop_count_(0), 9439 pop_count_(0),
9411 push_count_(0), 9440 push_count_(0),
9412 ast_id_(other->ast_id()), 9441 ast_id_(other->ast_id()),
9413 zone_(zone) { 9442 zone_(zone) {
9414 Initialize(other); 9443 Initialize(other);
9415 } 9444 }
9416 9445
9417 9446
9418 HEnvironment::HEnvironment(HEnvironment* outer, 9447 HEnvironment::HEnvironment(HEnvironment* outer,
9419 Handle<JSFunction> closure, 9448 Handle<JSFunction> closure,
9420 FrameType frame_type, 9449 FrameType frame_type,
9421 int arguments, 9450 int arguments,
9422 Zone* zone) 9451 Zone* zone)
9423 : closure_(closure), 9452 : closure_(closure),
9424 values_(arguments, zone), 9453 values_(arguments, zone),
9425 assigned_variables_(0, zone), 9454 assigned_variables_(0, zone),
9426 frame_type_(frame_type), 9455 frame_type_(frame_type),
9427 parameter_count_(arguments), 9456 parameter_count_(arguments),
9428 local_count_(0), 9457 local_count_(0),
9458 handler_count_(0),
9429 outer_(outer), 9459 outer_(outer),
9430 pop_count_(0), 9460 pop_count_(0),
9431 push_count_(0), 9461 push_count_(0),
9432 ast_id_(BailoutId::None()), 9462 ast_id_(BailoutId::None()),
9433 zone_(zone) { 9463 zone_(zone) {
9434 } 9464 }
9435 9465
9436 9466
9437 void HEnvironment::Initialize(int parameter_count, 9467 void HEnvironment::Initialize(int parameter_count,
9438 int local_count, 9468 int local_count,
9439 int stack_height) { 9469 int stack_height) {
9440 parameter_count_ = parameter_count; 9470 parameter_count_ = parameter_count;
9441 local_count_ = local_count; 9471 local_count_ = local_count;
9442 9472
9443 // Avoid reallocating the temporaries' backing store on the first Push. 9473 // Avoid reallocating the temporaries' backing store on the first Push.
9444 int total = parameter_count + specials_count_ + local_count + stack_height; 9474 int total = parameter_count + specials_count_ + local_count + stack_height;
9445 values_.Initialize(total + 4, zone()); 9475 values_.Initialize(total + 4, zone());
9446 for (int i = 0; i < total; ++i) values_.Add(NULL, zone()); 9476 for (int i = 0; i < total; ++i) values_.Add(NULL, zone());
9447 } 9477 }
9448 9478
9449 9479
9450 void HEnvironment::Initialize(const HEnvironment* other) { 9480 void HEnvironment::Initialize(const HEnvironment* other) {
9451 closure_ = other->closure(); 9481 closure_ = other->closure();
9452 values_.AddAll(other->values_, zone()); 9482 values_.AddAll(other->values_, zone());
9453 assigned_variables_.AddAll(other->assigned_variables_, zone()); 9483 assigned_variables_.AddAll(other->assigned_variables_, zone());
9454 frame_type_ = other->frame_type_; 9484 frame_type_ = other->frame_type_;
9455 parameter_count_ = other->parameter_count_; 9485 parameter_count_ = other->parameter_count_;
9456 local_count_ = other->local_count_; 9486 local_count_ = other->local_count_;
9487 handler_count_ = other->handler_count_;
9457 if (other->outer_ != NULL) outer_ = other->outer_->Copy(); // Deep copy. 9488 if (other->outer_ != NULL) outer_ = other->outer_->Copy(); // Deep copy.
9458 pop_count_ = other->pop_count_; 9489 pop_count_ = other->pop_count_;
9459 push_count_ = other->push_count_; 9490 push_count_ = other->push_count_;
9460 ast_id_ = other->ast_id_; 9491 ast_id_ = other->ast_id_;
9461 } 9492 }
9462 9493
9463 9494
9464 void HEnvironment::AddIncomingEdge(HBasicBlock* block, HEnvironment* other) { 9495 void HEnvironment::AddIncomingEdge(HBasicBlock* block, HEnvironment* other) {
9465 ASSERT(!block->IsLoopHeader()); 9496 ASSERT(!block->IsLoopHeader());
9466 ASSERT(values_.length() == other->values_.length()); 9497 ASSERT(values_.length() == other->values_.length());
9498 ASSERT(handler_count_ == other->handler_count_);
9467 9499
9468 int length = values_.length(); 9500 int length = values_.length();
9469 for (int i = 0; i < length; ++i) { 9501 for (int i = 0; i < length; ++i) {
9470 HValue* value = values_[i]; 9502 HValue* value = values_[i];
9471 if (value != NULL && value->IsPhi() && value->block() == block) { 9503 if (value != NULL && value->IsPhi() && value->block() == block) {
9472 // There is already a phi for the i'th value. 9504 // There is already a phi for the i'th value.
9473 HPhi* phi = HPhi::cast(value); 9505 HPhi* phi = HPhi::cast(value);
9474 // Assert index is correct and that we haven't missed an incoming edge. 9506 // Assert index is correct and that we haven't missed an incoming edge.
9475 ASSERT(phi->merged_index() == i); 9507 ASSERT(phi->merged_index() == i);
9476 ASSERT(phi->OperandCount() == block->predecessors()->length()); 9508 ASSERT(phi->OperandCount() == block->predecessors()->length());
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
9976 } 10008 }
9977 } 10009 }
9978 10010
9979 #ifdef DEBUG 10011 #ifdef DEBUG
9980 if (graph_ != NULL) graph_->Verify(false); // No full verify. 10012 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9981 if (allocator_ != NULL) allocator_->Verify(); 10013 if (allocator_ != NULL) allocator_->Verify();
9982 #endif 10014 #endif
9983 } 10015 }
9984 10016
9985 } } // namespace v8::internal 10017 } } // 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