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

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

Issue 6606002: Merge revision 6500-6600 from bleeding_edge to the isolates branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
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
OLDNEW
1 // Copyright 2010 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
11 // with the distribution. 11 // with the distribution.
(...skipping 18 matching lines...) Expand all
30 #include "codegen.h" 30 #include "codegen.h"
31 #include "deoptimizer.h" 31 #include "deoptimizer.h"
32 #include "full-codegen.h" 32 #include "full-codegen.h"
33 #include "safepoint-table.h" 33 #include "safepoint-table.h"
34 34
35 namespace v8 { 35 namespace v8 {
36 namespace internal { 36 namespace internal {
37 37
38 int Deoptimizer::table_entry_size_ = 16; 38 int Deoptimizer::table_entry_size_ = 16;
39 39
40
41 int Deoptimizer::patch_size() {
42 const int kCallInstructionSizeInWords = 3;
43 return kCallInstructionSizeInWords * Assembler::kInstrSize;
44 }
45
46
47
40 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { 48 void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
41 AssertNoAllocation no_allocation; 49 AssertNoAllocation no_allocation;
42 50
43 if (!function->IsOptimized()) return; 51 if (!function->IsOptimized()) return;
44 52
45 // Get the optimized code. 53 // Get the optimized code.
46 Code* code = function->code(); 54 Code* code = function->code();
47 55
48 // Invalidate the relocation information, as it will become invalid by the 56 // Invalidate the relocation information, as it will become invalid by the
49 // code patching below, and is not needed any more. 57 // code patching below, and is not needed any more.
50 code->InvalidateRelocation(); 58 code->InvalidateRelocation();
51 59
52 // For each return after a safepoint insert an absolute call to the 60 // For each return after a safepoint insert an absolute call to the
53 // corresponding deoptimization entry. 61 // corresponding deoptimization entry.
62 ASSERT(patch_size() % Assembler::kInstrSize == 0);
63 int call_size_in_words = patch_size() / Assembler::kInstrSize;
54 unsigned last_pc_offset = 0; 64 unsigned last_pc_offset = 0;
55 SafepointTable table(function->code()); 65 SafepointTable table(function->code());
56 for (unsigned i = 0; i < table.length(); i++) { 66 for (unsigned i = 0; i < table.length(); i++) {
57 unsigned pc_offset = table.GetPcOffset(i); 67 unsigned pc_offset = table.GetPcOffset(i);
58 SafepointEntry safepoint_entry = table.GetEntry(i); 68 SafepointEntry safepoint_entry = table.GetEntry(i);
59 int deoptimization_index = safepoint_entry.deoptimization_index(); 69 int deoptimization_index = safepoint_entry.deoptimization_index();
60 int gap_code_size = safepoint_entry.gap_code_size(); 70 int gap_code_size = safepoint_entry.gap_code_size();
61 // Check that we did not shoot past next safepoint. 71 // Check that we did not shoot past next safepoint.
62 // TODO(srdjan): How do we guarantee that safepoint code does not 72 // TODO(srdjan): How do we guarantee that safepoint code does not
63 // overlap other safepoint patching code? 73 // overlap other safepoint patching code?
64 CHECK(pc_offset >= last_pc_offset); 74 CHECK(pc_offset >= last_pc_offset);
65 #ifdef DEBUG 75 #ifdef DEBUG
66 // Destroy the code which is not supposed to be run again. 76 // Destroy the code which is not supposed to be run again.
67 int instructions = (pc_offset - last_pc_offset) / Assembler::kInstrSize; 77 int instructions = (pc_offset - last_pc_offset) / Assembler::kInstrSize;
68 CodePatcher destroyer(code->instruction_start() + last_pc_offset, 78 CodePatcher destroyer(code->instruction_start() + last_pc_offset,
69 instructions); 79 instructions);
70 for (int x = 0; x < instructions; x++) { 80 for (int x = 0; x < instructions; x++) {
71 destroyer.masm()->bkpt(0); 81 destroyer.masm()->bkpt(0);
72 } 82 }
73 #endif 83 #endif
74 last_pc_offset = pc_offset; 84 last_pc_offset = pc_offset;
75 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { 85 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) {
76 const int kCallInstructionSizeInWords = 3; 86 last_pc_offset += gap_code_size;
77 CodePatcher patcher(code->instruction_start() + pc_offset + gap_code_size, 87 CodePatcher patcher(code->instruction_start() + last_pc_offset,
78 kCallInstructionSizeInWords); 88 call_size_in_words);
79 Address deoptimization_entry = Deoptimizer::GetDeoptimizationEntry( 89 Address deoptimization_entry = Deoptimizer::GetDeoptimizationEntry(
80 deoptimization_index, Deoptimizer::LAZY); 90 deoptimization_index, Deoptimizer::LAZY);
81 patcher.masm()->Call(deoptimization_entry, RelocInfo::NONE); 91 patcher.masm()->Call(deoptimization_entry, RelocInfo::NONE);
82 last_pc_offset += 92 last_pc_offset += patch_size();
83 gap_code_size + kCallInstructionSizeInWords * Assembler::kInstrSize;
84 } 93 }
85 } 94 }
86 95
87 96
88 #ifdef DEBUG 97 #ifdef DEBUG
89 // Destroy the code which is not supposed to be run again. 98 // Destroy the code which is not supposed to be run again.
90 int instructions = 99 int instructions =
91 (code->safepoint_table_start() - last_pc_offset) / Assembler::kInstrSize; 100 (code->safepoint_table_start() - last_pc_offset) / Assembler::kInstrSize;
92 CodePatcher destroyer(code->instruction_start() + last_pc_offset, 101 CodePatcher destroyer(code->instruction_start() + last_pc_offset,
93 instructions); 102 instructions);
(...skipping 12 matching lines...) Expand all
106 function->ReplaceCode(function->shared()->code()); 115 function->ReplaceCode(function->shared()->code());
107 116
108 if (FLAG_trace_deopt) { 117 if (FLAG_trace_deopt) {
109 PrintF("[forced deoptimization: "); 118 PrintF("[forced deoptimization: ");
110 function->PrintName(); 119 function->PrintName();
111 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); 120 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function));
112 } 121 }
113 } 122 }
114 123
115 124
116 void Deoptimizer::PatchStackCheckCode(Code* unoptimized_code, 125 void Deoptimizer::PatchStackCheckCodeAt(Address pc_after,
117 Code* check_code, 126 Code* check_code,
118 Code* replacement_code) { 127 Code* replacement_code) {
119 UNIMPLEMENTED(); 128 UNIMPLEMENTED();
120 } 129 }
121 130
122 131
123 void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code, 132 void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
124 Code* check_code, 133 Code* check_code,
125 Code* replacement_code) { 134 Code* replacement_code) {
126 UNIMPLEMENTED(); 135 UNIMPLEMENTED();
127 } 136 }
128 137
129 138
130 void Deoptimizer::DoComputeOsrOutputFrame() { 139 void Deoptimizer::DoComputeOsrOutputFrame() {
131 UNIMPLEMENTED(); 140 UNIMPLEMENTED();
132 } 141 }
133 142
134 143
135 // This code is very similar to ia32 code, but relies on register names (fp, sp) 144 // This code is very similar to ia32 code, but relies on register names (fp, sp)
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 __ push(ip); 510 __ push(ip);
502 __ b(&done); 511 __ b(&done);
503 ASSERT(masm()->pc_offset() - start == table_entry_size_); 512 ASSERT(masm()->pc_offset() - start == table_entry_size_);
504 } 513 }
505 __ bind(&done); 514 __ bind(&done);
506 } 515 }
507 516
508 #undef __ 517 #undef __
509 518
510 } } // namespace v8::internal 519 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/codegen-arm.cc ('k') | src/arm/disasm-arm.cc » ('j') | src/ast.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698