| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 GenerateDeferredCode() && | 77 GenerateDeferredCode() && |
| 78 GenerateDeoptJumpTable() && | 78 GenerateDeoptJumpTable() && |
| 79 GenerateSafepointTable(); | 79 GenerateSafepointTable(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 void LCodeGen::FinishCode(Handle<Code> code) { | 83 void LCodeGen::FinishCode(Handle<Code> code) { |
| 84 ASSERT(is_done()); | 84 ASSERT(is_done()); |
| 85 code->set_stack_slots(GetStackSlotCount()); | 85 code->set_stack_slots(GetStackSlotCount()); |
| 86 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); | 86 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
| 87 if (FLAG_weak_embedded_maps_in_optimized_code) { | 87 RegisterDependentCodeForEmbeddedMaps(code); |
| 88 RegisterDependentCodeForEmbeddedMaps(code); | |
| 89 } | |
| 90 PopulateDeoptimizationData(code); | 88 PopulateDeoptimizationData(code); |
| 91 info()->CommitDependencies(code); | 89 info()->CommitDependencies(code); |
| 92 } | 90 } |
| 93 | 91 |
| 94 | 92 |
| 95 void LCodeGen::Abort(BailoutReason reason) { | 93 void LCodeGen::Abort(BailoutReason reason) { |
| 96 info()->set_bailout_reason(reason); | 94 info()->set_bailout_reason(reason); |
| 97 status_ = ABORTED; | 95 status_ = ABORTED; |
| 98 } | 96 } |
| 99 | 97 |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 | 878 |
| 881 void LCodeGen::DeoptimizeIf(Condition condition, | 879 void LCodeGen::DeoptimizeIf(Condition condition, |
| 882 LEnvironment* environment) { | 880 LEnvironment* environment) { |
| 883 Deoptimizer::BailoutType bailout_type = info()->IsStub() | 881 Deoptimizer::BailoutType bailout_type = info()->IsStub() |
| 884 ? Deoptimizer::LAZY | 882 ? Deoptimizer::LAZY |
| 885 : Deoptimizer::EAGER; | 883 : Deoptimizer::EAGER; |
| 886 DeoptimizeIf(condition, environment, bailout_type); | 884 DeoptimizeIf(condition, environment, bailout_type); |
| 887 } | 885 } |
| 888 | 886 |
| 889 | 887 |
| 890 void LCodeGen::RegisterDependentCodeForEmbeddedMaps(Handle<Code> code) { | |
| 891 ZoneList<Handle<Map> > maps(1, zone()); | |
| 892 ZoneList<Handle<JSObject> > objects(1, zone()); | |
| 893 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | |
| 894 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { | |
| 895 if (Code::IsWeakEmbeddedObject(code->kind(), it.rinfo()->target_object())) { | |
| 896 if (it.rinfo()->target_object()->IsMap()) { | |
| 897 Handle<Map> map(Map::cast(it.rinfo()->target_object())); | |
| 898 maps.Add(map, zone()); | |
| 899 } else if (it.rinfo()->target_object()->IsJSObject()) { | |
| 900 Handle<JSObject> object(JSObject::cast(it.rinfo()->target_object())); | |
| 901 objects.Add(object, zone()); | |
| 902 } | |
| 903 } | |
| 904 } | |
| 905 #ifdef VERIFY_HEAP | |
| 906 // This disables verification of weak embedded objects after full GC. | |
| 907 // AddDependentCode can cause a GC, which would observe the state where | |
| 908 // this code is not yet in the depended code lists of the embedded maps. | |
| 909 NoWeakObjectVerificationScope disable_verification_of_embedded_objects; | |
| 910 #endif | |
| 911 for (int i = 0; i < maps.length(); i++) { | |
| 912 maps.at(i)->AddDependentCode(DependentCode::kWeaklyEmbeddedGroup, code); | |
| 913 } | |
| 914 for (int i = 0; i < objects.length(); i++) { | |
| 915 AddWeakObjectToCodeDependency(isolate()->heap(), objects.at(i), code); | |
| 916 } | |
| 917 } | |
| 918 | |
| 919 | |
| 920 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { | 888 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { |
| 921 int length = deoptimizations_.length(); | 889 int length = deoptimizations_.length(); |
| 922 if (length == 0) return; | 890 if (length == 0) return; |
| 923 Handle<DeoptimizationInputData> data = | 891 Handle<DeoptimizationInputData> data = |
| 924 factory()->NewDeoptimizationInputData(length, TENURED); | 892 factory()->NewDeoptimizationInputData(length, TENURED); |
| 925 | 893 |
| 926 Handle<ByteArray> translations = | 894 Handle<ByteArray> translations = |
| 927 translations_.CreateByteArray(isolate()->factory()); | 895 translations_.CreateByteArray(isolate()->factory()); |
| 928 data->SetTranslationByteArray(*translations); | 896 data->SetTranslationByteArray(*translations); |
| 929 data->SetInlinedFunctionCount(Smi::FromInt(inlined_function_count_)); | 897 data->SetInlinedFunctionCount(Smi::FromInt(inlined_function_count_)); |
| (...skipping 4959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5889 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5857 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
| 5890 __ ldr(result, FieldMemOperand(scratch, | 5858 __ ldr(result, FieldMemOperand(scratch, |
| 5891 FixedArray::kHeaderSize - kPointerSize)); | 5859 FixedArray::kHeaderSize - kPointerSize)); |
| 5892 __ bind(&done); | 5860 __ bind(&done); |
| 5893 } | 5861 } |
| 5894 | 5862 |
| 5895 | 5863 |
| 5896 #undef __ | 5864 #undef __ |
| 5897 | 5865 |
| 5898 } } // namespace v8::internal | 5866 } } // namespace v8::internal |
| OLD | NEW |