| 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 2974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2985 case Translation::GETTER_STUB_FRAME: | 2985 case Translation::GETTER_STUB_FRAME: |
| 2986 case Translation::SETTER_STUB_FRAME: | 2986 case Translation::SETTER_STUB_FRAME: |
| 2987 // Peeled off before getting here. | 2987 // Peeled off before getting here. |
| 2988 break; | 2988 break; |
| 2989 | 2989 |
| 2990 case Translation::DUPLICATED_OBJECT: { | 2990 case Translation::DUPLICATED_OBJECT: { |
| 2991 return SlotRef::NewDuplicateObject(iterator->Next()); | 2991 return SlotRef::NewDuplicateObject(iterator->Next()); |
| 2992 } | 2992 } |
| 2993 | 2993 |
| 2994 case Translation::ARGUMENTS_OBJECT: | 2994 case Translation::ARGUMENTS_OBJECT: |
| 2995 // This can be only emitted for local slots not for argument slots. | 2995 return SlotRef::NewArgumentsObject(iterator->Next()); |
| 2996 break; | |
| 2997 | 2996 |
| 2998 case Translation::CAPTURED_OBJECT: { | 2997 case Translation::CAPTURED_OBJECT: { |
| 2999 return SlotRef::NewDeferredObject(iterator->Next()); | 2998 return SlotRef::NewDeferredObject(iterator->Next()); |
| 3000 } | 2999 } |
| 3001 | 3000 |
| 3002 case Translation::REGISTER: | 3001 case Translation::REGISTER: |
| 3003 case Translation::INT32_REGISTER: | 3002 case Translation::INT32_REGISTER: |
| 3004 case Translation::UINT32_REGISTER: | 3003 case Translation::UINT32_REGISTER: |
| 3005 case Translation::DOUBLE_REGISTER: | 3004 case Translation::DOUBLE_REGISTER: |
| 3006 // We are at safepoint which corresponds to call. All registers are | 3005 // We are at safepoint which corresponds to call. All registers are |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3036 int literal_index = iterator->Next(); | 3035 int literal_index = iterator->Next(); |
| 3037 return SlotRef(data->GetIsolate(), | 3036 return SlotRef(data->GetIsolate(), |
| 3038 data->LiteralArray()->get(literal_index)); | 3037 data->LiteralArray()->get(literal_index)); |
| 3039 } | 3038 } |
| 3040 | 3039 |
| 3041 case Translation::COMPILED_STUB_FRAME: | 3040 case Translation::COMPILED_STUB_FRAME: |
| 3042 UNREACHABLE(); | 3041 UNREACHABLE(); |
| 3043 break; | 3042 break; |
| 3044 } | 3043 } |
| 3045 | 3044 |
| 3046 UNREACHABLE(); | 3045 FATAL("We should never get here - unexpected deopt info."); |
| 3047 return SlotRef(); | 3046 return SlotRef(); |
| 3048 } | 3047 } |
| 3049 | 3048 |
| 3050 | 3049 |
| 3051 SlotRefValueBuilder::SlotRefValueBuilder(JavaScriptFrame* frame, | 3050 SlotRefValueBuilder::SlotRefValueBuilder(JavaScriptFrame* frame, |
| 3052 int inlined_jsframe_index, | 3051 int inlined_jsframe_index, |
| 3053 int formal_parameter_count) | 3052 int formal_parameter_count) |
| 3054 : current_slot_(0), args_length_(-1), first_slot_index_(-1) { | 3053 : current_slot_(0), args_length_(-1), first_slot_index_(-1) { |
| 3055 DisallowHeapAllocation no_gc; | 3054 DisallowHeapAllocation no_gc; |
| 3056 | 3055 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3116 opcode != Translation::GETTER_STUB_FRAME && | 3115 opcode != Translation::GETTER_STUB_FRAME && |
| 3117 opcode != Translation::SETTER_STUB_FRAME && | 3116 opcode != Translation::SETTER_STUB_FRAME && |
| 3118 opcode != Translation::COMPILED_STUB_FRAME) { | 3117 opcode != Translation::COMPILED_STUB_FRAME) { |
| 3119 slot_refs_.Add(ComputeSlotForNextArgument(opcode, &it, data, frame)); | 3118 slot_refs_.Add(ComputeSlotForNextArgument(opcode, &it, data, frame)); |
| 3120 | 3119 |
| 3121 if (first_slot_index_ >= 0) { | 3120 if (first_slot_index_ >= 0) { |
| 3122 // We have found the beginning of our frame -> make sure we count | 3121 // We have found the beginning of our frame -> make sure we count |
| 3123 // the nested slots of captured objects | 3122 // the nested slots of captured objects |
| 3124 number_of_slots--; | 3123 number_of_slots--; |
| 3125 SlotRef& slot = slot_refs_.last(); | 3124 SlotRef& slot = slot_refs_.last(); |
| 3126 if (slot.Representation() == SlotRef::DEFERRED_OBJECT) { | 3125 ASSERT(slot.Representation() != SlotRef::ARGUMENTS_OBJECT); |
| 3127 number_of_slots += slot.DeferredObjectLength(); | 3126 number_of_slots += slot.GetChildrenCount(); |
| 3128 } | |
| 3129 if (slot.Representation() == SlotRef::DEFERRED_OBJECT || | 3127 if (slot.Representation() == SlotRef::DEFERRED_OBJECT || |
| 3130 slot.Representation() == SlotRef::DUPLICATE_OBJECT) { | 3128 slot.Representation() == SlotRef::DUPLICATE_OBJECT) { |
| 3131 should_deopt = true; | 3129 should_deopt = true; |
| 3132 } | 3130 } |
| 3133 } | 3131 } |
| 3134 | 3132 |
| 3135 processed = true; | 3133 processed = true; |
| 3136 } | 3134 } |
| 3137 if (!processed) { | 3135 if (!processed) { |
| 3138 // Skip over operands to advance to the next opcode. | 3136 // Skip over operands to advance to the next opcode. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3172 | 3170 |
| 3173 case DOUBLE: { | 3171 case DOUBLE: { |
| 3174 double value = read_double_value(addr_); | 3172 double value = read_double_value(addr_); |
| 3175 return isolate->factory()->NewNumber(value); | 3173 return isolate->factory()->NewNumber(value); |
| 3176 } | 3174 } |
| 3177 | 3175 |
| 3178 case LITERAL: | 3176 case LITERAL: |
| 3179 return literal_; | 3177 return literal_; |
| 3180 | 3178 |
| 3181 default: | 3179 default: |
| 3182 UNREACHABLE(); | 3180 FATAL("We should never get here - unexpected deopt info."); |
| 3183 return Handle<Object>::null(); | 3181 return Handle<Object>::null(); |
| 3184 } | 3182 } |
| 3185 } | 3183 } |
| 3186 | 3184 |
| 3187 | 3185 |
| 3188 void SlotRefValueBuilder::Prepare(Isolate* isolate) { | 3186 void SlotRefValueBuilder::Prepare(Isolate* isolate) { |
| 3189 MaterializedObjectStore* materialized_store = | 3187 MaterializedObjectStore* materialized_store = |
| 3190 isolate->materialized_object_store(); | 3188 isolate->materialized_object_store(); |
| 3191 previously_materialized_objects_ = materialized_store->Get(stack_frame_id_); | 3189 previously_materialized_objects_ = materialized_store->Get(stack_frame_id_); |
| 3192 prev_materialized_count_ = previously_materialized_objects_.is_null() | 3190 prev_materialized_count_ = previously_materialized_objects_.is_null() |
| 3193 ? 0 : previously_materialized_objects_->length(); | 3191 ? 0 : previously_materialized_objects_->length(); |
| 3194 | 3192 |
| 3195 // Skip any materialized objects of the inlined "parent" frames. | 3193 // Skip any materialized objects of the inlined "parent" frames. |
| 3196 // (Note that we still need to materialize them because they might be | 3194 // (Note that we still need to materialize them because they might be |
| 3197 // referred to as duplicated objects.) | 3195 // referred to as duplicated objects.) |
| 3198 while (current_slot_ < first_slot_index_) { | 3196 while (current_slot_ < first_slot_index_) { |
| 3199 GetNext(isolate, 0); | 3197 GetNext(isolate, 0); |
| 3200 } | 3198 } |
| 3201 ASSERT(current_slot_ == first_slot_index_); | 3199 ASSERT(current_slot_ == first_slot_index_); |
| 3202 } | 3200 } |
| 3203 | 3201 |
| 3204 | 3202 |
| 3205 Handle<Object> SlotRefValueBuilder::GetPreviouslyMaterialized( | 3203 Handle<Object> SlotRefValueBuilder::GetPreviouslyMaterialized( |
| 3206 Isolate* isolate, int length) { | 3204 Isolate* isolate, int length) { |
| 3207 int object_index = materialized_objects_.length(); | 3205 int object_index = materialized_objects_.length(); |
| 3208 Handle<Object> return_value = Handle<Object>( | 3206 Handle<Object> return_value = Handle<Object>( |
| 3209 previously_materialized_objects_->get(object_index), isolate); | 3207 previously_materialized_objects_->get(object_index), isolate); |
| 3210 materialized_objects_.Add(return_value); | 3208 materialized_objects_.Add(return_value); |
| 3211 | 3209 |
| 3212 // Now need to skip all nested objects (and possibly read them from | 3210 // Now need to skip all the nested objects (and possibly read them from |
| 3213 // the materialization store, too) | 3211 // the materialization store, too). |
| 3214 for (int i = 0; i < length; i++) { | 3212 for (int i = 0; i < length; i++) { |
| 3215 SlotRef& slot = slot_refs_[current_slot_]; | 3213 SlotRef& slot = slot_refs_[current_slot_]; |
| 3216 current_slot_++; | 3214 current_slot_++; |
| 3217 | 3215 |
| 3218 // For nested deferred objects, we need to read its properties | 3216 // We need to read all the nested objects - add them to the |
| 3219 if (slot.Representation() == SlotRef::DEFERRED_OBJECT) { | 3217 // number of objects we need to process. |
| 3220 length += slot.DeferredObjectLength(); | 3218 length += slot.GetChildrenCount(); |
| 3221 } | |
| 3222 | 3219 |
| 3223 // For nested deferred and duplicate objects, we need to put them into | 3220 // Put the nested deferred/duplicate objects into our materialization |
| 3224 // our materialization array | 3221 // array. |
| 3225 if (slot.Representation() == SlotRef::DEFERRED_OBJECT || | 3222 if (slot.Representation() == SlotRef::DEFERRED_OBJECT || |
| 3226 slot.Representation() == SlotRef::DUPLICATE_OBJECT) { | 3223 slot.Representation() == SlotRef::DUPLICATE_OBJECT) { |
| 3227 int nested_object_index = materialized_objects_.length(); | 3224 int nested_object_index = materialized_objects_.length(); |
| 3228 Handle<Object> nested_object = Handle<Object>( | 3225 Handle<Object> nested_object = Handle<Object>( |
| 3229 previously_materialized_objects_->get(nested_object_index), | 3226 previously_materialized_objects_->get(nested_object_index), |
| 3230 isolate); | 3227 isolate); |
| 3231 materialized_objects_.Add(nested_object); | 3228 materialized_objects_.Add(nested_object); |
| 3232 } | 3229 } |
| 3233 } | 3230 } |
| 3234 | 3231 |
| 3235 return return_value; | 3232 return return_value; |
| 3236 } | 3233 } |
| 3237 | 3234 |
| 3238 | 3235 |
| 3239 Handle<Object> SlotRefValueBuilder::GetNext(Isolate* isolate, int lvl) { | 3236 Handle<Object> SlotRefValueBuilder::GetNext(Isolate* isolate, int lvl) { |
| 3240 SlotRef& slot = slot_refs_[current_slot_]; | 3237 SlotRef& slot = slot_refs_[current_slot_]; |
| 3241 current_slot_++; | 3238 current_slot_++; |
| 3242 switch (slot.Representation()) { | 3239 switch (slot.Representation()) { |
| 3243 case SlotRef::TAGGED: | 3240 case SlotRef::TAGGED: |
| 3244 case SlotRef::INT32: | 3241 case SlotRef::INT32: |
| 3245 case SlotRef::UINT32: | 3242 case SlotRef::UINT32: |
| 3246 case SlotRef::DOUBLE: | 3243 case SlotRef::DOUBLE: |
| 3247 case SlotRef::LITERAL: { | 3244 case SlotRef::LITERAL: { |
| 3248 return slot.GetValue(isolate); | 3245 return slot.GetValue(isolate); |
| 3249 } | 3246 } |
| 3247 case SlotRef::ARGUMENTS_OBJECT: { |
| 3248 // We should never need to materialize an arguments object, |
| 3249 // but we still need to put something into the array |
| 3250 // so that the indexing is consistent. |
| 3251 materialized_objects_.Add(isolate->factory()->undefined_value()); |
| 3252 int length = slot.GetChildrenCount(); |
| 3253 for (int i = 0; i < length; ++i) { |
| 3254 // We don't need the argument, just ignore it |
| 3255 GetNext(isolate, lvl + 1); |
| 3256 } |
| 3257 return isolate->factory()->undefined_value(); |
| 3258 } |
| 3250 case SlotRef::DEFERRED_OBJECT: { | 3259 case SlotRef::DEFERRED_OBJECT: { |
| 3251 int length = slot.DeferredObjectLength(); | 3260 int length = slot.GetChildrenCount(); |
| 3252 ASSERT(slot_refs_[current_slot_].Representation() == SlotRef::LITERAL || | 3261 ASSERT(slot_refs_[current_slot_].Representation() == SlotRef::LITERAL || |
| 3253 slot_refs_[current_slot_].Representation() == SlotRef::TAGGED); | 3262 slot_refs_[current_slot_].Representation() == SlotRef::TAGGED); |
| 3254 | 3263 |
| 3255 int object_index = materialized_objects_.length(); | 3264 int object_index = materialized_objects_.length(); |
| 3256 if (object_index < prev_materialized_count_) { | 3265 if (object_index < prev_materialized_count_) { |
| 3257 return GetPreviouslyMaterialized(isolate, length); | 3266 return GetPreviouslyMaterialized(isolate, length); |
| 3258 } | 3267 } |
| 3259 | 3268 |
| 3260 Handle<Object> map_object = slot_refs_[current_slot_].GetValue(isolate); | 3269 Handle<Object> map_object = slot_refs_[current_slot_].GetValue(isolate); |
| 3261 Handle<Map> map = Map::GeneralizeAllFieldRepresentations( | 3270 Handle<Map> map = Map::GeneralizeAllFieldRepresentations( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3310 int object_index = slot.DuplicateObjectId(); | 3319 int object_index = slot.DuplicateObjectId(); |
| 3311 Handle<Object> object = materialized_objects_[object_index]; | 3320 Handle<Object> object = materialized_objects_[object_index]; |
| 3312 materialized_objects_.Add(object); | 3321 materialized_objects_.Add(object); |
| 3313 return object; | 3322 return object; |
| 3314 } | 3323 } |
| 3315 default: | 3324 default: |
| 3316 UNREACHABLE(); | 3325 UNREACHABLE(); |
| 3317 break; | 3326 break; |
| 3318 } | 3327 } |
| 3319 | 3328 |
| 3320 UNREACHABLE(); | 3329 FATAL("We should never get here - unexpected deopt slot kind."); |
| 3321 return Handle<Object>::null(); | 3330 return Handle<Object>::null(); |
| 3322 } | 3331 } |
| 3323 | 3332 |
| 3324 | 3333 |
| 3325 void SlotRefValueBuilder::Finish(Isolate* isolate) { | 3334 void SlotRefValueBuilder::Finish(Isolate* isolate) { |
| 3326 // We should have processed all slot | 3335 // We should have processed all slot |
| 3327 ASSERT(slot_refs_.length() == current_slot_); | 3336 ASSERT(slot_refs_.length() == current_slot_); |
| 3328 | 3337 |
| 3329 if (materialized_objects_.length() > prev_materialized_count_) { | 3338 if (materialized_objects_.length() > prev_materialized_count_) { |
| 3330 // We have materialized some new objects, so we have to store them | 3339 // We have materialized some new objects, so we have to store them |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3457 | 3466 |
| 3458 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 3467 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
| 3459 v->VisitPointer(BitCast<Object**>(&function_)); | 3468 v->VisitPointer(BitCast<Object**>(&function_)); |
| 3460 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 3469 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
| 3461 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 3470 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
| 3462 } | 3471 } |
| 3463 | 3472 |
| 3464 #endif // ENABLE_DEBUGGER_SUPPORT | 3473 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3465 | 3474 |
| 3466 } } // namespace v8::internal | 3475 } } // namespace v8::internal |
| OLD | NEW |