OLD | NEW |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 fprintf(f, "%s\n", out->Finalize()); | 104 fprintf(f, "%s\n", out->Finalize()); |
105 } | 105 } |
106 out->Reset(); | 106 out->Reset(); |
107 } | 107 } |
108 | 108 |
109 | 109 |
110 | 110 |
111 static const int kOutBufferSize = 2048 + String::kMaxShortPrintLength; | 111 static const int kOutBufferSize = 2048 + String::kMaxShortPrintLength; |
112 static const int kRelocInfoPosition = 57; | 112 static const int kRelocInfoPosition = 57; |
113 | 113 |
114 static int DecodeIt(FILE* f, | 114 static int DecodeIt(Isolate* isolate, |
| 115 FILE* f, |
115 const V8NameConverter& converter, | 116 const V8NameConverter& converter, |
116 byte* begin, | 117 byte* begin, |
117 byte* end) { | 118 byte* end) { |
118 NoHandleAllocation ha; | 119 NoHandleAllocation ha(isolate); |
119 AssertNoAllocation no_alloc; | 120 AssertNoAllocation no_alloc; |
120 ExternalReferenceEncoder ref_encoder; | 121 ExternalReferenceEncoder ref_encoder; |
121 Heap* heap = HEAP; | 122 Heap* heap = HEAP; |
122 | 123 |
123 v8::internal::EmbeddedVector<char, 128> decode_buffer; | 124 v8::internal::EmbeddedVector<char, 128> decode_buffer; |
124 v8::internal::EmbeddedVector<char, kOutBufferSize> out_buffer; | 125 v8::internal::EmbeddedVector<char, kOutBufferSize> out_buffer; |
125 StringBuilder out(out_buffer.start(), out_buffer.length()); | 126 StringBuilder out(out_buffer.start(), out_buffer.length()); |
126 byte* pc = begin; | 127 byte* pc = begin; |
127 disasm::Disassembler d(converter); | 128 disasm::Disassembler d(converter); |
128 RelocIterator* it = NULL; | 129 RelocIterator* it = NULL; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 out.AddFormatted("minor: %d", minor_key); | 276 out.AddFormatted("minor: %d", minor_key); |
276 } | 277 } |
277 } | 278 } |
278 } else { | 279 } else { |
279 out.AddFormatted(" %s", Code::Kind2String(kind)); | 280 out.AddFormatted(" %s", Code::Kind2String(kind)); |
280 } | 281 } |
281 if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { | 282 if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { |
282 out.AddFormatted(" (id = %d)", static_cast<int>(relocinfo.data())); | 283 out.AddFormatted(" (id = %d)", static_cast<int>(relocinfo.data())); |
283 } | 284 } |
284 } else if (rmode == RelocInfo::RUNTIME_ENTRY && | 285 } else if (rmode == RelocInfo::RUNTIME_ENTRY && |
285 Isolate::Current()->deoptimizer_data() != NULL) { | 286 isolate->deoptimizer_data() != NULL) { |
286 // A runtime entry reloinfo might be a deoptimization bailout. | 287 // A runtime entry reloinfo might be a deoptimization bailout. |
287 Address addr = relocinfo.target_address(); | 288 Address addr = relocinfo.target_address(); |
288 int id = Deoptimizer::GetDeoptimizationId(addr, Deoptimizer::EAGER); | 289 int id = Deoptimizer::GetDeoptimizationId(addr, Deoptimizer::EAGER); |
289 if (id == Deoptimizer::kNotDeoptimizationEntry) { | 290 if (id == Deoptimizer::kNotDeoptimizationEntry) { |
290 id = Deoptimizer::GetDeoptimizationId(addr, Deoptimizer::LAZY); | 291 id = Deoptimizer::GetDeoptimizationId(addr, Deoptimizer::LAZY); |
291 if (id == Deoptimizer::kNotDeoptimizationEntry) { | 292 if (id == Deoptimizer::kNotDeoptimizationEntry) { |
292 out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode)); | 293 out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode)); |
293 } else { | 294 } else { |
294 out.AddFormatted(" ;; lazy deoptimization bailout %d", id); | 295 out.AddFormatted(" ;; lazy deoptimization bailout %d", id); |
295 } | 296 } |
(...skipping 16 matching lines...) Expand all Loading... |
312 DumpBuffer(f, &out); | 313 DumpBuffer(f, &out); |
313 } | 314 } |
314 } | 315 } |
315 } | 316 } |
316 | 317 |
317 delete it; | 318 delete it; |
318 return static_cast<int>(pc - begin); | 319 return static_cast<int>(pc - begin); |
319 } | 320 } |
320 | 321 |
321 | 322 |
322 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { | 323 int Disassembler::Decode(Isolate* isolate, FILE* f, byte* begin, byte* end) { |
323 V8NameConverter defaultConverter(NULL); | 324 V8NameConverter defaultConverter(NULL); |
324 return DecodeIt(f, defaultConverter, begin, end); | 325 return DecodeIt(isolate, f, defaultConverter, begin, end); |
325 } | 326 } |
326 | 327 |
327 | 328 |
328 // Called by Code::CodePrint. | 329 // Called by Code::CodePrint. |
329 void Disassembler::Decode(FILE* f, Code* code) { | 330 void Disassembler::Decode(FILE* f, Code* code) { |
| 331 Isolate* isolate = code->GetIsolate(); |
330 int decode_size = (code->kind() == Code::OPTIMIZED_FUNCTION || | 332 int decode_size = (code->kind() == Code::OPTIMIZED_FUNCTION || |
331 code->kind() == Code::COMPILED_STUB) | 333 code->kind() == Code::COMPILED_STUB) |
332 ? static_cast<int>(code->safepoint_table_offset()) | 334 ? static_cast<int>(code->safepoint_table_offset()) |
333 : code->instruction_size(); | 335 : code->instruction_size(); |
334 // If there might be a stack check table, stop before reaching it. | 336 // If there might be a stack check table, stop before reaching it. |
335 if (code->kind() == Code::FUNCTION) { | 337 if (code->kind() == Code::FUNCTION) { |
336 decode_size = | 338 decode_size = |
337 Min(decode_size, static_cast<int>(code->stack_check_table_offset())); | 339 Min(decode_size, static_cast<int>(code->stack_check_table_offset())); |
338 } | 340 } |
339 | 341 |
340 byte* begin = code->instruction_start(); | 342 byte* begin = code->instruction_start(); |
341 byte* end = begin + decode_size; | 343 byte* end = begin + decode_size; |
342 V8NameConverter v8NameConverter(code); | 344 V8NameConverter v8NameConverter(code); |
343 DecodeIt(f, v8NameConverter, begin, end); | 345 DecodeIt(isolate, f, v8NameConverter, begin, end); |
344 } | 346 } |
345 | 347 |
346 #else // ENABLE_DISASSEMBLER | 348 #else // ENABLE_DISASSEMBLER |
347 | 349 |
348 void Disassembler::Dump(FILE* f, byte* begin, byte* end) {} | 350 void Disassembler::Dump(FILE* f, byte* begin, byte* end) {} |
349 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { return 0; } | 351 int Disassembler::Decode(Isolate* isolate, FILE* f, byte* begin, byte* end) { |
| 352 return 0; |
| 353 } |
350 void Disassembler::Decode(FILE* f, Code* code) {} | 354 void Disassembler::Decode(FILE* f, Code* code) {} |
351 | 355 |
352 #endif // ENABLE_DISASSEMBLER | 356 #endif // ENABLE_DISASSEMBLER |
353 | 357 |
354 } } // namespace v8::internal | 358 } } // namespace v8::internal |
OLD | NEW |