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

Side by Side Diff: src/arm/deoptimizer-arm.cc

Issue 6697023: Merge 6800:7180 from the bleeding edge branch to the experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 9 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/arm/cpu-arm.cc ('k') | src/arm/disasm-arm.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 28 matching lines...) Expand all
39 39
40 40
41 int Deoptimizer::patch_size() { 41 int Deoptimizer::patch_size() {
42 const int kCallInstructionSizeInWords = 3; 42 const int kCallInstructionSizeInWords = 3;
43 return kCallInstructionSizeInWords * Assembler::kInstrSize; 43 return kCallInstructionSizeInWords * Assembler::kInstrSize;
44 } 44 }
45 45
46 46
47 47
48 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { 48 void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
49 HandleScope scope;
49 AssertNoAllocation no_allocation; 50 AssertNoAllocation no_allocation;
50 51
51 if (!function->IsOptimized()) return; 52 if (!function->IsOptimized()) return;
52 53
53 // Get the optimized code. 54 // Get the optimized code.
54 Code* code = function->code(); 55 Code* code = function->code();
55 56
56 // Invalidate the relocation information, as it will become invalid by the 57 // Invalidate the relocation information, as it will become invalid by the
57 // code patching below, and is not needed any more. 58 // code patching below, and is not needed any more.
58 code->InvalidateRelocation(); 59 code->InvalidateRelocation();
59 60
60 // For each return after a safepoint insert an absolute call to the 61 // For each return after a safepoint insert an absolute call to the
61 // corresponding deoptimization entry. 62 // corresponding deoptimization entry.
62 ASSERT(patch_size() % Assembler::kInstrSize == 0); 63 ASSERT(patch_size() % Assembler::kInstrSize == 0);
63 int call_size_in_words = patch_size() / Assembler::kInstrSize; 64 int call_size_in_words = patch_size() / Assembler::kInstrSize;
64 unsigned last_pc_offset = 0; 65 unsigned last_pc_offset = 0;
65 SafepointTable table(function->code()); 66 SafepointTable table(function->code());
66 for (unsigned i = 0; i < table.length(); i++) { 67 for (unsigned i = 0; i < table.length(); i++) {
67 unsigned pc_offset = table.GetPcOffset(i); 68 unsigned pc_offset = table.GetPcOffset(i);
68 SafepointEntry safepoint_entry = table.GetEntry(i); 69 SafepointEntry safepoint_entry = table.GetEntry(i);
69 int deoptimization_index = safepoint_entry.deoptimization_index(); 70 int deoptimization_index = safepoint_entry.deoptimization_index();
70 int gap_code_size = safepoint_entry.gap_code_size(); 71 int gap_code_size = safepoint_entry.gap_code_size();
71 // Check that we did not shoot past next safepoint. 72 // Check that we did not shoot past next safepoint.
72 // TODO(srdjan): How do we guarantee that safepoint code does not
73 // overlap other safepoint patching code?
74 CHECK(pc_offset >= last_pc_offset); 73 CHECK(pc_offset >= last_pc_offset);
75 #ifdef DEBUG 74 #ifdef DEBUG
76 // Destroy the code which is not supposed to be run again. 75 // Destroy the code which is not supposed to be run again.
77 int instructions = (pc_offset - last_pc_offset) / Assembler::kInstrSize; 76 int instructions = (pc_offset - last_pc_offset) / Assembler::kInstrSize;
78 CodePatcher destroyer(code->instruction_start() + last_pc_offset, 77 CodePatcher destroyer(code->instruction_start() + last_pc_offset,
79 instructions); 78 instructions);
80 for (int x = 0; x < instructions; x++) { 79 for (int x = 0; x < instructions; x++) {
81 destroyer.masm()->bkpt(0); 80 destroyer.masm()->bkpt(0);
82 } 81 }
83 #endif 82 #endif
(...skipping 26 matching lines...) Expand all
110 node->set_next(deoptimizing_code_list_); 109 node->set_next(deoptimizing_code_list_);
111 deoptimizing_code_list_ = node; 110 deoptimizing_code_list_ = node;
112 111
113 // Set the code for the function to non-optimized version. 112 // Set the code for the function to non-optimized version.
114 function->ReplaceCode(function->shared()->code()); 113 function->ReplaceCode(function->shared()->code());
115 114
116 if (FLAG_trace_deopt) { 115 if (FLAG_trace_deopt) {
117 PrintF("[forced deoptimization: "); 116 PrintF("[forced deoptimization: ");
118 function->PrintName(); 117 function->PrintName();
119 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); 118 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function));
119 #ifdef DEBUG
120 if (FLAG_print_code) {
121 code->PrintLn();
122 }
123 #endif
120 } 124 }
121 } 125 }
122 126
123 127
124 // TODO(gc) make use of unoptimized_code when supporting incremental marking. 128 // TODO(gc) make use of unoptimized_code when supporting incremental marking.
125 void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code, 129 void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code,
126 Address pc_after, 130 Address pc_after,
127 Code* check_code, 131 Code* check_code,
128 Code* replacement_code) { 132 Code* replacement_code) {
129 const int kInstrSize = Assembler::kInstrSize; 133 const int kInstrSize = Assembler::kInstrSize;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 ASSERT(!is_bottommost || input_->GetRegister(fp.code()) == fp_value); 428 ASSERT(!is_bottommost || input_->GetRegister(fp.code()) == fp_value);
425 output_frame->SetFp(fp_value); 429 output_frame->SetFp(fp_value);
426 if (is_topmost) { 430 if (is_topmost) {
427 output_frame->SetRegister(fp.code(), fp_value); 431 output_frame->SetRegister(fp.code(), fp_value);
428 } 432 }
429 if (FLAG_trace_deopt) { 433 if (FLAG_trace_deopt) {
430 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n", 434 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
431 fp_value, output_offset, value); 435 fp_value, output_offset, value);
432 } 436 }
433 437
434 // The context can be gotten from the function so long as we don't 438 // For the bottommost output frame the context can be gotten from the input
435 // optimize functions that need local contexts. 439 // frame. For all subsequent output frames it can be gotten from the function
440 // so long as we don't inline functions that need local contexts.
436 output_offset -= kPointerSize; 441 output_offset -= kPointerSize;
437 input_offset -= kPointerSize; 442 input_offset -= kPointerSize;
438 value = reinterpret_cast<intptr_t>(function->context()); 443 if (is_bottommost) {
439 // The context for the bottommost output frame should also agree with the 444 value = input_->GetFrameSlot(input_offset);
440 // input frame. 445 } else {
441 ASSERT(!is_bottommost || input_->GetFrameSlot(input_offset) == value); 446 value = reinterpret_cast<intptr_t>(function->context());
447 }
442 output_frame->SetFrameSlot(output_offset, value); 448 output_frame->SetFrameSlot(output_offset, value);
443 if (is_topmost) { 449 if (is_topmost) {
444 output_frame->SetRegister(cp.code(), value); 450 output_frame->SetRegister(cp.code(), value);
445 } 451 }
446 if (FLAG_trace_deopt) { 452 if (FLAG_trace_deopt) {
447 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n", 453 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n",
448 top_address + output_offset, output_offset, value); 454 top_address + output_offset, output_offset, value);
449 } 455 }
450 456
451 // The function was mentioned explicitly in the BEGIN_FRAME. 457 // The function was mentioned explicitly in the BEGIN_FRAME.
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 __ push(ip); 697 __ push(ip);
692 __ b(&done); 698 __ b(&done);
693 ASSERT(masm()->pc_offset() - start == table_entry_size_); 699 ASSERT(masm()->pc_offset() - start == table_entry_size_);
694 } 700 }
695 __ bind(&done); 701 __ bind(&done);
696 } 702 }
697 703
698 #undef __ 704 #undef __
699 705
700 } } // namespace v8::internal 706 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/cpu-arm.cc ('k') | src/arm/disasm-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698