| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 660 |
| 661 | 661 |
| 662 #undef DEFINE_GET_CONSTANT | 662 #undef DEFINE_GET_CONSTANT |
| 663 | 663 |
| 664 | 664 |
| 665 HConstant* HGraph::GetInvalidContext() { | 665 HConstant* HGraph::GetInvalidContext() { |
| 666 return GetConstant(&constant_invalid_context_, 0xFFFFC0C7); | 666 return GetConstant(&constant_invalid_context_, 0xFFFFC0C7); |
| 667 } | 667 } |
| 668 | 668 |
| 669 | 669 |
| 670 bool HGraph::IsStandardConstant(HConstant* constant) { |
| 671 if (constant == GetConstantUndefined()) return true; |
| 672 if (constant == GetConstant0()) return true; |
| 673 if (constant == GetConstant1()) return true; |
| 674 if (constant == GetConstantMinus1()) return true; |
| 675 if (constant == GetConstantTrue()) return true; |
| 676 if (constant == GetConstantFalse()) return true; |
| 677 if (constant == GetConstantHole()) return true; |
| 678 if (constant == GetConstantNull()) return true; |
| 679 return false; |
| 680 } |
| 681 |
| 682 |
| 670 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, int position) | 683 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, int position) |
| 671 : builder_(builder), | 684 : builder_(builder), |
| 672 position_(position), | 685 position_(position), |
| 673 finished_(false), | 686 finished_(false), |
| 674 did_then_(false), | 687 did_then_(false), |
| 675 did_else_(false), | 688 did_else_(false), |
| 676 did_and_(false), | 689 did_and_(false), |
| 677 did_or_(false), | 690 did_or_(false), |
| 678 captured_(false), | 691 captured_(false), |
| 679 needs_compare_(true), | 692 needs_compare_(true), |
| (...skipping 3766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4446 } | 4459 } |
| 4447 } | 4460 } |
| 4448 | 4461 |
| 4449 | 4462 |
| 4450 void HOptimizedGraphBuilder::PushAndAdd(HInstruction* instr) { | 4463 void HOptimizedGraphBuilder::PushAndAdd(HInstruction* instr) { |
| 4451 Push(instr); | 4464 Push(instr); |
| 4452 AddInstruction(instr); | 4465 AddInstruction(instr); |
| 4453 } | 4466 } |
| 4454 | 4467 |
| 4455 | 4468 |
| 4456 void HOptimizedGraphBuilder::AddSoftDeoptimize() { | 4469 void HOptimizedGraphBuilder::AddSoftDeoptimize(SoftDeoptimizeMode mode) { |
| 4457 isolate()->counters()->soft_deopts_requested()->Increment(); | 4470 isolate()->counters()->soft_deopts_requested()->Increment(); |
| 4458 if (FLAG_always_opt) return; | 4471 if (FLAG_always_opt && mode == CAN_OMIT_SOFT_DEOPT) return; |
| 4459 if (current_block()->IsDeoptimizing()) return; | 4472 if (current_block()->IsDeoptimizing()) return; |
| 4460 Add<HSoftDeoptimize>(); | 4473 Add<HSoftDeoptimize>(); |
| 4461 isolate()->counters()->soft_deopts_inserted()->Increment(); | 4474 isolate()->counters()->soft_deopts_inserted()->Increment(); |
| 4462 current_block()->MarkAsDeoptimizing(); | 4475 current_block()->MarkAsDeoptimizing(); |
| 4463 graph()->set_has_soft_deoptimize(true); | 4476 graph()->set_has_soft_deoptimize(true); |
| 4464 } | 4477 } |
| 4465 | 4478 |
| 4466 | 4479 |
| 4467 template <class Instruction> | 4480 template <class Instruction> |
| 4468 HInstruction* HOptimizedGraphBuilder::PreProcessCall(Instruction* call) { | 4481 HInstruction* HOptimizedGraphBuilder::PreProcessCall(Instruction* call) { |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5401 LookupGlobalProperty(variable, &lookup, false); | 5414 LookupGlobalProperty(variable, &lookup, false); |
| 5402 | 5415 |
| 5403 if (type == kUseCell && | 5416 if (type == kUseCell && |
| 5404 current_info()->global_object()->IsAccessCheckNeeded()) { | 5417 current_info()->global_object()->IsAccessCheckNeeded()) { |
| 5405 type = kUseGeneric; | 5418 type = kUseGeneric; |
| 5406 } | 5419 } |
| 5407 | 5420 |
| 5408 if (type == kUseCell) { | 5421 if (type == kUseCell) { |
| 5409 Handle<GlobalObject> global(current_info()->global_object()); | 5422 Handle<GlobalObject> global(current_info()->global_object()); |
| 5410 Handle<PropertyCell> cell(global->GetPropertyCell(&lookup)); | 5423 Handle<PropertyCell> cell(global->GetPropertyCell(&lookup)); |
| 5411 HLoadGlobalCell* instr = | 5424 if (cell->type()->IsConstant()) { |
| 5412 new(zone()) HLoadGlobalCell(cell, lookup.GetPropertyDetails()); | 5425 cell->AddDependentCompilationInfo(top_info()); |
| 5413 return ast_context()->ReturnInstruction(instr, expr->id()); | 5426 Handle<Object> constant_object = cell->type()->AsConstant(); |
| 5427 if (constant_object->IsConsString()) { |
| 5428 constant_object = |
| 5429 FlattenGetString(Handle<String>::cast(constant_object)); |
| 5430 } |
| 5431 HConstant* constant = new(zone()) HConstant(constant_object); |
| 5432 return ast_context()->ReturnInstruction(constant, expr->id()); |
| 5433 } else { |
| 5434 HLoadGlobalCell* instr = |
| 5435 new(zone()) HLoadGlobalCell(cell, lookup.GetPropertyDetails()); |
| 5436 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 5437 } |
| 5414 } else { | 5438 } else { |
| 5415 HValue* context = environment()->LookupContext(); | 5439 HValue* context = environment()->LookupContext(); |
| 5416 HGlobalObject* global_object = new(zone()) HGlobalObject(context); | 5440 HGlobalObject* global_object = new(zone()) HGlobalObject(context); |
| 5417 AddInstruction(global_object); | 5441 AddInstruction(global_object); |
| 5418 HLoadGlobalGeneric* instr = | 5442 HLoadGlobalGeneric* instr = |
| 5419 new(zone()) HLoadGlobalGeneric(context, | 5443 new(zone()) HLoadGlobalGeneric(context, |
| 5420 global_object, | 5444 global_object, |
| 5421 variable->name(), | 5445 variable->name(), |
| 5422 ast_context()->is_for_typeof()); | 5446 ast_context()->is_for_typeof()); |
| 5423 instr->set_position(expr->position()); | 5447 instr->set_position(expr->position()); |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6310 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( | 6334 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( |
| 6311 Variable* var, | 6335 Variable* var, |
| 6312 HValue* value, | 6336 HValue* value, |
| 6313 int position, | 6337 int position, |
| 6314 BailoutId ast_id) { | 6338 BailoutId ast_id) { |
| 6315 LookupResult lookup(isolate()); | 6339 LookupResult lookup(isolate()); |
| 6316 GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, true); | 6340 GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, true); |
| 6317 if (type == kUseCell) { | 6341 if (type == kUseCell) { |
| 6318 Handle<GlobalObject> global(current_info()->global_object()); | 6342 Handle<GlobalObject> global(current_info()->global_object()); |
| 6319 Handle<PropertyCell> cell(global->GetPropertyCell(&lookup)); | 6343 Handle<PropertyCell> cell(global->GetPropertyCell(&lookup)); |
| 6320 HInstruction* instr = Add<HStoreGlobalCell>(value, cell, | 6344 if (cell->type()->IsConstant()) { |
| 6321 lookup.GetPropertyDetails()); | 6345 IfBuilder builder(this); |
| 6346 HValue* constant = Add<HConstant>(cell->type()->AsConstant()); |
| 6347 if (cell->type()->AsConstant()->IsNumber()) { |
| 6348 builder.IfCompare(value, constant, Token::EQ); |
| 6349 } else { |
| 6350 builder.If<HCompareObjectEqAndBranch>(value, constant); |
| 6351 } |
| 6352 builder.Then(); |
| 6353 builder.Else(); |
| 6354 AddSoftDeoptimize(MUST_EMIT_SOFT_DEOPT); |
| 6355 builder.End(); |
| 6356 } |
| 6357 HInstruction* instr = |
| 6358 Add<HStoreGlobalCell>(value, cell, lookup.GetPropertyDetails()); |
| 6322 instr->set_position(position); | 6359 instr->set_position(position); |
| 6323 if (instr->HasObservableSideEffects()) { | 6360 if (instr->HasObservableSideEffects()) { |
| 6324 AddSimulate(ast_id, REMOVABLE_SIMULATE); | 6361 AddSimulate(ast_id, REMOVABLE_SIMULATE); |
| 6325 } | 6362 } |
| 6326 } else { | 6363 } else { |
| 6327 HValue* context = environment()->LookupContext(); | 6364 HValue* context = environment()->LookupContext(); |
| 6328 HGlobalObject* global_object = Add<HGlobalObject>(context); | 6365 HGlobalObject* global_object = Add<HGlobalObject>(context); |
| 6329 HStoreGlobalGeneric* instr = | 6366 HStoreGlobalGeneric* instr = |
| 6330 Add<HStoreGlobalGeneric>(context, global_object, var->name(), | 6367 Add<HStoreGlobalGeneric>(context, global_object, var->name(), |
| 6331 value, function_strict_mode_flag()); | 6368 value, function_strict_mode_flag()); |
| (...skipping 4912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11244 if (ShouldProduceTraceOutput()) { | 11281 if (ShouldProduceTraceOutput()) { |
| 11245 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11282 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 11246 } | 11283 } |
| 11247 | 11284 |
| 11248 #ifdef DEBUG | 11285 #ifdef DEBUG |
| 11249 graph_->Verify(false); // No full verify. | 11286 graph_->Verify(false); // No full verify. |
| 11250 #endif | 11287 #endif |
| 11251 } | 11288 } |
| 11252 | 11289 |
| 11253 } } // namespace v8::internal | 11290 } } // namespace v8::internal |
| OLD | NEW |