| 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 (kNumberOfEntries * table_entry_size_)) { | 486 (kNumberOfEntries * table_entry_size_)) { |
| 487 return kNotDeoptimizationEntry; | 487 return kNotDeoptimizationEntry; |
| 488 } | 488 } |
| 489 ASSERT_EQ(0, | 489 ASSERT_EQ(0, |
| 490 static_cast<int>(addr - base->area_start()) % table_entry_size_); | 490 static_cast<int>(addr - base->area_start()) % table_entry_size_); |
| 491 return static_cast<int>(addr - base->area_start()) / table_entry_size_; | 491 return static_cast<int>(addr - base->area_start()) / table_entry_size_; |
| 492 } | 492 } |
| 493 | 493 |
| 494 | 494 |
| 495 int Deoptimizer::GetOutputInfo(DeoptimizationOutputData* data, | 495 int Deoptimizer::GetOutputInfo(DeoptimizationOutputData* data, |
| 496 unsigned id, | 496 BailoutId id, |
| 497 SharedFunctionInfo* shared) { | 497 SharedFunctionInfo* shared) { |
| 498 // TODO(kasperl): For now, we do a simple linear search for the PC | 498 // TODO(kasperl): For now, we do a simple linear search for the PC |
| 499 // offset associated with the given node id. This should probably be | 499 // offset associated with the given node id. This should probably be |
| 500 // changed to a binary search. | 500 // changed to a binary search. |
| 501 int length = data->DeoptPoints(); | 501 int length = data->DeoptPoints(); |
| 502 Smi* smi_id = Smi::FromInt(id); | |
| 503 for (int i = 0; i < length; i++) { | 502 for (int i = 0; i < length; i++) { |
| 504 if (data->AstId(i) == smi_id) { | 503 if (data->AstId(i) == id) { |
| 505 return data->PcAndState(i)->value(); | 504 return data->PcAndState(i)->value(); |
| 506 } | 505 } |
| 507 } | 506 } |
| 508 PrintF("[couldn't find pc offset for node=%u]\n", id); | 507 PrintF("[couldn't find pc offset for node=%d]\n", id.ToInt()); |
| 509 PrintF("[method: %s]\n", *shared->DebugName()->ToCString()); | 508 PrintF("[method: %s]\n", *shared->DebugName()->ToCString()); |
| 510 // Print the source code if available. | 509 // Print the source code if available. |
| 511 HeapStringAllocator string_allocator; | 510 HeapStringAllocator string_allocator; |
| 512 StringStream stream(&string_allocator); | 511 StringStream stream(&string_allocator); |
| 513 shared->SourceCodePrint(&stream, -1); | 512 shared->SourceCodePrint(&stream, -1); |
| 514 PrintF("[source:\n%s\n]", *stream.ToCString()); | 513 PrintF("[source:\n%s\n]", *stream.ToCString()); |
| 515 | 514 |
| 516 UNREACHABLE(); | 515 UNREACHABLE(); |
| 517 return -1; | 516 return -1; |
| 518 } | 517 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 545 (bailout_type_ == LAZY ? " (lazy)" : ""), | 544 (bailout_type_ == LAZY ? " (lazy)" : ""), |
| 546 reinterpret_cast<intptr_t>(function_)); | 545 reinterpret_cast<intptr_t>(function_)); |
| 547 function_->PrintName(); | 546 function_->PrintName(); |
| 548 PrintF(" @%d]\n", bailout_id_); | 547 PrintF(" @%d]\n", bailout_id_); |
| 549 } | 548 } |
| 550 | 549 |
| 551 // Determine basic deoptimization information. The optimized frame is | 550 // Determine basic deoptimization information. The optimized frame is |
| 552 // described by the input data. | 551 // described by the input data. |
| 553 DeoptimizationInputData* input_data = | 552 DeoptimizationInputData* input_data = |
| 554 DeoptimizationInputData::cast(optimized_code_->deoptimization_data()); | 553 DeoptimizationInputData::cast(optimized_code_->deoptimization_data()); |
| 555 unsigned node_id = input_data->AstId(bailout_id_)->value(); | 554 BailoutId node_id = input_data->AstId(bailout_id_); |
| 556 ByteArray* translations = input_data->TranslationByteArray(); | 555 ByteArray* translations = input_data->TranslationByteArray(); |
| 557 unsigned translation_index = | 556 unsigned translation_index = |
| 558 input_data->TranslationIndex(bailout_id_)->value(); | 557 input_data->TranslationIndex(bailout_id_)->value(); |
| 559 | 558 |
| 560 // Do the input frame to output frame(s) translation. | 559 // Do the input frame to output frame(s) translation. |
| 561 TranslationIterator iterator(translations, translation_index); | 560 TranslationIterator iterator(translations, translation_index); |
| 562 Translation::Opcode opcode = | 561 Translation::Opcode opcode = |
| 563 static_cast<Translation::Opcode>(iterator.Next()); | 562 static_cast<Translation::Opcode>(iterator.Next()); |
| 564 ASSERT(Translation::BEGIN == opcode); | 563 ASSERT(Translation::BEGIN == opcode); |
| 565 USE(opcode); | 564 USE(opcode); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 } | 596 } |
| 598 | 597 |
| 599 // Print some helpful diagnostic information. | 598 // Print some helpful diagnostic information. |
| 600 if (FLAG_trace_deopt) { | 599 if (FLAG_trace_deopt) { |
| 601 double ms = static_cast<double>(OS::Ticks() - start) / 1000; | 600 double ms = static_cast<double>(OS::Ticks() - start) / 1000; |
| 602 int index = output_count_ - 1; // Index of the topmost frame. | 601 int index = output_count_ - 1; // Index of the topmost frame. |
| 603 JSFunction* function = output_[index]->GetFunction(); | 602 JSFunction* function = output_[index]->GetFunction(); |
| 604 PrintF("[deoptimizing: end 0x%08" V8PRIxPTR " ", | 603 PrintF("[deoptimizing: end 0x%08" V8PRIxPTR " ", |
| 605 reinterpret_cast<intptr_t>(function)); | 604 reinterpret_cast<intptr_t>(function)); |
| 606 function->PrintName(); | 605 function->PrintName(); |
| 607 PrintF(" => node=%u, pc=0x%08" V8PRIxPTR ", state=%s, alignment=%s," | 606 PrintF(" => node=%d, pc=0x%08" V8PRIxPTR ", state=%s, alignment=%s," |
| 608 " took %0.3f ms]\n", | 607 " took %0.3f ms]\n", |
| 609 node_id, | 608 node_id.ToInt(), |
| 610 output_[index]->GetPc(), | 609 output_[index]->GetPc(), |
| 611 FullCodeGenerator::State2String( | 610 FullCodeGenerator::State2String( |
| 612 static_cast<FullCodeGenerator::State>( | 611 static_cast<FullCodeGenerator::State>( |
| 613 output_[index]->GetState()->value())), | 612 output_[index]->GetState()->value())), |
| 614 has_alignment_padding_ ? "with padding" : "no padding", | 613 has_alignment_padding_ ? "with padding" : "no padding", |
| 615 ms); | 614 ms); |
| 616 } | 615 } |
| 617 } | 616 } |
| 618 | 617 |
| 619 | 618 |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 } | 1350 } |
| 1352 | 1351 |
| 1353 | 1352 |
| 1354 void Translation::BeginArgumentsAdaptorFrame(int literal_id, unsigned height) { | 1353 void Translation::BeginArgumentsAdaptorFrame(int literal_id, unsigned height) { |
| 1355 buffer_->Add(ARGUMENTS_ADAPTOR_FRAME, zone()); | 1354 buffer_->Add(ARGUMENTS_ADAPTOR_FRAME, zone()); |
| 1356 buffer_->Add(literal_id, zone()); | 1355 buffer_->Add(literal_id, zone()); |
| 1357 buffer_->Add(height, zone()); | 1356 buffer_->Add(height, zone()); |
| 1358 } | 1357 } |
| 1359 | 1358 |
| 1360 | 1359 |
| 1361 void Translation::BeginJSFrame(int node_id, int literal_id, unsigned height) { | 1360 void Translation::BeginJSFrame(BailoutId node_id, |
| 1361 int literal_id, |
| 1362 unsigned height) { |
| 1362 buffer_->Add(JS_FRAME, zone()); | 1363 buffer_->Add(JS_FRAME, zone()); |
| 1363 buffer_->Add(node_id, zone()); | 1364 buffer_->Add(node_id.ToInt(), zone()); |
| 1364 buffer_->Add(literal_id, zone()); | 1365 buffer_->Add(literal_id, zone()); |
| 1365 buffer_->Add(height, zone()); | 1366 buffer_->Add(height, zone()); |
| 1366 } | 1367 } |
| 1367 | 1368 |
| 1368 | 1369 |
| 1369 void Translation::StoreRegister(Register reg) { | 1370 void Translation::StoreRegister(Register reg) { |
| 1370 buffer_->Add(REGISTER, zone()); | 1371 buffer_->Add(REGISTER, zone()); |
| 1371 buffer_->Add(reg.code(), zone()); | 1372 buffer_->Add(reg.code(), zone()); |
| 1372 } | 1373 } |
| 1373 | 1374 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 (*args_slots)[i] = ComputeSlotForNextArgument(it, data, frame); | 1572 (*args_slots)[i] = ComputeSlotForNextArgument(it, data, frame); |
| 1572 } | 1573 } |
| 1573 } | 1574 } |
| 1574 | 1575 |
| 1575 | 1576 |
| 1576 Vector<SlotRef> SlotRef::ComputeSlotMappingForArguments( | 1577 Vector<SlotRef> SlotRef::ComputeSlotMappingForArguments( |
| 1577 JavaScriptFrame* frame, | 1578 JavaScriptFrame* frame, |
| 1578 int inlined_jsframe_index, | 1579 int inlined_jsframe_index, |
| 1579 int formal_parameter_count) { | 1580 int formal_parameter_count) { |
| 1580 AssertNoAllocation no_gc; | 1581 AssertNoAllocation no_gc; |
| 1581 int deopt_index = AstNode::kNoNumber; | 1582 int deopt_index = Safepoint::kNoDeoptimizationIndex; |
| 1582 DeoptimizationInputData* data = | 1583 DeoptimizationInputData* data = |
| 1583 static_cast<OptimizedFrame*>(frame)->GetDeoptimizationData(&deopt_index); | 1584 static_cast<OptimizedFrame*>(frame)->GetDeoptimizationData(&deopt_index); |
| 1584 TranslationIterator it(data->TranslationByteArray(), | 1585 TranslationIterator it(data->TranslationByteArray(), |
| 1585 data->TranslationIndex(deopt_index)->value()); | 1586 data->TranslationIndex(deopt_index)->value()); |
| 1586 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); | 1587 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| 1587 ASSERT(opcode == Translation::BEGIN); | 1588 ASSERT(opcode == Translation::BEGIN); |
| 1588 it.Next(); // Drop frame count. | 1589 it.Next(); // Drop frame count. |
| 1589 int jsframe_count = it.Next(); | 1590 int jsframe_count = it.Next(); |
| 1590 USE(jsframe_count); | 1591 USE(jsframe_count); |
| 1591 ASSERT(jsframe_count > inlined_jsframe_index); | 1592 ASSERT(jsframe_count > inlined_jsframe_index); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 | 1673 |
| 1673 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 1674 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
| 1674 v->VisitPointer(BitCast<Object**>(&function_)); | 1675 v->VisitPointer(BitCast<Object**>(&function_)); |
| 1675 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 1676 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
| 1676 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 1677 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
| 1677 } | 1678 } |
| 1678 | 1679 |
| 1679 #endif // ENABLE_DEBUGGER_SUPPORT | 1680 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1680 | 1681 |
| 1681 } } // namespace v8::internal | 1682 } } // namespace v8::internal |
| OLD | NEW |