OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/deoptimizer.h" | 5 #include "src/deoptimizer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 void Translation::BeginArgumentsObject(int args_length) { | 2400 void Translation::BeginArgumentsObject(int args_length) { |
2401 buffer_->Add(ARGUMENTS_OBJECT); | 2401 buffer_->Add(ARGUMENTS_OBJECT); |
2402 buffer_->Add(args_length); | 2402 buffer_->Add(args_length); |
2403 } | 2403 } |
2404 | 2404 |
2405 void Translation::ArgumentsElements(bool is_rest) { | 2405 void Translation::ArgumentsElements(bool is_rest) { |
2406 buffer_->Add(ARGUMENTS_ELEMENTS); | 2406 buffer_->Add(ARGUMENTS_ELEMENTS); |
2407 buffer_->Add(is_rest); | 2407 buffer_->Add(is_rest); |
2408 } | 2408 } |
2409 | 2409 |
| 2410 void Translation::ArgumentsLength(bool is_rest) { |
| 2411 buffer_->Add(ARGUMENTS_LENGTH); |
| 2412 buffer_->Add(is_rest); |
| 2413 } |
| 2414 |
2410 void Translation::BeginCapturedObject(int length) { | 2415 void Translation::BeginCapturedObject(int length) { |
2411 buffer_->Add(CAPTURED_OBJECT); | 2416 buffer_->Add(CAPTURED_OBJECT); |
2412 buffer_->Add(length); | 2417 buffer_->Add(length); |
2413 } | 2418 } |
2414 | 2419 |
2415 | 2420 |
2416 void Translation::DuplicateObject(int object_index) { | 2421 void Translation::DuplicateObject(int object_index) { |
2417 buffer_->Add(DUPLICATED_OBJECT); | 2422 buffer_->Add(DUPLICATED_OBJECT); |
2418 buffer_->Add(object_index); | 2423 buffer_->Add(object_index); |
2419 } | 2424 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 case TAIL_CALLER_FRAME: | 2538 case TAIL_CALLER_FRAME: |
2534 return 1; | 2539 return 1; |
2535 case BEGIN: | 2540 case BEGIN: |
2536 case ARGUMENTS_ADAPTOR_FRAME: | 2541 case ARGUMENTS_ADAPTOR_FRAME: |
2537 return 2; | 2542 return 2; |
2538 case JS_FRAME: | 2543 case JS_FRAME: |
2539 case INTERPRETED_FRAME: | 2544 case INTERPRETED_FRAME: |
2540 case CONSTRUCT_STUB_FRAME: | 2545 case CONSTRUCT_STUB_FRAME: |
2541 return 3; | 2546 return 3; |
2542 case ARGUMENTS_ELEMENTS: | 2547 case ARGUMENTS_ELEMENTS: |
| 2548 case ARGUMENTS_LENGTH: |
2543 return 1; | 2549 return 1; |
2544 } | 2550 } |
2545 FATAL("Unexpected translation type"); | 2551 FATAL("Unexpected translation type"); |
2546 return -1; | 2552 return -1; |
2547 } | 2553 } |
2548 | 2554 |
2549 | 2555 |
2550 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) | 2556 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) |
2551 | 2557 |
2552 const char* Translation::StringFor(Opcode opcode) { | 2558 const char* Translation::StringFor(Opcode opcode) { |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3302 " reading compiler stub frame => height=%d; inputs:\n", height); | 3308 " reading compiler stub frame => height=%d; inputs:\n", height); |
3303 } | 3309 } |
3304 return TranslatedFrame::CompiledStubFrame(height, | 3310 return TranslatedFrame::CompiledStubFrame(height, |
3305 literal_array->GetIsolate()); | 3311 literal_array->GetIsolate()); |
3306 } | 3312 } |
3307 | 3313 |
3308 case Translation::BEGIN: | 3314 case Translation::BEGIN: |
3309 case Translation::DUPLICATED_OBJECT: | 3315 case Translation::DUPLICATED_OBJECT: |
3310 case Translation::ARGUMENTS_OBJECT: | 3316 case Translation::ARGUMENTS_OBJECT: |
3311 case Translation::ARGUMENTS_ELEMENTS: | 3317 case Translation::ARGUMENTS_ELEMENTS: |
| 3318 case Translation::ARGUMENTS_LENGTH: |
3312 case Translation::CAPTURED_OBJECT: | 3319 case Translation::CAPTURED_OBJECT: |
3313 case Translation::REGISTER: | 3320 case Translation::REGISTER: |
3314 case Translation::INT32_REGISTER: | 3321 case Translation::INT32_REGISTER: |
3315 case Translation::UINT32_REGISTER: | 3322 case Translation::UINT32_REGISTER: |
3316 case Translation::BOOL_REGISTER: | 3323 case Translation::BOOL_REGISTER: |
3317 case Translation::FLOAT_REGISTER: | 3324 case Translation::FLOAT_REGISTER: |
3318 case Translation::DOUBLE_REGISTER: | 3325 case Translation::DOUBLE_REGISTER: |
3319 case Translation::STACK_SLOT: | 3326 case Translation::STACK_SLOT: |
3320 case Translation::INT32_STACK_SLOT: | 3327 case Translation::INT32_STACK_SLOT: |
3321 case Translation::UINT32_STACK_SLOT: | 3328 case Translation::UINT32_STACK_SLOT: |
(...skipping 15 matching lines...) Expand all Loading... |
3337 while (values_to_skip > 0) { | 3344 while (values_to_skip > 0) { |
3338 // Consume the current element. | 3345 // Consume the current element. |
3339 values_to_skip--; | 3346 values_to_skip--; |
3340 // Add all the children. | 3347 // Add all the children. |
3341 values_to_skip += (*iter)->GetChildrenCount(); | 3348 values_to_skip += (*iter)->GetChildrenCount(); |
3342 | 3349 |
3343 (*iter)++; | 3350 (*iter)++; |
3344 } | 3351 } |
3345 } | 3352 } |
3346 | 3353 |
| 3354 Address TranslatedState::ComputeArgumentsPosition(Address input_frame_pointer, |
| 3355 bool is_rest, int* length) { |
| 3356 Address parent_frame_pointer = *reinterpret_cast<Address*>( |
| 3357 input_frame_pointer + StandardFrameConstants::kCallerFPOffset); |
| 3358 intptr_t parent_frame_type = Memory::intptr_at( |
| 3359 parent_frame_pointer + CommonFrameConstants::kContextOrFrameTypeOffset); |
| 3360 |
| 3361 Address arguments_frame; |
| 3362 if (parent_frame_type == |
| 3363 StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)) { |
| 3364 if (length) |
| 3365 *length = Smi::cast(*reinterpret_cast<Object**>( |
| 3366 parent_frame_pointer + |
| 3367 ArgumentsAdaptorFrameConstants::kLengthOffset)) |
| 3368 ->value(); |
| 3369 arguments_frame = parent_frame_pointer; |
| 3370 } else { |
| 3371 if (length) *length = formal_parameter_count_; |
| 3372 arguments_frame = input_frame_pointer; |
| 3373 } |
| 3374 |
| 3375 if (is_rest) { |
| 3376 // If the actual number of arguments is less than the number of formal |
| 3377 // parameters, we have zero rest parameters. |
| 3378 if (length) *length = std::max(0, *length - formal_parameter_count_); |
| 3379 } |
| 3380 |
| 3381 return arguments_frame; |
| 3382 } |
| 3383 |
3347 // Creates translated values for an arguments backing store, or the backing | 3384 // Creates translated values for an arguments backing store, or the backing |
3348 // store for the rest parameters if {is_rest} is true. The TranslatedValue | 3385 // store for the rest parameters if {is_rest} is true. The TranslatedValue |
3349 // objects for the fields are not read from the TranslationIterator, but instead | 3386 // objects for the fields are not read from the TranslationIterator, but instead |
3350 // created on-the-fly based on dynamic information in the optimized frame. | 3387 // created on-the-fly based on dynamic information in the optimized frame. |
3351 void TranslatedState::CreateArgumentsElementsTranslatedValues( | 3388 void TranslatedState::CreateArgumentsElementsTranslatedValues( |
3352 int frame_index, Address input_frame_pointer, bool is_rest) { | 3389 int frame_index, Address input_frame_pointer, bool is_rest) { |
3353 TranslatedFrame& frame = frames_[frame_index]; | 3390 TranslatedFrame& frame = frames_[frame_index]; |
3354 | 3391 |
3355 Address parent_frame_pointer = *reinterpret_cast<Address*>( | |
3356 input_frame_pointer + StandardFrameConstants::kCallerFPOffset); | |
3357 intptr_t parent_frame_type = Memory::intptr_at( | |
3358 parent_frame_pointer + CommonFrameConstants::kContextOrFrameTypeOffset); | |
3359 int length; | 3392 int length; |
3360 Address arguments_frame; | 3393 Address arguments_frame = |
3361 if (parent_frame_type == | 3394 ComputeArgumentsPosition(input_frame_pointer, is_rest, &length); |
3362 StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)) { | |
3363 length = Smi::cast(*reinterpret_cast<Object**>( | |
3364 parent_frame_pointer + | |
3365 ArgumentsAdaptorFrameConstants::kLengthOffset)) | |
3366 ->value(); | |
3367 arguments_frame = parent_frame_pointer; | |
3368 } else { | |
3369 length = formal_parameter_count_; | |
3370 arguments_frame = input_frame_pointer; | |
3371 } | |
3372 | |
3373 if (is_rest) { | |
3374 // If the actual number of arguments is less than the number of formal | |
3375 // parameters, we have zero rest parameters. | |
3376 length = std::max(0, length - formal_parameter_count_); | |
3377 } | |
3378 | 3395 |
3379 int object_index = static_cast<int>(object_positions_.size()); | 3396 int object_index = static_cast<int>(object_positions_.size()); |
3380 int value_index = static_cast<int>(frame.values_.size()); | 3397 int value_index = static_cast<int>(frame.values_.size()); |
3381 object_positions_.push_back({frame_index, value_index}); | 3398 object_positions_.push_back({frame_index, value_index}); |
3382 frame.Add(TranslatedValue::NewDeferredObject( | 3399 frame.Add(TranslatedValue::NewDeferredObject( |
3383 this, length + FixedArray::kHeaderSize / kPointerSize, object_index)); | 3400 this, length + FixedArray::kHeaderSize / kPointerSize, object_index)); |
3384 | 3401 |
3385 frame.Add( | 3402 frame.Add( |
3386 TranslatedValue::NewTagged(this, isolate_->heap()->fixed_array_map())); | 3403 TranslatedValue::NewTagged(this, isolate_->heap()->fixed_array_map())); |
3387 frame.Add(TranslatedValue::NewInt32(this, length)); | 3404 frame.Add(TranslatedValue::NewInt32(this, length)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3452 frame.Add(translated_value); | 3469 frame.Add(translated_value); |
3453 return translated_value.GetChildrenCount(); | 3470 return translated_value.GetChildrenCount(); |
3454 } | 3471 } |
3455 | 3472 |
3456 case Translation::ARGUMENTS_ELEMENTS: { | 3473 case Translation::ARGUMENTS_ELEMENTS: { |
3457 bool is_rest = iterator->Next(); | 3474 bool is_rest = iterator->Next(); |
3458 CreateArgumentsElementsTranslatedValues(frame_index, fp, is_rest); | 3475 CreateArgumentsElementsTranslatedValues(frame_index, fp, is_rest); |
3459 return 0; | 3476 return 0; |
3460 } | 3477 } |
3461 | 3478 |
| 3479 case Translation::ARGUMENTS_LENGTH: { |
| 3480 bool is_rest = iterator->Next(); |
| 3481 int length; |
| 3482 ComputeArgumentsPosition(fp, is_rest, &length); |
| 3483 frame.Add(TranslatedValue::NewInt32(this, length)); |
| 3484 return 0; |
| 3485 } |
| 3486 |
3462 case Translation::CAPTURED_OBJECT: { | 3487 case Translation::CAPTURED_OBJECT: { |
3463 int field_count = iterator->Next(); | 3488 int field_count = iterator->Next(); |
3464 int object_index = static_cast<int>(object_positions_.size()); | 3489 int object_index = static_cast<int>(object_positions_.size()); |
3465 if (trace_file != nullptr) { | 3490 if (trace_file != nullptr) { |
3466 PrintF(trace_file, "captured object #%d (length = %d)", object_index, | 3491 PrintF(trace_file, "captured object #%d (length = %d)", object_index, |
3467 field_count); | 3492 field_count); |
3468 } | 3493 } |
3469 object_positions_.push_back({frame_index, value_index}); | 3494 object_positions_.push_back({frame_index, value_index}); |
3470 TranslatedValue translated_value = | 3495 TranslatedValue translated_value = |
3471 TranslatedValue::NewDeferredObject(this, field_count, object_index); | 3496 TranslatedValue::NewDeferredObject(this, field_count, object_index); |
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4381 CHECK(value_info->IsMaterializedObject()); | 4406 CHECK(value_info->IsMaterializedObject()); |
4382 | 4407 |
4383 value_info->value_ = | 4408 value_info->value_ = |
4384 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 4409 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
4385 } | 4410 } |
4386 } | 4411 } |
4387 } | 4412 } |
4388 | 4413 |
4389 } // namespace internal | 4414 } // namespace internal |
4390 } // namespace v8 | 4415 } // namespace v8 |
OLD | NEW |