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

Side by Side Diff: src/disassembler.cc

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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/disasm.h ('k') | src/execution.h » ('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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 59
60 class V8NameConverter: public disasm::NameConverter { 60 class V8NameConverter: public disasm::NameConverter {
61 public: 61 public:
62 explicit V8NameConverter(Code* code) : code_(code) {} 62 explicit V8NameConverter(Code* code) : code_(code) {}
63 virtual const char* NameOfAddress(byte* pc) const; 63 virtual const char* NameOfAddress(byte* pc) const;
64 virtual const char* NameInCode(byte* addr) const; 64 virtual const char* NameInCode(byte* addr) const;
65 Code* code() const { return code_; } 65 Code* code() const { return code_; }
66 private: 66 private:
67 Code* code_; 67 Code* code_;
68
69 EmbeddedVector<char, 128> v8_buffer_;
68 }; 70 };
69 71
70 72
71 const char* V8NameConverter::NameOfAddress(byte* pc) const { 73 const char* V8NameConverter::NameOfAddress(byte* pc) const {
72 static v8::internal::EmbeddedVector<char, 128> buffer; 74 const char* name = Isolate::Current()->builtins()->Lookup(pc);
73
74 const char* name = Builtins::Lookup(pc);
75 if (name != NULL) { 75 if (name != NULL) {
76 OS::SNPrintF(buffer, "%s (%p)", name, pc); 76 OS::SNPrintF(v8_buffer_, "%s (%p)", name, pc);
77 return buffer.start(); 77 return v8_buffer_.start();
78 } 78 }
79 79
80 if (code_ != NULL) { 80 if (code_ != NULL) {
81 int offs = static_cast<int>(pc - code_->instruction_start()); 81 int offs = static_cast<int>(pc - code_->instruction_start());
82 // print as code offset, if it seems reasonable 82 // print as code offset, if it seems reasonable
83 if (0 <= offs && offs < code_->instruction_size()) { 83 if (0 <= offs && offs < code_->instruction_size()) {
84 OS::SNPrintF(buffer, "%d (%p)", offs, pc); 84 OS::SNPrintF(v8_buffer_, "%d (%p)", offs, pc);
85 return buffer.start(); 85 return v8_buffer_.start();
86 } 86 }
87 } 87 }
88 88
89 return disasm::NameConverter::NameOfAddress(pc); 89 return disasm::NameConverter::NameOfAddress(pc);
90 } 90 }
91 91
92 92
93 const char* V8NameConverter::NameInCode(byte* addr) const { 93 const char* V8NameConverter::NameInCode(byte* addr) const {
94 // The V8NameConverter is used for well known code, so we can "safely" 94 // The V8NameConverter is used for well known code, so we can "safely"
95 // dereference pointers in generated code. 95 // dereference pointers in generated code.
(...skipping 12 matching lines...) Expand all
108 static const int kOutBufferSize = 2048 + String::kMaxShortPrintLength; 108 static const int kOutBufferSize = 2048 + String::kMaxShortPrintLength;
109 static const int kRelocInfoPosition = 57; 109 static const int kRelocInfoPosition = 57;
110 110
111 static int DecodeIt(FILE* f, 111 static int DecodeIt(FILE* f,
112 const V8NameConverter& converter, 112 const V8NameConverter& converter,
113 byte* begin, 113 byte* begin,
114 byte* end) { 114 byte* end) {
115 NoHandleAllocation ha; 115 NoHandleAllocation ha;
116 AssertNoAllocation no_alloc; 116 AssertNoAllocation no_alloc;
117 ExternalReferenceEncoder ref_encoder; 117 ExternalReferenceEncoder ref_encoder;
118 Heap* heap = HEAP;
118 119
119 v8::internal::EmbeddedVector<char, 128> decode_buffer; 120 v8::internal::EmbeddedVector<char, 128> decode_buffer;
120 v8::internal::EmbeddedVector<char, kOutBufferSize> out_buffer; 121 v8::internal::EmbeddedVector<char, kOutBufferSize> out_buffer;
121 byte* pc = begin; 122 byte* pc = begin;
122 disasm::Disassembler d(converter); 123 disasm::Disassembler d(converter);
123 RelocIterator* it = NULL; 124 RelocIterator* it = NULL;
124 if (converter.code() != NULL) { 125 if (converter.code() != NULL) {
125 it = new RelocIterator(converter.code()); 126 it = new RelocIterator(converter.code());
126 } else { 127 } else {
127 // No relocation information when printing code stubs. 128 // No relocation information when printing code stubs.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 250 }
250 if (code->ic_in_loop() == IN_LOOP) { 251 if (code->ic_in_loop() == IN_LOOP) {
251 out.AddFormatted(", in_loop"); 252 out.AddFormatted(", in_loop");
252 } 253 }
253 if (kind == Code::CALL_IC || kind == Code::KEYED_CALL_IC) { 254 if (kind == Code::CALL_IC || kind == Code::KEYED_CALL_IC) {
254 out.AddFormatted(", argc = %d", code->arguments_count()); 255 out.AddFormatted(", argc = %d", code->arguments_count());
255 } 256 }
256 } else if (kind == Code::STUB) { 257 } else if (kind == Code::STUB) {
257 // Reverse lookup required as the minor key cannot be retrieved 258 // Reverse lookup required as the minor key cannot be retrieved
258 // from the code object. 259 // from the code object.
259 Object* obj = Heap::code_stubs()->SlowReverseLookup(code); 260 Object* obj = heap->code_stubs()->SlowReverseLookup(code);
260 if (obj != Heap::undefined_value()) { 261 if (obj != heap->undefined_value()) {
261 ASSERT(obj->IsSmi()); 262 ASSERT(obj->IsSmi());
262 // Get the STUB key and extract major and minor key. 263 // Get the STUB key and extract major and minor key.
263 uint32_t key = Smi::cast(obj)->value(); 264 uint32_t key = Smi::cast(obj)->value();
264 uint32_t minor_key = CodeStub::MinorKeyFromKey(key); 265 uint32_t minor_key = CodeStub::MinorKeyFromKey(key);
265 CodeStub::Major major_key = CodeStub::GetMajorKey(code); 266 CodeStub::Major major_key = CodeStub::GetMajorKey(code);
266 ASSERT(major_key == CodeStub::MajorKeyFromKey(key)); 267 ASSERT(major_key == CodeStub::MajorKeyFromKey(key));
267 out.AddFormatted(" %s, %s, ", 268 out.AddFormatted(" %s, %s, ",
268 Code::Kind2String(kind), 269 Code::Kind2String(kind),
269 CodeStub::MajorName(major_key, false)); 270 CodeStub::MajorName(major_key, false));
270 switch (major_key) { 271 switch (major_key) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 330
330 #else // ENABLE_DISASSEMBLER 331 #else // ENABLE_DISASSEMBLER
331 332
332 void Disassembler::Dump(FILE* f, byte* begin, byte* end) {} 333 void Disassembler::Dump(FILE* f, byte* begin, byte* end) {}
333 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { return 0; } 334 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { return 0; }
334 void Disassembler::Decode(FILE* f, Code* code) {} 335 void Disassembler::Decode(FILE* f, Code* code) {}
335 336
336 #endif // ENABLE_DISASSEMBLER 337 #endif // ENABLE_DISASSEMBLER
337 338
338 } } // namespace v8::internal 339 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/disasm.h ('k') | src/execution.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698