OLD | NEW |
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 | 100 |
101 void LCodeGen::FinishCode(Handle<Code> code) { | 101 void LCodeGen::FinishCode(Handle<Code> code) { |
102 ASSERT(is_done()); | 102 ASSERT(is_done()); |
103 code->set_stack_slots(GetStackSlotCount()); | 103 code->set_stack_slots(GetStackSlotCount()); |
104 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); | 104 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
105 if (FLAG_weak_embedded_maps_in_optimized_code) { | 105 if (FLAG_weak_embedded_maps_in_optimized_code) { |
106 RegisterDependentCodeForEmbeddedMaps(code); | 106 RegisterDependentCodeForEmbeddedMaps(code); |
107 } | 107 } |
108 PopulateDeoptimizationData(code); | 108 PopulateDeoptimizationData(code); |
| 109 PopulateDeoptCounterCells(code); |
109 if (!info()->IsStub()) { | 110 if (!info()->IsStub()) { |
110 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); | 111 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); |
111 } | 112 } |
112 for (int i = 0 ; i < prototype_maps_.length(); i++) { | 113 for (int i = 0 ; i < prototype_maps_.length(); i++) { |
113 prototype_maps_.at(i)->AddDependentCode( | 114 prototype_maps_.at(i)->AddDependentCode( |
114 DependentCode::kPrototypeCheckGroup, code); | 115 DependentCode::kPrototypeCheckGroup, code); |
115 } | 116 } |
116 for (int i = 0 ; i < transition_maps_.length(); i++) { | 117 for (int i = 0 ; i < transition_maps_.length(); i++) { |
117 transition_maps_.at(i)->AddDependentCode( | 118 transition_maps_.at(i)->AddDependentCode( |
118 DependentCode::kTransitionGroup, code); | 119 DependentCode::kTransitionGroup, code); |
(...skipping 6264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6383 | 6384 |
6384 void LCodeGen::DoLazyBailout(LLazyBailout* instr) { | 6385 void LCodeGen::DoLazyBailout(LLazyBailout* instr) { |
6385 EnsureSpaceForLazyDeopt(); | 6386 EnsureSpaceForLazyDeopt(); |
6386 ASSERT(instr->HasEnvironment()); | 6387 ASSERT(instr->HasEnvironment()); |
6387 LEnvironment* env = instr->environment(); | 6388 LEnvironment* env = instr->environment(); |
6388 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); | 6389 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
6389 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); | 6390 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
6390 } | 6391 } |
6391 | 6392 |
6392 | 6393 |
| 6394 void LCodeGen::DoDeoptCounter(LDeoptCounter* instr) { |
| 6395 Handle<JSGlobalPropertyCell> cell = |
| 6396 isolate()->factory()->NewJSGlobalPropertyCell( |
| 6397 Handle<Object>(Smi::FromInt(instr->initial_value()), isolate())); |
| 6398 LDeoptCounterCell* deopt_cell = |
| 6399 new(zone()) LDeoptCounterCell(instr->id(), instr->max_value(), cell); |
| 6400 deopt_counter_cells_.Add(deopt_cell, zone()); |
| 6401 } |
| 6402 |
| 6403 |
| 6404 void LCodeGen::DoDeoptCounterAdd(LDeoptCounterAdd* instr) { |
| 6405 for (int i = 0; i < deopt_counter_cells_.length(); ++i) { |
| 6406 LDeoptCounterCell* deopt_cell = deopt_counter_cells_[i]; |
| 6407 if (deopt_cell->id() != instr->counter()) continue; |
| 6408 |
| 6409 Handle<JSGlobalPropertyCell> cell = deopt_cell->cell(); |
| 6410 Register scratch = ToRegister(instr->temp()); |
| 6411 Register scratch2 = ToRegister(instr->temp2()); |
| 6412 |
| 6413 // Increment counter |
| 6414 Label ok; |
| 6415 Operand counter = FieldOperand(scratch, |
| 6416 JSGlobalPropertyCell::kValueOffset); |
| 6417 |
| 6418 ASSERT(instr->delta() != 0); |
| 6419 __ LoadHeapObject(scratch, cell); |
| 6420 __ mov(scratch2, counter); |
| 6421 __ AssertSmi(scratch2); |
| 6422 __ add(scratch2, Immediate(Smi::FromInt(instr->delta()))); |
| 6423 __ cmp(scratch2, Immediate(Smi::FromInt(deopt_cell->max_value()))); |
| 6424 __ j(less_equal, &ok, Label::kNear); |
| 6425 |
| 6426 // Limit counter |
| 6427 __ mov(scratch2, Immediate(Smi::FromInt(deopt_cell->max_value()))); |
| 6428 __ bind(&ok); |
| 6429 __ mov(counter, scratch2); |
| 6430 |
| 6431 // And deoptimize on negative value |
| 6432 __ cmp(scratch2, Immediate(Smi::FromInt(0))); |
| 6433 DeoptimizeIf(less_equal, instr->environment(), Deoptimizer::SOFT); |
| 6434 return; |
| 6435 } |
| 6436 UNREACHABLE(); |
| 6437 } |
| 6438 |
| 6439 |
6393 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { | 6440 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { |
6394 if (instr->hydrogen_value()->IsSoftDeoptimize()) { | 6441 if (instr->hydrogen_value()->IsSoftDeoptimize()) { |
6395 SoftDeoptimize(instr->environment()); | 6442 SoftDeoptimize(instr->environment()); |
6396 } else { | 6443 } else { |
6397 DeoptimizeIf(no_condition, instr->environment()); | 6444 DeoptimizeIf(no_condition, instr->environment()); |
6398 } | 6445 } |
6399 } | 6446 } |
6400 | 6447 |
6401 | 6448 |
6402 void LCodeGen::DoDummyUse(LDummyUse* instr) { | 6449 void LCodeGen::DoDummyUse(LDummyUse* instr) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6601 FixedArray::kHeaderSize - kPointerSize)); | 6648 FixedArray::kHeaderSize - kPointerSize)); |
6602 __ bind(&done); | 6649 __ bind(&done); |
6603 } | 6650 } |
6604 | 6651 |
6605 | 6652 |
6606 #undef __ | 6653 #undef __ |
6607 | 6654 |
6608 } } // namespace v8::internal | 6655 } } // namespace v8::internal |
6609 | 6656 |
6610 #endif // V8_TARGET_ARCH_IA32 | 6657 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |