| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 | 81 |
| 82 void LCodeGen::FinishCode(Handle<Code> code) { | 82 void LCodeGen::FinishCode(Handle<Code> code) { |
| 83 ASSERT(is_done()); | 83 ASSERT(is_done()); |
| 84 code->set_stack_slots(GetStackSlotCount()); | 84 code->set_stack_slots(GetStackSlotCount()); |
| 85 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); | 85 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
| 86 if (FLAG_weak_embedded_maps_in_optimized_code) { | 86 if (FLAG_weak_embedded_maps_in_optimized_code) { |
| 87 RegisterDependentCodeForEmbeddedMaps(code); | 87 RegisterDependentCodeForEmbeddedMaps(code); |
| 88 } | 88 } |
| 89 PopulateDeoptimizationData(code); | 89 PopulateDeoptimizationData(code); |
| 90 PopulateDeoptCounterCells(code); |
| 90 for (int i = 0 ; i < prototype_maps_.length(); i++) { | 91 for (int i = 0 ; i < prototype_maps_.length(); i++) { |
| 91 prototype_maps_.at(i)->AddDependentCode( | 92 prototype_maps_.at(i)->AddDependentCode( |
| 92 DependentCode::kPrototypeCheckGroup, code); | 93 DependentCode::kPrototypeCheckGroup, code); |
| 93 } | 94 } |
| 94 for (int i = 0 ; i < transition_maps_.length(); i++) { | 95 for (int i = 0 ; i < transition_maps_.length(); i++) { |
| 95 transition_maps_.at(i)->AddDependentCode( | 96 transition_maps_.at(i)->AddDependentCode( |
| 96 DependentCode::kTransitionGroup, code); | 97 DependentCode::kTransitionGroup, code); |
| 97 } | 98 } |
| 98 if (graph()->depends_on_empty_array_proto_elements()) { | 99 if (graph()->depends_on_empty_array_proto_elements()) { |
| 99 isolate()->initial_object_prototype()->map()->AddDependentCode( | 100 isolate()->initial_object_prototype()->map()->AddDependentCode( |
| (...skipping 5687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5787 | 5788 |
| 5788 void LCodeGen::DoLazyBailout(LLazyBailout* instr) { | 5789 void LCodeGen::DoLazyBailout(LLazyBailout* instr) { |
| 5789 EnsureSpaceForLazyDeopt(); | 5790 EnsureSpaceForLazyDeopt(); |
| 5790 ASSERT(instr->HasEnvironment()); | 5791 ASSERT(instr->HasEnvironment()); |
| 5791 LEnvironment* env = instr->environment(); | 5792 LEnvironment* env = instr->environment(); |
| 5792 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); | 5793 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
| 5793 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); | 5794 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
| 5794 } | 5795 } |
| 5795 | 5796 |
| 5796 | 5797 |
| 5798 void LCodeGen::DoDeoptCounter(LDeoptCounter* instr) { |
| 5799 Handle<JSGlobalPropertyCell> cell = |
| 5800 isolate()->factory()->NewJSGlobalPropertyCell( |
| 5801 Handle<Object>(Smi::FromInt(instr->initial_value()), isolate())); |
| 5802 LDeoptCounterCell* deopt_cell = |
| 5803 new(zone()) LDeoptCounterCell(instr->id(), instr->max_value(), cell); |
| 5804 deopt_counter_cells_.Add(deopt_cell, zone()); |
| 5805 } |
| 5806 |
| 5807 |
| 5808 void LCodeGen::DoDeoptCounterAdd(LDeoptCounterAdd* instr) { |
| 5809 for (int i = 0; i < deopt_counter_cells_.length(); ++i) { |
| 5810 LDeoptCounterCell* deopt_cell = deopt_counter_cells_[i]; |
| 5811 if (deopt_cell->id() != instr->counter()) continue; |
| 5812 |
| 5813 Handle<JSGlobalPropertyCell> cell = deopt_cell->cell(); |
| 5814 Register scratch = ToRegister(instr->temp()); |
| 5815 Register scratch2 = ToRegister(instr->temp2()); |
| 5816 |
| 5817 // Increment counter |
| 5818 Label ok; |
| 5819 MemOperand counter = MemOperand(scratch, |
| 5820 JSGlobalPropertyCell::kValueOffset); |
| 5821 |
| 5822 ASSERT(instr->delta() != 0); |
| 5823 __ LoadHeapObject(scratch, cell); |
| 5824 __ ldr(scratch2, counter); |
| 5825 __ AssertSmi(scratch2); |
| 5826 __ add(scratch2, scratch2, Operand(Smi::FromInt(instr->delta()))); |
| 5827 __ cmp(scratch2, Operand(Smi::FromInt(deopt_cell->max_value()))); |
| 5828 __ b(le, &ok); |
| 5829 |
| 5830 // Limit counter |
| 5831 __ mov(scratch2, Operand(Smi::FromInt(deopt_cell->max_value()))); |
| 5832 __ bind(&ok); |
| 5833 |
| 5834 // Update cell value |
| 5835 __ str(scratch2, counter); |
| 5836 |
| 5837 // And deoptimize on negative value |
| 5838 __ cmp(scratch2, Operand(Smi::FromInt(0))); |
| 5839 DeoptimizeIf(le, instr->environment(), Deoptimizer::SOFT); |
| 5840 return; |
| 5841 } |
| 5842 UNREACHABLE(); |
| 5843 } |
| 5844 |
| 5845 |
| 5797 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { | 5846 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { |
| 5798 if (instr->hydrogen_value()->IsSoftDeoptimize()) { | 5847 if (instr->hydrogen_value()->IsSoftDeoptimize()) { |
| 5799 SoftDeoptimize(instr->environment()); | 5848 SoftDeoptimize(instr->environment()); |
| 5800 } else { | 5849 } else { |
| 5801 DeoptimizeIf(al, instr->environment()); | 5850 DeoptimizeIf(al, instr->environment()); |
| 5802 } | 5851 } |
| 5803 } | 5852 } |
| 5804 | 5853 |
| 5805 | 5854 |
| 5806 void LCodeGen::DoDummyUse(LDummyUse* instr) { | 5855 void LCodeGen::DoDummyUse(LDummyUse* instr) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6000 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 6049 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
| 6001 __ ldr(result, FieldMemOperand(scratch, | 6050 __ ldr(result, FieldMemOperand(scratch, |
| 6002 FixedArray::kHeaderSize - kPointerSize)); | 6051 FixedArray::kHeaderSize - kPointerSize)); |
| 6003 __ bind(&done); | 6052 __ bind(&done); |
| 6004 } | 6053 } |
| 6005 | 6054 |
| 6006 | 6055 |
| 6007 #undef __ | 6056 #undef __ |
| 6008 | 6057 |
| 6009 } } // namespace v8::internal | 6058 } } // namespace v8::internal |
| OLD | NEW |