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

Side by Side Diff: src/objects-printer.cc

Issue 1230753004: [Interpreter] Add BytecodeArray class and add to SharedFunctionInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Avoid outputting junk data in BytecodeArray::Print() and ByteArray::Print(). Created 5 years, 5 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/disasm.h" 7 #include "src/disasm.h"
8 #include "src/disassembler.h" 8 #include "src/disassembler.h"
9 #include "src/heap/objects-visiting.h" 9 #include "src/heap/objects-visiting.h"
10 #include "src/interpreter/bytecodes.h"
10 #include "src/jsregexp.h" 11 #include "src/jsregexp.h"
11 #include "src/ostreams.h" 12 #include "src/ostreams.h"
12 13
13 namespace v8 { 14 namespace v8 {
14 namespace internal { 15 namespace internal {
15 16
16 #ifdef OBJECT_PRINT 17 #ifdef OBJECT_PRINT
17 18
18 void Object::Print() { 19 void Object::Print() {
19 OFStream os(stdout); 20 OFStream os(stdout);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 break; 66 break;
66 case FIXED_DOUBLE_ARRAY_TYPE: 67 case FIXED_DOUBLE_ARRAY_TYPE:
67 FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(os); 68 FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(os);
68 break; 69 break;
69 case FIXED_ARRAY_TYPE: 70 case FIXED_ARRAY_TYPE:
70 FixedArray::cast(this)->FixedArrayPrint(os); 71 FixedArray::cast(this)->FixedArrayPrint(os);
71 break; 72 break;
72 case BYTE_ARRAY_TYPE: 73 case BYTE_ARRAY_TYPE:
73 ByteArray::cast(this)->ByteArrayPrint(os); 74 ByteArray::cast(this)->ByteArrayPrint(os);
74 break; 75 break;
76 case BYTECODE_ARRAY_TYPE:
77 BytecodeArray::cast(this)->BytecodeArrayPrint(os);
78 break;
75 case FREE_SPACE_TYPE: 79 case FREE_SPACE_TYPE:
76 FreeSpace::cast(this)->FreeSpacePrint(os); 80 FreeSpace::cast(this)->FreeSpacePrint(os);
77 break; 81 break;
78 82
79 #define PRINT_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ 83 #define PRINT_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \
80 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ 84 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
81 External##Type##Array::cast(this)->External##Type##ArrayPrint(os); \ 85 External##Type##Array::cast(this)->External##Type##ArrayPrint(os); \
82 break; 86 break;
83 87
84 TYPED_ARRAYS(PRINT_EXTERNAL_ARRAY) 88 TYPED_ARRAYS(PRINT_EXTERNAL_ARRAY)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 194
191 default: 195 default:
192 os << "UNKNOWN TYPE " << map()->instance_type(); 196 os << "UNKNOWN TYPE " << map()->instance_type();
193 UNREACHABLE(); 197 UNREACHABLE();
194 break; 198 break;
195 } 199 }
196 } 200 }
197 201
198 202
199 void ByteArray::ByteArrayPrint(std::ostream& os) { // NOLINT 203 void ByteArray::ByteArrayPrint(std::ostream& os) { // NOLINT
200 os << "byte array, data starts at " << GetDataStartAddress(); 204 ScopedVector<char> buf(100);
205 SNPrintF(buf, "byte array, data starts at %p", GetDataStartAddress());
206 os << buf.start();
rmcilroy 2015/07/20 11:39:46 nit - do you need to change this function?
oth 2015/07/20 13:47:30 Done.
201 } 207 }
202 208
203 209
210 void BytecodeArray::BytecodeArrayPrint(std::ostream& os) { // NOLINT
211 ScopedVector<char> buf(100);
212 SNPrintF(buf, "bytecode array, starts at %p (%d bytes)\n",
213 GetFirstBytecodeAddress(), length());
214 os << buf.start();
rmcilroy 2015/07/20 11:39:46 I don't think these lines is necessary - it should
oth 2015/07/20 13:47:30 Done.
215 Disassemble(os);
216 }
217
218
204 void FreeSpace::FreeSpacePrint(std::ostream& os) { // NOLINT 219 void FreeSpace::FreeSpacePrint(std::ostream& os) { // NOLINT
205 os << "free space, size " << Size(); 220 os << "free space, size " << Size();
206 } 221 }
207 222
208 223
209 #define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \ 224 #define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \
210 void External##Type##Array::External##Type##ArrayPrint(std::ostream& os) { \ 225 void External##Type##Array::External##Type##ArrayPrint(std::ostream& os) { \
211 os << "external " #type " array"; \ 226 os << "external " #type " array"; \
212 } 227 }
213 228
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 // script()->Print(os); 772 // script()->Print(os);
758 os << "\n - function token position = " << function_token_position(); 773 os << "\n - function token position = " << function_token_position();
759 os << "\n - start position = " << start_position(); 774 os << "\n - start position = " << start_position();
760 os << "\n - end position = " << end_position(); 775 os << "\n - end position = " << end_position();
761 os << "\n - is expression = " << is_expression(); 776 os << "\n - is expression = " << is_expression();
762 os << "\n - debug info = " << Brief(debug_info()); 777 os << "\n - debug info = " << Brief(debug_info());
763 os << "\n - length = " << length(); 778 os << "\n - length = " << length();
764 os << "\n - optimized_code_map = " << Brief(optimized_code_map()); 779 os << "\n - optimized_code_map = " << Brief(optimized_code_map());
765 os << "\n - feedback_vector = "; 780 os << "\n - feedback_vector = ";
766 feedback_vector()->FixedArrayPrint(os); 781 feedback_vector()->FixedArrayPrint(os);
782 os << "\n - bytecode_array = " << bytecode_array();
767 os << "\n"; 783 os << "\n";
768 } 784 }
769 785
770 786
771 void JSGlobalProxy::JSGlobalProxyPrint(std::ostream& os) { // NOLINT 787 void JSGlobalProxy::JSGlobalProxyPrint(std::ostream& os) { // NOLINT
772 os << "global_proxy "; 788 os << "global_proxy ";
773 JSObjectPrint(os); 789 JSObjectPrint(os);
774 os << "native context : " << Brief(native_context()); 790 os << "native context : " << Brief(native_context());
775 os << "\n"; 791 os << "\n";
776 } 792 }
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 } 1187 }
1172 } 1188 }
1173 1189
1174 1190
1175 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT 1191 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT
1176 TransitionArray::PrintTransitions(os, map()->raw_transitions()); 1192 TransitionArray::PrintTransitions(os, map()->raw_transitions());
1177 } 1193 }
1178 #endif // defined(DEBUG) || defined(OBJECT_PRINT) 1194 #endif // defined(DEBUG) || defined(OBJECT_PRINT)
1179 } // namespace internal 1195 } // namespace internal
1180 } // namespace v8 1196 } // namespace v8
OLDNEW
« src/objects-inl.h ('K') | « src/objects-inl.h ('k') | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698