Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: src/deoptimizer.cc

Issue 139973004: A64: Synchronize with r15814. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/debug.cc ('k') | src/factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 #include "macro-assembler.h" 36 #include "macro-assembler.h"
37 #include "prettyprinter.h" 37 #include "prettyprinter.h"
38 38
39 39
40 namespace v8 { 40 namespace v8 {
41 namespace internal { 41 namespace internal {
42 42
43 static MemoryChunk* AllocateCodeChunk(MemoryAllocator* allocator) { 43 static MemoryChunk* AllocateCodeChunk(MemoryAllocator* allocator) {
44 return allocator->AllocateChunk(Deoptimizer::GetMaxDeoptTableSize(), 44 return allocator->AllocateChunk(Deoptimizer::GetMaxDeoptTableSize(),
45 OS::CommitPageSize(), 45 OS::CommitPageSize(),
46 #if defined(__native_client__)
47 // The Native Client port of V8 uses an interpreter,
48 // so code pages don't need PROT_EXEC.
49 NOT_EXECUTABLE,
50 #else
46 EXECUTABLE, 51 EXECUTABLE,
52 #endif
47 NULL); 53 NULL);
48 } 54 }
49 55
50 56
51 DeoptimizerData::DeoptimizerData(MemoryAllocator* allocator) 57 DeoptimizerData::DeoptimizerData(MemoryAllocator* allocator)
52 : allocator_(allocator), 58 : allocator_(allocator),
53 current_(NULL), 59 current_(NULL),
54 #ifdef ENABLE_DEBUGGER_SUPPORT 60 #ifdef ENABLE_DEBUGGER_SUPPORT
55 deoptimized_frame_info_(NULL), 61 deoptimized_frame_info_(NULL),
56 #endif 62 #endif
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 577
572 Code* Deoptimizer::FindOptimizedCode(JSFunction* function, 578 Code* Deoptimizer::FindOptimizedCode(JSFunction* function,
573 Code* optimized_code) { 579 Code* optimized_code) {
574 switch (bailout_type_) { 580 switch (bailout_type_) {
575 case Deoptimizer::SOFT: 581 case Deoptimizer::SOFT:
576 case Deoptimizer::EAGER: 582 case Deoptimizer::EAGER:
577 case Deoptimizer::LAZY: { 583 case Deoptimizer::LAZY: {
578 Code* compiled_code = 584 Code* compiled_code =
579 isolate_->deoptimizer_data()->FindDeoptimizingCode(from_); 585 isolate_->deoptimizer_data()->FindDeoptimizingCode(from_);
580 return (compiled_code == NULL) 586 return (compiled_code == NULL)
581 ? static_cast<Code*>(isolate_->heap()->FindCodeObject(from_)) 587 ? static_cast<Code*>(isolate_->FindCodeObject(from_))
582 : compiled_code; 588 : compiled_code;
583 } 589 }
584 case Deoptimizer::OSR: { 590 case Deoptimizer::OSR: {
585 // The function has already been optimized and we're transitioning 591 // The function has already been optimized and we're transitioning
586 // from the unoptimized shared version to the optimized one in the 592 // from the unoptimized shared version to the optimized one in the
587 // function. The return address (from_) points to unoptimized code. 593 // function. The return address (from_) points to unoptimized code.
588 Code* compiled_code = function->code(); 594 Code* compiled_code = function->code();
589 ASSERT(compiled_code->kind() == Code::OPTIMIZED_FUNCTION); 595 ASSERT(compiled_code->kind() == Code::OPTIMIZED_FUNCTION);
590 ASSERT(!compiled_code->contains(from_)); 596 ASSERT(!compiled_code->contains(from_));
591 return compiled_code; 597 return compiled_code;
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 Handle<JSFunction> function(frame->function(), isolate_); 1617 Handle<JSFunction> function(frame->function(), isolate_);
1612 Handle<JSObject> arguments; 1618 Handle<JSObject> arguments;
1613 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) { 1619 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
1614 if (frame->GetExpression(i) == isolate_->heap()->arguments_marker()) { 1620 if (frame->GetExpression(i) == isolate_->heap()->arguments_marker()) {
1615 ObjectMaterializationDescriptor descriptor = 1621 ObjectMaterializationDescriptor descriptor =
1616 deferred_objects_.RemoveLast(); 1622 deferred_objects_.RemoveLast();
1617 const int length = descriptor.object_length(); 1623 const int length = descriptor.object_length();
1618 if (arguments.is_null()) { 1624 if (arguments.is_null()) {
1619 if (frame->has_adapted_arguments()) { 1625 if (frame->has_adapted_arguments()) {
1620 // Use the arguments adapter frame we just built to materialize the 1626 // Use the arguments adapter frame we just built to materialize the
1621 // arguments object. FunctionGetArguments can't throw an exception, 1627 // arguments object. FunctionGetArguments can't throw an exception.
1622 // so cast away the doubt with an assert. 1628 arguments = Handle<JSObject>::cast(
1623 arguments = Handle<JSObject>(JSObject::cast( 1629 Accessors::FunctionGetArguments(function));
1624 Accessors::FunctionGetArguments(*function,
1625 NULL)->ToObjectUnchecked()));
1626 values.RewindBy(length); 1630 values.RewindBy(length);
1627 } else { 1631 } else {
1628 // Construct an arguments object and copy the parameters to a newly 1632 // Construct an arguments object and copy the parameters to a newly
1629 // allocated arguments object backing store. 1633 // allocated arguments object backing store.
1630 arguments = 1634 arguments =
1631 isolate_->factory()->NewArgumentsObject(function, length); 1635 isolate_->factory()->NewArgumentsObject(function, length);
1632 Handle<FixedArray> array = 1636 Handle<FixedArray> array =
1633 isolate_->factory()->NewFixedArray(length); 1637 isolate_->factory()->NewFixedArray(length);
1634 ASSERT(array->length() == length); 1638 ASSERT(array->length() == length);
1635 for (int i = length - 1; i >= 0 ; --i) { 1639 for (int i = length - 1; i >= 0 ; --i) {
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 Code* replacement_code) { 2364 Code* replacement_code) {
2361 // Iterate over the back edge table and patch every interrupt 2365 // Iterate over the back edge table and patch every interrupt
2362 // call to an unconditional call to the replacement code. 2366 // call to an unconditional call to the replacement code.
2363 ASSERT(unoptimized_code->kind() == Code::FUNCTION); 2367 ASSERT(unoptimized_code->kind() == Code::FUNCTION);
2364 int loop_nesting_level = unoptimized_code->allow_osr_at_loop_nesting_level(); 2368 int loop_nesting_level = unoptimized_code->allow_osr_at_loop_nesting_level();
2365 Address back_edge_cursor = unoptimized_code->instruction_start() + 2369 Address back_edge_cursor = unoptimized_code->instruction_start() +
2366 unoptimized_code->back_edge_table_offset(); 2370 unoptimized_code->back_edge_table_offset();
2367 uint32_t table_length = Memory::uint32_at(back_edge_cursor); 2371 uint32_t table_length = Memory::uint32_at(back_edge_cursor);
2368 back_edge_cursor += kIntSize; 2372 back_edge_cursor += kIntSize;
2369 for (uint32_t i = 0; i < table_length; ++i) { 2373 for (uint32_t i = 0; i < table_length; ++i) {
2370 uint8_t loop_depth = Memory::uint8_at(back_edge_cursor + 2 * kIntSize); 2374 uint32_t loop_depth = Memory::uint32_at(back_edge_cursor + 2 * kIntSize);
2371 if (loop_depth == loop_nesting_level) { 2375 if (static_cast<int>(loop_depth) == loop_nesting_level) {
2372 // Loop back edge has the loop depth that we want to patch. 2376 // Loop back edge has the loop depth that we want to patch.
2373 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize); 2377 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize);
2374 Address pc_after = unoptimized_code->instruction_start() + pc_offset; 2378 Address pc_after = unoptimized_code->instruction_start() + pc_offset;
2375 PatchInterruptCodeAt(unoptimized_code, 2379 PatchInterruptCodeAt(unoptimized_code,
2376 pc_after, 2380 pc_after,
2377 interrupt_code, 2381 interrupt_code,
2378 replacement_code); 2382 replacement_code);
2379 } 2383 }
2380 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize; 2384 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize;
2381 } 2385 }
(...skipping 10 matching lines...) Expand all
2392 Code* replacement_code) { 2396 Code* replacement_code) {
2393 // Iterate over the back edge table and revert the patched interrupt calls. 2397 // Iterate over the back edge table and revert the patched interrupt calls.
2394 ASSERT(unoptimized_code->kind() == Code::FUNCTION); 2398 ASSERT(unoptimized_code->kind() == Code::FUNCTION);
2395 ASSERT(unoptimized_code->back_edges_patched_for_osr()); 2399 ASSERT(unoptimized_code->back_edges_patched_for_osr());
2396 int loop_nesting_level = unoptimized_code->allow_osr_at_loop_nesting_level(); 2400 int loop_nesting_level = unoptimized_code->allow_osr_at_loop_nesting_level();
2397 Address back_edge_cursor = unoptimized_code->instruction_start() + 2401 Address back_edge_cursor = unoptimized_code->instruction_start() +
2398 unoptimized_code->back_edge_table_offset(); 2402 unoptimized_code->back_edge_table_offset();
2399 uint32_t table_length = Memory::uint32_at(back_edge_cursor); 2403 uint32_t table_length = Memory::uint32_at(back_edge_cursor);
2400 back_edge_cursor += kIntSize; 2404 back_edge_cursor += kIntSize;
2401 for (uint32_t i = 0; i < table_length; ++i) { 2405 for (uint32_t i = 0; i < table_length; ++i) {
2402 uint8_t loop_depth = Memory::uint8_at(back_edge_cursor + 2 * kIntSize); 2406 uint32_t loop_depth = Memory::uint32_at(back_edge_cursor + 2 * kIntSize);
2403 if (loop_depth <= loop_nesting_level) { 2407 if (static_cast<int>(loop_depth) <= loop_nesting_level) {
2404 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize); 2408 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize);
2405 Address pc_after = unoptimized_code->instruction_start() + pc_offset; 2409 Address pc_after = unoptimized_code->instruction_start() + pc_offset;
2406 RevertInterruptCodeAt(unoptimized_code, 2410 RevertInterruptCodeAt(unoptimized_code,
2407 pc_after, 2411 pc_after,
2408 interrupt_code, 2412 interrupt_code,
2409 replacement_code); 2413 replacement_code);
2410 } 2414 }
2411 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize; 2415 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize;
2412 } 2416 }
2413 unoptimized_code->set_back_edges_patched_for_osr(false); 2417 unoptimized_code->set_back_edges_patched_for_osr(false);
(...skipping 10 matching lines...) Expand all
2424 void Deoptimizer::VerifyInterruptCode(Code* unoptimized_code, 2428 void Deoptimizer::VerifyInterruptCode(Code* unoptimized_code,
2425 Code* interrupt_code, 2429 Code* interrupt_code,
2426 Code* replacement_code, 2430 Code* replacement_code,
2427 int loop_nesting_level) { 2431 int loop_nesting_level) {
2428 CHECK(unoptimized_code->kind() == Code::FUNCTION); 2432 CHECK(unoptimized_code->kind() == Code::FUNCTION);
2429 Address back_edge_cursor = unoptimized_code->instruction_start() + 2433 Address back_edge_cursor = unoptimized_code->instruction_start() +
2430 unoptimized_code->back_edge_table_offset(); 2434 unoptimized_code->back_edge_table_offset();
2431 uint32_t table_length = Memory::uint32_at(back_edge_cursor); 2435 uint32_t table_length = Memory::uint32_at(back_edge_cursor);
2432 back_edge_cursor += kIntSize; 2436 back_edge_cursor += kIntSize;
2433 for (uint32_t i = 0; i < table_length; ++i) { 2437 for (uint32_t i = 0; i < table_length; ++i) {
2434 uint8_t loop_depth = Memory::uint8_at(back_edge_cursor + 2 * kIntSize); 2438 uint32_t loop_depth = Memory::uint32_at(back_edge_cursor + 2 * kIntSize);
2435 CHECK_LE(loop_depth, Code::kMaxLoopNestingMarker); 2439 CHECK_LE(static_cast<int>(loop_depth), Code::kMaxLoopNestingMarker);
2436 // Assert that all back edges for shallower loops (and only those) 2440 // Assert that all back edges for shallower loops (and only those)
2437 // have already been patched. 2441 // have already been patched.
2438 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize); 2442 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize);
2439 Address pc_after = unoptimized_code->instruction_start() + pc_offset; 2443 Address pc_after = unoptimized_code->instruction_start() + pc_offset;
2440 CHECK_EQ((loop_depth <= loop_nesting_level), 2444 CHECK_EQ((static_cast<int>(loop_depth) <= loop_nesting_level),
2441 InterruptCodeIsPatched(unoptimized_code, 2445 InterruptCodeIsPatched(unoptimized_code,
2442 pc_after, 2446 pc_after,
2443 interrupt_code, 2447 interrupt_code,
2444 replacement_code)); 2448 replacement_code));
2445 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize; 2449 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize;
2446 } 2450 }
2447 } 2451 }
2448 #endif // DEBUG 2452 #endif // DEBUG
2449 2453
2450 2454
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
3060 int frame_index, 3064 int frame_index,
3061 bool has_arguments_adaptor, 3065 bool has_arguments_adaptor,
3062 bool has_construct_stub) { 3066 bool has_construct_stub) {
3063 FrameDescription* output_frame = deoptimizer->output_[frame_index]; 3067 FrameDescription* output_frame = deoptimizer->output_[frame_index];
3064 function_ = output_frame->GetFunction(); 3068 function_ = output_frame->GetFunction();
3065 has_construct_stub_ = has_construct_stub; 3069 has_construct_stub_ = has_construct_stub;
3066 expression_count_ = output_frame->GetExpressionCount(); 3070 expression_count_ = output_frame->GetExpressionCount();
3067 expression_stack_ = new Object*[expression_count_]; 3071 expression_stack_ = new Object*[expression_count_];
3068 // Get the source position using the unoptimized code. 3072 // Get the source position using the unoptimized code.
3069 Address pc = reinterpret_cast<Address>(output_frame->GetPc()); 3073 Address pc = reinterpret_cast<Address>(output_frame->GetPc());
3070 Code* code = Code::cast(deoptimizer->isolate()->heap()->FindCodeObject(pc)); 3074 Code* code = Code::cast(deoptimizer->isolate()->FindCodeObject(pc));
3071 source_position_ = code->SourcePosition(pc); 3075 source_position_ = code->SourcePosition(pc);
3072 3076
3073 for (int i = 0; i < expression_count_; i++) { 3077 for (int i = 0; i < expression_count_; i++) {
3074 SetExpression(i, output_frame->GetExpression(i)); 3078 SetExpression(i, output_frame->GetExpression(i));
3075 } 3079 }
3076 3080
3077 if (has_arguments_adaptor) { 3081 if (has_arguments_adaptor) {
3078 output_frame = deoptimizer->output_[frame_index - 1]; 3082 output_frame = deoptimizer->output_[frame_index - 1];
3079 ASSERT(output_frame->GetFrameType() == StackFrame::ARGUMENTS_ADAPTOR); 3083 ASSERT(output_frame->GetFrameType() == StackFrame::ARGUMENTS_ADAPTOR);
3080 } 3084 }
(...skipping 14 matching lines...) Expand all
3095 3099
3096 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { 3100 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) {
3097 v->VisitPointer(BitCast<Object**>(&function_)); 3101 v->VisitPointer(BitCast<Object**>(&function_));
3098 v->VisitPointers(parameters_, parameters_ + parameters_count_); 3102 v->VisitPointers(parameters_, parameters_ + parameters_count_);
3099 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); 3103 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_);
3100 } 3104 }
3101 3105
3102 #endif // ENABLE_DEBUGGER_SUPPORT 3106 #endif // ENABLE_DEBUGGER_SUPPORT
3103 3107
3104 } } // namespace v8::internal 3108 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698