OLD | NEW |
1 // Copyright 2013 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 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 | 86 |
87 void LCodeGen::FinishCode(Handle<Code> code) { | 87 void LCodeGen::FinishCode(Handle<Code> code) { |
88 ASSERT(is_done()); | 88 ASSERT(is_done()); |
89 code->set_stack_slots(GetStackSlotCount()); | 89 code->set_stack_slots(GetStackSlotCount()); |
90 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); | 90 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
91 if (FLAG_weak_embedded_maps_in_optimized_code) { | 91 if (FLAG_weak_embedded_maps_in_optimized_code) { |
92 RegisterDependentCodeForEmbeddedMaps(code); | 92 RegisterDependentCodeForEmbeddedMaps(code); |
93 } | 93 } |
94 PopulateDeoptimizationData(code); | 94 PopulateDeoptimizationData(code); |
| 95 PopulateDeoptCounterCells(code); |
95 for (int i = 0 ; i < prototype_maps_.length(); i++) { | 96 for (int i = 0 ; i < prototype_maps_.length(); i++) { |
96 prototype_maps_.at(i)->AddDependentCode( | 97 prototype_maps_.at(i)->AddDependentCode( |
97 DependentCode::kPrototypeCheckGroup, code); | 98 DependentCode::kPrototypeCheckGroup, code); |
98 } | 99 } |
99 for (int i = 0 ; i < transition_maps_.length(); i++) { | 100 for (int i = 0 ; i < transition_maps_.length(); i++) { |
100 transition_maps_.at(i)->AddDependentCode( | 101 transition_maps_.at(i)->AddDependentCode( |
101 DependentCode::kTransitionGroup, code); | 102 DependentCode::kTransitionGroup, code); |
102 } | 103 } |
103 if (graph()->depends_on_empty_array_proto_elements()) { | 104 if (graph()->depends_on_empty_array_proto_elements()) { |
104 isolate()->initial_object_prototype()->map()->AddDependentCode( | 105 isolate()->initial_object_prototype()->map()->AddDependentCode( |
(...skipping 5379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5484 void LCodeGen::DoLazyBailout(LLazyBailout* instr) { | 5485 void LCodeGen::DoLazyBailout(LLazyBailout* instr) { |
5485 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); | 5486 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); |
5486 last_lazy_deopt_pc_ = masm()->pc_offset(); | 5487 last_lazy_deopt_pc_ = masm()->pc_offset(); |
5487 ASSERT(instr->HasEnvironment()); | 5488 ASSERT(instr->HasEnvironment()); |
5488 LEnvironment* env = instr->environment(); | 5489 LEnvironment* env = instr->environment(); |
5489 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); | 5490 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
5490 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); | 5491 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
5491 } | 5492 } |
5492 | 5493 |
5493 | 5494 |
| 5495 void LCodeGen::DoDeoptCounter(LDeoptCounter* instr) { |
| 5496 Handle<JSGlobalPropertyCell> cell = |
| 5497 isolate()->factory()->NewJSGlobalPropertyCell( |
| 5498 Handle<Object>(Smi::FromInt(instr->initial_value()), isolate())); |
| 5499 LDeoptCounterCell* deopt_cell = |
| 5500 new(zone()) LDeoptCounterCell(instr->id(), instr->max_value(), cell); |
| 5501 deopt_counter_cells_.Add(deopt_cell, zone()); |
| 5502 } |
| 5503 |
| 5504 |
| 5505 void LCodeGen::DoDeoptCounterAdd(LDeoptCounterAdd* instr) { |
| 5506 for (int i = 0; i < deopt_counter_cells_.length(); ++i) { |
| 5507 LDeoptCounterCell* deopt_cell = deopt_counter_cells_[i]; |
| 5508 if (deopt_cell->id() != instr->counter()) continue; |
| 5509 |
| 5510 Handle<JSGlobalPropertyCell> cell = deopt_cell->cell(); |
| 5511 Register scratch = ToRegister(instr->temp()); |
| 5512 Register scratch2 = ToRegister(instr->temp2()); |
| 5513 |
| 5514 // Increment counter |
| 5515 Label ok; |
| 5516 Operand counter = FieldOperand(scratch, |
| 5517 JSGlobalPropertyCell::kValueOffset); |
| 5518 |
| 5519 ASSERT(instr->delta() != 0); |
| 5520 __ LoadHeapObject(scratch, cell); |
| 5521 __ movq(scratch2, counter); |
| 5522 __ AssertSmi(scratch2); |
| 5523 __ SmiAddConstant(scratch2, scratch2, Smi::FromInt(instr->delta())); |
| 5524 __ SmiCompare(scratch2, Smi::FromInt(deopt_cell->max_value())); |
| 5525 __ j(less_equal, &ok, Label::kNear); |
| 5526 |
| 5527 // Limit counter |
| 5528 __ Move(scratch2, Smi::FromInt(deopt_cell->max_value())); |
| 5529 __ bind(&ok); |
| 5530 __ movq(counter, scratch2); |
| 5531 |
| 5532 // And deoptimize on negative value |
| 5533 __ SmiCompare(scratch2, Smi::FromInt(0)); |
| 5534 DeoptimizeIf(less_equal, instr->environment(), Deoptimizer::SOFT); |
| 5535 return; |
| 5536 } |
| 5537 UNREACHABLE(); |
| 5538 } |
| 5539 |
| 5540 |
5494 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { | 5541 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { |
5495 if (instr->hydrogen_value()->IsSoftDeoptimize()) { | 5542 if (instr->hydrogen_value()->IsSoftDeoptimize()) { |
5496 SoftDeoptimize(instr->environment()); | 5543 SoftDeoptimize(instr->environment()); |
5497 } else { | 5544 } else { |
5498 DeoptimizeIf(no_condition, instr->environment()); | 5545 DeoptimizeIf(no_condition, instr->environment()); |
5499 } | 5546 } |
5500 } | 5547 } |
5501 | 5548 |
5502 | 5549 |
5503 void LCodeGen::DoDummyUse(LDummyUse* instr) { | 5550 void LCodeGen::DoDummyUse(LDummyUse* instr) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5698 FixedArray::kHeaderSize - kPointerSize)); | 5745 FixedArray::kHeaderSize - kPointerSize)); |
5699 __ bind(&done); | 5746 __ bind(&done); |
5700 } | 5747 } |
5701 | 5748 |
5702 | 5749 |
5703 #undef __ | 5750 #undef __ |
5704 | 5751 |
5705 } } // namespace v8::internal | 5752 } } // namespace v8::internal |
5706 | 5753 |
5707 #endif // V8_TARGET_ARCH_X64 | 5754 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |