blob: 512f532ff9164638a1efeeb559d16d9275bed6da [file] [log] [blame]
jkummerow@chromium.org1145ef82012-02-02 16:21:15 +00001// Copyright 2012 the V8 project authors. All rights reserved.
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#include "v8.h"
29
30#include "disassembler.h"
31#include "disasm.h"
32#include "jsregexp.h"
33#include "objects-visiting.h"
34
35namespace v8 {
36namespace internal {
37
38#ifdef OBJECT_PRINT
39
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +000040void MaybeObject::Print() {
41 Print(stdout);
42}
43
44
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +000045void MaybeObject::Print(FILE* out) {
46 Object* this_as_object;
47 if (ToObject(&this_as_object)) {
48 if (this_as_object->IsSmi()) {
49 Smi::cast(this_as_object)->SmiPrint(out);
50 } else {
51 HeapObject::cast(this_as_object)->HeapObjectPrint(out);
52 }
53 } else {
54 Failure::cast(this)->FailurePrint(out);
55 }
56 Flush(out);
57}
58
59
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +000060void MaybeObject::PrintLn() {
61 PrintLn(stdout);
62}
63
64
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +000065void MaybeObject::PrintLn(FILE* out) {
66 Print(out);
67 PrintF(out, "\n");
68}
69
70
71void HeapObject::PrintHeader(FILE* out, const char* id) {
72 PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id);
73}
74
75
76void HeapObject::HeapObjectPrint(FILE* out) {
77 InstanceType instance_type = map()->instance_type();
78
yangguo@chromium.orgc03a1922013-02-19 13:55:47 +000079 HandleScope scope(GetIsolate());
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +000080 if (instance_type < FIRST_NONSTRING_TYPE) {
81 String::cast(this)->StringPrint(out);
82 return;
83 }
84
85 switch (instance_type) {
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +000086 case SYMBOL_TYPE:
87 Symbol::cast(this)->SymbolPrint(out);
88 break;
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +000089 case MAP_TYPE:
90 Map::cast(this)->MapPrint(out);
91 break;
92 case HEAP_NUMBER_TYPE:
93 HeapNumber::cast(this)->HeapNumberPrint(out);
94 break;
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000095 case FIXED_DOUBLE_ARRAY_TYPE:
96 FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(out);
97 break;
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +000098 case CONSTANT_POOL_ARRAY_TYPE:
99 ConstantPoolArray::cast(this)->ConstantPoolArrayPrint(out);
100 break;
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000101 case FIXED_ARRAY_TYPE:
102 FixedArray::cast(this)->FixedArrayPrint(out);
103 break;
104 case BYTE_ARRAY_TYPE:
105 ByteArray::cast(this)->ByteArrayPrint(out);
106 break;
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000107 case FREE_SPACE_TYPE:
108 FreeSpace::cast(this)->FreeSpacePrint(out);
109 break;
danno@chromium.org4d3fe4e2011-03-10 10:14:28 +0000110 case EXTERNAL_PIXEL_ARRAY_TYPE:
111 ExternalPixelArray::cast(this)->ExternalPixelArrayPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000112 break;
113 case EXTERNAL_BYTE_ARRAY_TYPE:
114 ExternalByteArray::cast(this)->ExternalByteArrayPrint(out);
115 break;
116 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
117 ExternalUnsignedByteArray::cast(this)
118 ->ExternalUnsignedByteArrayPrint(out);
119 break;
120 case EXTERNAL_SHORT_ARRAY_TYPE:
121 ExternalShortArray::cast(this)->ExternalShortArrayPrint(out);
122 break;
123 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
124 ExternalUnsignedShortArray::cast(this)
125 ->ExternalUnsignedShortArrayPrint(out);
126 break;
127 case EXTERNAL_INT_ARRAY_TYPE:
128 ExternalIntArray::cast(this)->ExternalIntArrayPrint(out);
129 break;
130 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
131 ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint(out);
132 break;
133 case EXTERNAL_FLOAT_ARRAY_TYPE:
134 ExternalFloatArray::cast(this)->ExternalFloatArrayPrint(out);
135 break;
erik.corry@gmail.com3847bd52011-04-27 10:38:56 +0000136 case EXTERNAL_DOUBLE_ARRAY_TYPE:
137 ExternalDoubleArray::cast(this)->ExternalDoubleArrayPrint(out);
138 break;
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000139 case FILLER_TYPE:
140 PrintF(out, "filler");
141 break;
142 case JS_OBJECT_TYPE: // fall through
143 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
144 case JS_ARRAY_TYPE:
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000145 case JS_GENERATOR_OBJECT_TYPE:
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000146 case JS_REGEXP_TYPE:
147 JSObject::cast(this)->JSObjectPrint(out);
148 break;
149 case ODDBALL_TYPE:
150 Oddball::cast(this)->to_string()->Print(out);
151 break;
erik.corry@gmail.comed49e962012-04-17 11:57:53 +0000152 case JS_MODULE_TYPE:
153 JSModule::cast(this)->JSModulePrint(out);
154 break;
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000155 case JS_FUNCTION_TYPE:
156 JSFunction::cast(this)->JSFunctionPrint(out);
157 break;
158 case JS_GLOBAL_PROXY_TYPE:
159 JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out);
160 break;
161 case JS_GLOBAL_OBJECT_TYPE:
162 JSGlobalObject::cast(this)->JSGlobalObjectPrint(out);
163 break;
164 case JS_BUILTINS_OBJECT_TYPE:
165 JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out);
166 break;
167 case JS_VALUE_TYPE:
168 PrintF(out, "Value wrapper around:");
169 JSValue::cast(this)->value()->Print(out);
170 break;
svenpanne@chromium.org4efbdb12012-03-12 08:18:42 +0000171 case JS_DATE_TYPE:
erik.corry@gmail.comed49e962012-04-17 11:57:53 +0000172 JSDate::cast(this)->JSDatePrint(out);
svenpanne@chromium.org4efbdb12012-03-12 08:18:42 +0000173 break;
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000174 case CODE_TYPE:
175 Code::cast(this)->CodePrint(out);
176 break;
vegorov@chromium.org7304bca2011-05-16 12:14:13 +0000177 case JS_PROXY_TYPE:
178 JSProxy::cast(this)->JSProxyPrint(out);
179 break;
lrn@chromium.org34e60782011-09-15 07:25:40 +0000180 case JS_FUNCTION_PROXY_TYPE:
181 JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out);
182 break;
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000183 case JS_SET_TYPE:
184 JSSet::cast(this)->JSSetPrint(out);
185 break;
186 case JS_MAP_TYPE:
187 JSMap::cast(this)->JSMapPrint(out);
188 break;
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000189 case JS_WEAK_MAP_TYPE:
190 JSWeakMap::cast(this)->JSWeakMapPrint(out);
191 break;
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +0000192 case JS_WEAK_SET_TYPE:
193 JSWeakSet::cast(this)->JSWeakSetPrint(out);
194 break;
ager@chromium.orgea91cc52011-05-23 06:06:11 +0000195 case FOREIGN_TYPE:
196 Foreign::cast(this)->ForeignPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000197 break;
198 case SHARED_FUNCTION_INFO_TYPE:
199 SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out);
200 break;
kmillikin@chromium.org31b12772011-02-02 16:08:26 +0000201 case JS_MESSAGE_OBJECT_TYPE:
202 JSMessageObject::cast(this)->JSMessageObjectPrint(out);
203 break;
danno@chromium.org41728482013-06-12 22:31:22 +0000204 case CELL_TYPE:
205 Cell::cast(this)->CellPrint(out);
206 break;
207 case PROPERTY_CELL_TYPE:
dslomov@chromium.orgb752d402013-06-18 11:54:54 +0000208 PropertyCell::cast(this)->PropertyCellPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000209 break;
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000210 case JS_ARRAY_BUFFER_TYPE:
211 JSArrayBuffer::cast(this)->JSArrayBufferPrint(out);
mstarzinger@chromium.orgb228be02013-04-18 14:56:59 +0000212 break;
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000213 case JS_TYPED_ARRAY_TYPE:
214 JSTypedArray::cast(this)->JSTypedArrayPrint(out);
mstarzinger@chromium.orgb228be02013-04-18 14:56:59 +0000215 break;
mstarzinger@chromium.org1510d582013-06-28 14:00:48 +0000216 case JS_DATA_VIEW_TYPE:
217 JSDataView::cast(this)->JSDataViewPrint(out);
218 break;
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000219#define MAKE_STRUCT_CASE(NAME, Name, name) \
220 case NAME##_TYPE: \
221 Name::cast(this)->Name##Print(out); \
222 break;
223 STRUCT_LIST(MAKE_STRUCT_CASE)
224#undef MAKE_STRUCT_CASE
225
226 default:
227 PrintF(out, "UNKNOWN TYPE %d", map()->instance_type());
228 UNREACHABLE();
229 break;
230 }
231}
232
233
234void ByteArray::ByteArrayPrint(FILE* out) {
235 PrintF(out, "byte array, data starts at %p", GetDataStartAddress());
236}
237
238
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000239void FreeSpace::FreeSpacePrint(FILE* out) {
240 PrintF(out, "free space, size %d", Size());
241}
242
243
danno@chromium.org4d3fe4e2011-03-10 10:14:28 +0000244void ExternalPixelArray::ExternalPixelArrayPrint(FILE* out) {
245 PrintF(out, "external pixel array");
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000246}
247
248
249void ExternalByteArray::ExternalByteArrayPrint(FILE* out) {
250 PrintF(out, "external byte array");
251}
252
253
254void ExternalUnsignedByteArray::ExternalUnsignedByteArrayPrint(FILE* out) {
255 PrintF(out, "external unsigned byte array");
256}
257
258
259void ExternalShortArray::ExternalShortArrayPrint(FILE* out) {
260 PrintF(out, "external short array");
261}
262
263
264void ExternalUnsignedShortArray::ExternalUnsignedShortArrayPrint(FILE* out) {
265 PrintF(out, "external unsigned short array");
266}
267
268
269void ExternalIntArray::ExternalIntArrayPrint(FILE* out) {
270 PrintF(out, "external int array");
271}
272
273
274void ExternalUnsignedIntArray::ExternalUnsignedIntArrayPrint(FILE* out) {
275 PrintF(out, "external unsigned int array");
276}
277
278
279void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) {
280 PrintF(out, "external float array");
281}
282
283
erik.corry@gmail.com3847bd52011-04-27 10:38:56 +0000284void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) {
285 PrintF(out, "external double array");
286}
287
288
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000289void JSObject::PrintProperties(FILE* out) {
290 if (HasFastProperties()) {
291 DescriptorArray* descs = map()->instance_descriptors();
verwaest@chromium.org06ab2ec2012-10-09 17:00:13 +0000292 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000293 PrintF(out, " ");
ulan@chromium.org750145a2013-03-07 15:14:13 +0000294 descs->GetKey(i)->NamePrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000295 PrintF(out, ": ");
296 switch (descs->GetType(i)) {
297 case FIELD: {
298 int index = descs->GetFieldIndex(i);
ulan@chromium.org57ff8812013-05-10 08:16:55 +0000299 RawFastPropertyAt(index)->ShortPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000300 PrintF(out, " (field at offset %d)\n", index);
301 break;
302 }
jkummerow@chromium.orgfb732b12013-07-26 10:27:09 +0000303 case CONSTANT:
304 descs->GetConstant(i)->ShortPrint(out);
305 PrintF(out, " (constant)\n");
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000306 break;
307 case CALLBACKS:
308 descs->GetCallbacksObject(i)->ShortPrint(out);
309 PrintF(out, " (callback)\n");
310 break;
danno@chromium.orgc612e022011-11-10 11:38:15 +0000311 case NORMAL: // only in slow mode
312 case HANDLER: // only in lookup results, not in descriptors
313 case INTERCEPTOR: // only in lookup results, not in descriptors
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000314 // There are no transitions in the descriptor array.
315 case TRANSITION:
jkummerow@chromium.org7a6fc812012-06-27 11:12:38 +0000316 case NONEXISTENT:
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000317 UNREACHABLE();
318 break;
319 }
320 }
321 } else {
322 property_dictionary()->Print(out);
323 }
324}
325
326
327void JSObject::PrintElements(FILE* out) {
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000328 // Don't call GetElementsKind, its validation code can cause the printer to
329 // fail when debugging.
330 switch (map()->elements_kind()) {
svenpanne@chromium.org830d30c2012-05-29 13:20:14 +0000331 case FAST_HOLEY_SMI_ELEMENTS:
332 case FAST_SMI_ELEMENTS:
333 case FAST_HOLEY_ELEMENTS:
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000334 case FAST_ELEMENTS: {
335 // Print in array notation for non-sparse arrays.
336 FixedArray* p = FixedArray::cast(elements());
337 for (int i = 0; i < p->length(); i++) {
338 PrintF(out, " %d: ", i);
339 p->get(i)->ShortPrint(out);
340 PrintF(out, "\n");
341 }
342 break;
343 }
svenpanne@chromium.org830d30c2012-05-29 13:20:14 +0000344 case FAST_HOLEY_DOUBLE_ELEMENTS:
ricow@chromium.org9fa09672011-07-25 11:05:35 +0000345 case FAST_DOUBLE_ELEMENTS: {
346 // Print in array notation for non-sparse arrays.
jkummerow@chromium.org212d9642012-05-11 15:02:09 +0000347 if (elements()->length() > 0) {
348 FixedDoubleArray* p = FixedDoubleArray::cast(elements());
349 for (int i = 0; i < p->length(); i++) {
350 if (p->is_the_hole(i)) {
351 PrintF(out, " %d: <the hole>", i);
352 } else {
353 PrintF(out, " %d: %g", i, p->get_scalar(i));
354 }
355 PrintF(out, "\n");
ricow@chromium.org9fa09672011-07-25 11:05:35 +0000356 }
ricow@chromium.org9fa09672011-07-25 11:05:35 +0000357 }
358 break;
359 }
danno@chromium.org4d3fe4e2011-03-10 10:14:28 +0000360 case EXTERNAL_PIXEL_ELEMENTS: {
361 ExternalPixelArray* p = ExternalPixelArray::cast(elements());
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000362 for (int i = 0; i < p->length(); i++) {
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000363 PrintF(out, " %d: %d\n", i, p->get_scalar(i));
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000364 }
365 break;
366 }
367 case EXTERNAL_BYTE_ELEMENTS: {
368 ExternalByteArray* p = ExternalByteArray::cast(elements());
369 for (int i = 0; i < p->length(); i++) {
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000370 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i)));
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000371 }
372 break;
373 }
374 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: {
375 ExternalUnsignedByteArray* p =
376 ExternalUnsignedByteArray::cast(elements());
377 for (int i = 0; i < p->length(); i++) {
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000378 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i)));
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000379 }
380 break;
381 }
382 case EXTERNAL_SHORT_ELEMENTS: {
383 ExternalShortArray* p = ExternalShortArray::cast(elements());
384 for (int i = 0; i < p->length(); i++) {
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000385 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i)));
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000386 }
387 break;
388 }
389 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: {
390 ExternalUnsignedShortArray* p =
391 ExternalUnsignedShortArray::cast(elements());
392 for (int i = 0; i < p->length(); i++) {
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000393 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i)));
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000394 }
395 break;
396 }
397 case EXTERNAL_INT_ELEMENTS: {
398 ExternalIntArray* p = ExternalIntArray::cast(elements());
399 for (int i = 0; i < p->length(); i++) {
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000400 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i)));
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000401 }
402 break;
403 }
404 case EXTERNAL_UNSIGNED_INT_ELEMENTS: {
405 ExternalUnsignedIntArray* p =
406 ExternalUnsignedIntArray::cast(elements());
407 for (int i = 0; i < p->length(); i++) {
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000408 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i)));
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000409 }
410 break;
411 }
412 case EXTERNAL_FLOAT_ELEMENTS: {
413 ExternalFloatArray* p = ExternalFloatArray::cast(elements());
414 for (int i = 0; i < p->length(); i++) {
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000415 PrintF(out, " %d: %f\n", i, p->get_scalar(i));
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000416 }
417 break;
418 }
erik.corry@gmail.com3847bd52011-04-27 10:38:56 +0000419 case EXTERNAL_DOUBLE_ELEMENTS: {
420 ExternalDoubleArray* p = ExternalDoubleArray::cast(elements());
421 for (int i = 0; i < p->length(); i++) {
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000422 PrintF(out, " %d: %f\n", i, p->get_scalar(i));
erik.corry@gmail.com3847bd52011-04-27 10:38:56 +0000423 }
424 break;
425 }
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000426 case DICTIONARY_ELEMENTS:
427 elements()->Print(out);
428 break;
whesse@chromium.org7b260152011-06-20 15:33:18 +0000429 case NON_STRICT_ARGUMENTS_ELEMENTS: {
430 FixedArray* p = FixedArray::cast(elements());
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000431 PrintF(out, " parameter map:");
whesse@chromium.org7b260152011-06-20 15:33:18 +0000432 for (int i = 2; i < p->length(); i++) {
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000433 PrintF(out, " %d:", i - 2);
whesse@chromium.org7b260152011-06-20 15:33:18 +0000434 p->get(i)->ShortPrint(out);
whesse@chromium.org7b260152011-06-20 15:33:18 +0000435 }
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000436 PrintF(out, "\n context: ");
437 p->get(0)->ShortPrint(out);
438 PrintF(out, "\n arguments: ");
439 p->get(1)->ShortPrint(out);
440 PrintF(out, "\n");
whesse@chromium.org7b260152011-06-20 15:33:18 +0000441 break;
442 }
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000443 }
444}
445
446
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000447void JSObject::PrintTransitions(FILE* out) {
448 if (!map()->HasTransitionArray()) return;
449 TransitionArray* transitions = map()->transitions();
450 for (int i = 0; i < transitions->number_of_transitions(); i++) {
451 PrintF(out, " ");
ulan@chromium.org750145a2013-03-07 15:14:13 +0000452 transitions->GetKey(i)->NamePrint(out);
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000453 PrintF(out, ": ");
454 switch (transitions->GetTargetDetails(i).type()) {
455 case FIELD: {
456 PrintF(out, " (transition to field)\n");
457 break;
458 }
jkummerow@chromium.orgfb732b12013-07-26 10:27:09 +0000459 case CONSTANT:
460 PrintF(out, " (transition to constant)\n");
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000461 break;
462 case CALLBACKS:
463 PrintF(out, " (transition to callback)\n");
464 break;
465 // Values below are never in the target descriptor array.
466 case NORMAL:
467 case HANDLER:
468 case INTERCEPTOR:
469 case TRANSITION:
470 case NONEXISTENT:
471 UNREACHABLE();
472 break;
473 }
474 }
475}
476
477
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000478void JSObject::JSObjectPrint(FILE* out) {
479 PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this));
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000480 PrintF(out, " - map = %p [", reinterpret_cast<void*>(map()));
481 // Don't call GetElementsKind, its validation code can cause the printer to
482 // fail when debugging.
483 PrintElementsKind(out, this->map()->elements_kind());
484 PrintF(out,
485 "]\n - prototype = %p\n",
486 reinterpret_cast<void*>(GetPrototype()));
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000487 PrintF(out, " {\n");
488 PrintProperties(out);
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000489 PrintTransitions(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000490 PrintElements(out);
491 PrintF(out, " }\n");
492}
493
494
erik.corry@gmail.comed49e962012-04-17 11:57:53 +0000495void JSModule::JSModulePrint(FILE* out) {
496 HeapObject::PrintHeader(out, "JSModule");
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000497 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
erik.corry@gmail.comed49e962012-04-17 11:57:53 +0000498 PrintF(out, " - context = ");
499 context()->Print(out);
danno@chromium.org81cac2b2012-07-10 11:28:27 +0000500 PrintF(out, " - scope_info = ");
501 scope_info()->ShortPrint(out);
erik.corry@gmail.comed49e962012-04-17 11:57:53 +0000502 PrintElementsKind(out, this->map()->elements_kind());
503 PrintF(out, " {\n");
504 PrintProperties(out);
505 PrintElements(out);
506 PrintF(out, " }\n");
507}
508
509
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000510static const char* TypeToString(InstanceType type) {
511 switch (type) {
danno@chromium.org59400602013-08-13 17:09:37 +0000512#define TYPE_TO_STRING(TYPE) case TYPE: return #TYPE;
513 INSTANCE_TYPE_LIST(TYPE_TO_STRING)
514#undef TYPE_TO_STRING
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000515 }
danno@chromium.org59400602013-08-13 17:09:37 +0000516 UNREACHABLE();
517 return "UNKNOWN"; // Keep the compiler happy.
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000518}
519
520
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +0000521void Symbol::SymbolPrint(FILE* out) {
522 HeapObject::PrintHeader(out, "Symbol");
523 PrintF(out, " - hash: %d\n", Hash());
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000524 PrintF(out, " - name: ");
525 name()->ShortPrint();
machenbach@chromium.org0cc09502013-11-13 12:20:55 +0000526 PrintF(out, " - private: %d\n", is_private());
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000527 PrintF(out, "\n");
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +0000528}
529
530
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000531void Map::MapPrint(FILE* out) {
532 HeapObject::PrintHeader(out, "Map");
533 PrintF(out, " - type: %s\n", TypeToString(instance_type()));
534 PrintF(out, " - instance size: %d\n", instance_size());
535 PrintF(out, " - inobject properties: %d\n", inobject_properties());
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000536 PrintF(out, " - elements kind: ");
537 PrintElementsKind(out, elements_kind());
538 PrintF(out, "\n - pre-allocated property fields: %d\n",
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000539 pre_allocated_property_fields());
540 PrintF(out, " - unused property fields: %d\n", unused_property_fields());
541 if (is_hidden_prototype()) {
542 PrintF(out, " - hidden_prototype\n");
543 }
544 if (has_named_interceptor()) {
545 PrintF(out, " - named_interceptor\n");
546 }
547 if (has_indexed_interceptor()) {
548 PrintF(out, " - indexed_interceptor\n");
549 }
550 if (is_undetectable()) {
551 PrintF(out, " - undetectable\n");
552 }
553 if (has_instance_call_handler()) {
554 PrintF(out, " - instance_call_handler\n");
555 }
556 if (is_access_check_needed()) {
557 PrintF(out, " - access_check_needed\n");
558 }
verwaest@chromium.org33e09c82012-10-10 17:07:22 +0000559 PrintF(out, " - back pointer: ");
560 GetBackPointer()->ShortPrint(out);
jkummerow@chromium.org4e308cf2013-05-17 13:39:16 +0000561 PrintF(out, "\n - instance descriptors %s#%i: ",
562 owns_descriptors() ? "(own) " : "",
rossberg@chromium.org89e18f52012-10-22 13:09:53 +0000563 NumberOfOwnDescriptors());
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000564 instance_descriptors()->ShortPrint(out);
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000565 if (HasTransitionArray()) {
566 PrintF(out, "\n - transitions: ");
567 transitions()->ShortPrint(out);
568 }
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000569 PrintF(out, "\n - prototype: ");
570 prototype()->ShortPrint(out);
571 PrintF(out, "\n - constructor: ");
572 constructor()->ShortPrint(out);
mmassi@chromium.org7028c052012-06-13 11:51:58 +0000573 PrintF(out, "\n - code cache: ");
574 code_cache()->ShortPrint(out);
ulan@chromium.org750145a2013-03-07 15:14:13 +0000575 PrintF(out, "\n - dependent code: ");
576 dependent_code()->ShortPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000577 PrintF(out, "\n");
578}
579
580
581void CodeCache::CodeCachePrint(FILE* out) {
582 HeapObject::PrintHeader(out, "CodeCache");
583 PrintF(out, "\n - default_cache: ");
584 default_cache()->ShortPrint(out);
585 PrintF(out, "\n - normal_type_cache: ");
586 normal_type_cache()->ShortPrint(out);
587}
588
589
jkummerow@chromium.orge297f592011-06-08 10:05:15 +0000590void PolymorphicCodeCache::PolymorphicCodeCachePrint(FILE* out) {
591 HeapObject::PrintHeader(out, "PolymorphicCodeCache");
592 PrintF(out, "\n - cache: ");
593 cache()->ShortPrint(out);
594}
595
596
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +0000597void TypeFeedbackInfo::TypeFeedbackInfoPrint(FILE* out) {
598 HeapObject::PrintHeader(out, "TypeFeedbackInfo");
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +0000599 PrintF(out, " - ic_total_count: %d, ic_with_type_info_count: %d\n",
jkummerow@chromium.org1456e702012-03-30 08:38:13 +0000600 ic_total_count(), ic_with_type_info_count());
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +0000601 PrintF(out, " - type_feedback_cells: ");
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +0000602 type_feedback_cells()->FixedArrayPrint(out);
603}
604
605
yangguo@chromium.orgab30bb82012-02-24 14:41:46 +0000606void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(FILE* out) {
607 HeapObject::PrintHeader(out, "AliasedArgumentsEntry");
608 PrintF(out, "\n - aliased_context_slot: %d", aliased_context_slot());
609}
610
611
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000612void FixedArray::FixedArrayPrint(FILE* out) {
613 HeapObject::PrintHeader(out, "FixedArray");
614 PrintF(out, " - length: %d", length());
615 for (int i = 0; i < length(); i++) {
616 PrintF(out, "\n [%d]: ", i);
617 get(i)->ShortPrint(out);
618 }
619 PrintF(out, "\n");
620}
621
622
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000623void FixedDoubleArray::FixedDoubleArrayPrint(FILE* out) {
624 HeapObject::PrintHeader(out, "FixedDoubleArray");
625 PrintF(out, " - length: %d", length());
626 for (int i = 0; i < length(); i++) {
jkummerow@chromium.org1145ef82012-02-02 16:21:15 +0000627 if (is_the_hole(i)) {
628 PrintF(out, "\n [%d]: <the hole>", i);
629 } else {
630 PrintF(out, "\n [%d]: %g", i, get_scalar(i));
631 }
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000632 }
633 PrintF(out, "\n");
634}
635
636
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +0000637void ConstantPoolArray::ConstantPoolArrayPrint(FILE* out) {
638 HeapObject::PrintHeader(out, "ConstantPoolArray");
639 PrintF(out, " - length: %d", length());
640 for (int i = 0; i < length(); i++) {
641 if (i < first_ptr_index()) {
642 PrintF(out, "\n [%d]: double: %g", i, get_int64_entry_as_double(i));
643 } else if (i < first_int32_index()) {
644 PrintF(out, "\n [%d]: pointer: %p", i,
645 reinterpret_cast<void*>(get_ptr_entry(i)));
646 } else {
647 PrintF(out, "\n [%d]: int32: %d", i, get_int32_entry(i));
648 }
649 }
650 PrintF(out, "\n");
651}
652
653
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000654void JSValue::JSValuePrint(FILE* out) {
655 HeapObject::PrintHeader(out, "ValueObject");
656 value()->Print(out);
657}
658
659
kmillikin@chromium.org31b12772011-02-02 16:08:26 +0000660void JSMessageObject::JSMessageObjectPrint(FILE* out) {
661 HeapObject::PrintHeader(out, "JSMessageObject");
662 PrintF(out, " - type: ");
663 type()->ShortPrint(out);
664 PrintF(out, "\n - arguments: ");
665 arguments()->ShortPrint(out);
666 PrintF(out, "\n - start_position: %d", start_position());
667 PrintF(out, "\n - end_position: %d", end_position());
668 PrintF(out, "\n - script: ");
669 script()->ShortPrint(out);
670 PrintF(out, "\n - stack_trace: ");
671 stack_trace()->ShortPrint(out);
672 PrintF(out, "\n - stack_frames: ");
673 stack_frames()->ShortPrint(out);
674 PrintF(out, "\n");
675}
676
677
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000678void String::StringPrint(FILE* out) {
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +0000679 if (StringShape(this).IsInternalized()) {
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000680 PrintF(out, "#");
681 } else if (StringShape(this).IsCons()) {
682 PrintF(out, "c\"");
683 } else {
684 PrintF(out, "\"");
685 }
686
687 const char truncated_epilogue[] = "...<truncated>";
688 int len = length();
689 if (!FLAG_use_verbose_printer) {
690 if (len > 100) {
691 len = 100 - sizeof(truncated_epilogue);
692 }
693 }
694 for (int i = 0; i < len; i++) {
695 PrintF(out, "%c", Get(i));
696 }
697 if (len != length()) {
698 PrintF(out, "%s", truncated_epilogue);
699 }
700
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +0000701 if (!StringShape(this).IsInternalized()) PrintF(out, "\"");
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000702}
703
704
ulan@chromium.org750145a2013-03-07 15:14:13 +0000705void Name::NamePrint(FILE* out) {
706 if (IsString())
707 String::cast(this)->StringPrint(out);
708 else
709 ShortPrint();
710}
711
712
vegorov@chromium.org7943d462011-08-01 11:41:52 +0000713// This method is only meant to be called from gdb for debugging purposes.
ulan@chromium.org2efb9002012-01-19 15:36:35 +0000714// Since the string can also be in two-byte encoding, non-ASCII characters
vegorov@chromium.org7943d462011-08-01 11:41:52 +0000715// will be ignored in the output.
716char* String::ToAsciiArray() {
717 // Static so that subsequent calls frees previously allocated space.
718 // This also means that previous results will be overwritten.
719 static char* buffer = NULL;
720 if (buffer != NULL) free(buffer);
721 buffer = new char[length()+1];
jkummerow@chromium.org9439d1f2013-01-09 17:13:11 +0000722 WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length());
vegorov@chromium.org7943d462011-08-01 11:41:52 +0000723 buffer[length()] = 0;
724 return buffer;
725}
726
727
svenpanne@chromium.org4efbdb12012-03-12 08:18:42 +0000728static const char* const weekdays[] = {
729 "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
730};
731
mstarzinger@chromium.orge0e1b0d2013-07-08 08:38:06 +0000732
svenpanne@chromium.org4efbdb12012-03-12 08:18:42 +0000733void JSDate::JSDatePrint(FILE* out) {
734 HeapObject::PrintHeader(out, "JSDate");
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000735 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
svenpanne@chromium.org4efbdb12012-03-12 08:18:42 +0000736 PrintF(out, " - value = ");
737 value()->Print(out);
738 if (!year()->IsSmi()) {
739 PrintF(out, " - time = NaN\n");
740 } else {
741 PrintF(out, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
742 weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0],
743 year()->IsSmi() ? Smi::cast(year())->value() : -1,
744 month()->IsSmi() ? Smi::cast(month())->value() : -1,
745 day()->IsSmi() ? Smi::cast(day())->value() : -1,
746 hour()->IsSmi() ? Smi::cast(hour())->value() : -1,
747 min()->IsSmi() ? Smi::cast(min())->value() : -1,
748 sec()->IsSmi() ? Smi::cast(sec())->value() : -1);
749 }
750}
751
752
vegorov@chromium.org7304bca2011-05-16 12:14:13 +0000753void JSProxy::JSProxyPrint(FILE* out) {
754 HeapObject::PrintHeader(out, "JSProxy");
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000755 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
vegorov@chromium.org7304bca2011-05-16 12:14:13 +0000756 PrintF(out, " - handler = ");
757 handler()->Print(out);
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000758 PrintF(out, " - hash = ");
759 hash()->Print(out);
vegorov@chromium.org7304bca2011-05-16 12:14:13 +0000760 PrintF(out, "\n");
761}
762
763
lrn@chromium.org34e60782011-09-15 07:25:40 +0000764void JSFunctionProxy::JSFunctionProxyPrint(FILE* out) {
765 HeapObject::PrintHeader(out, "JSFunctionProxy");
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000766 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
lrn@chromium.org34e60782011-09-15 07:25:40 +0000767 PrintF(out, " - handler = ");
768 handler()->Print(out);
769 PrintF(out, " - call_trap = ");
770 call_trap()->Print(out);
771 PrintF(out, " - construct_trap = ");
772 construct_trap()->Print(out);
773 PrintF(out, "\n");
774}
775
776
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000777void JSSet::JSSetPrint(FILE* out) {
778 HeapObject::PrintHeader(out, "JSSet");
779 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
780 PrintF(out, " - table = ");
781 table()->ShortPrint(out);
782 PrintF(out, "\n");
783}
784
785
786void JSMap::JSMapPrint(FILE* out) {
787 HeapObject::PrintHeader(out, "JSMap");
788 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
789 PrintF(out, " - table = ");
790 table()->ShortPrint(out);
791 PrintF(out, "\n");
792}
793
794
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000795void JSWeakMap::JSWeakMapPrint(FILE* out) {
796 HeapObject::PrintHeader(out, "JSWeakMap");
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000797 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000798 PrintF(out, " - table = ");
799 table()->ShortPrint(out);
800 PrintF(out, "\n");
801}
802
803
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +0000804void JSWeakSet::JSWeakSetPrint(FILE* out) {
805 HeapObject::PrintHeader(out, "JSWeakSet");
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000806 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +0000807 PrintF(out, " - table = ");
808 table()->ShortPrint(out);
809 PrintF(out, "\n");
810}
811
812
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000813void JSArrayBuffer::JSArrayBufferPrint(FILE* out) {
814 HeapObject::PrintHeader(out, "JSArrayBuffer");
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000815 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
816 PrintF(out, " - backing_store = %p\n", backing_store());
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000817 PrintF(out, " - byte_length = ");
818 byte_length()->ShortPrint(out);
819 PrintF(out, "\n");
820}
821
822
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000823void JSTypedArray::JSTypedArrayPrint(FILE* out) {
824 HeapObject::PrintHeader(out, "JSTypedArray");
mstarzinger@chromium.org1510d582013-06-28 14:00:48 +0000825 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000826 PrintF(out, " - buffer =");
827 buffer()->ShortPrint(out);
828 PrintF(out, "\n - byte_offset = ");
829 byte_offset()->ShortPrint(out);
830 PrintF(out, "\n - byte_length = ");
831 byte_length()->ShortPrint(out);
ulan@chromium.orgdfe53072013-06-06 14:14:51 +0000832 PrintF(out, "\n - length = ");
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000833 length()->ShortPrint(out);
machenbach@chromium.orge8412be2013-11-08 10:23:52 +0000834 PrintF(out, "\n");
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000835 PrintElements(out);
836}
837
838
mstarzinger@chromium.org1510d582013-06-28 14:00:48 +0000839void JSDataView::JSDataViewPrint(FILE* out) {
840 HeapObject::PrintHeader(out, "JSDataView");
841 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
842 PrintF(out, " - buffer =");
843 buffer()->ShortPrint(out);
844 PrintF(out, "\n - byte_offset = ");
845 byte_offset()->ShortPrint(out);
846 PrintF(out, "\n - byte_length = ");
847 byte_length()->ShortPrint(out);
machenbach@chromium.orge8412be2013-11-08 10:23:52 +0000848 PrintF(out, "\n");
mstarzinger@chromium.org1510d582013-06-28 14:00:48 +0000849}
850
851
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000852void JSFunction::JSFunctionPrint(FILE* out) {
853 HeapObject::PrintHeader(out, "Function");
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000854 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000855 PrintF(out, " - initial_map = ");
856 if (has_initial_map()) {
857 initial_map()->ShortPrint(out);
858 }
859 PrintF(out, "\n - shared_info = ");
860 shared()->ShortPrint(out);
861 PrintF(out, "\n - name = ");
862 shared()->name()->Print(out);
863 PrintF(out, "\n - context = ");
mstarzinger@chromium.org1510d582013-06-28 14:00:48 +0000864 context()->ShortPrint(out);
machenbach@chromium.org37be4082013-11-26 13:50:38 +0000865 if (shared()->bound()) {
866 PrintF(out, "\n - bindings = ");
867 function_bindings()->ShortPrint(out);
868 } else {
869 PrintF(out, "\n - literals = ");
870 literals()->ShortPrint(out);
871 }
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000872 PrintF(out, "\n - code = ");
873 code()->ShortPrint(out);
874 PrintF(out, "\n");
875
876 PrintProperties(out);
877 PrintElements(out);
878
879 PrintF(out, "\n");
880}
881
882
883void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) {
884 HeapObject::PrintHeader(out, "SharedFunctionInfo");
885 PrintF(out, " - name: ");
886 name()->ShortPrint(out);
887 PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties());
888 PrintF(out, "\n - instance class name = ");
889 instance_class_name()->Print(out);
890 PrintF(out, "\n - code = ");
891 code()->ShortPrint(out);
yangguo@chromium.org5a11aaf2012-06-20 11:29:00 +0000892 if (HasSourceCode()) {
893 PrintF(out, "\n - source code = ");
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +0000894 String* source = String::cast(Script::cast(script())->source());
895 int start = start_position();
896 int length = end_position() - start;
897 SmartArrayPointer<char> source_string =
898 source->ToCString(DISALLOW_NULLS,
899 FAST_STRING_TRAVERSAL,
900 start, length, NULL);
901 PrintF(out, "%s", *source_string);
yangguo@chromium.org5a11aaf2012-06-20 11:29:00 +0000902 }
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000903 // Script files are often large, hard to read.
904 // PrintF(out, "\n - script =");
905 // script()->Print(out);
906 PrintF(out, "\n - function token position = %d", function_token_position());
907 PrintF(out, "\n - start position = %d", start_position());
908 PrintF(out, "\n - end position = %d", end_position());
909 PrintF(out, "\n - is expression = %d", is_expression());
910 PrintF(out, "\n - debug info = ");
911 debug_info()->ShortPrint(out);
912 PrintF(out, "\n - length = %d", length());
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +0000913 PrintF(out, "\n - optimized_code_map = ");
914 optimized_code_map()->ShortPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000915 PrintF(out, "\n");
916}
917
918
919void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) {
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +0000920 PrintF(out, "global_proxy ");
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000921 JSObjectPrint(out);
yangguo@chromium.org46839fb2012-08-28 09:06:19 +0000922 PrintF(out, "native context : ");
923 native_context()->ShortPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000924 PrintF(out, "\n");
925}
926
927
928void JSGlobalObject::JSGlobalObjectPrint(FILE* out) {
929 PrintF(out, "global ");
930 JSObjectPrint(out);
yangguo@chromium.org46839fb2012-08-28 09:06:19 +0000931 PrintF(out, "native context : ");
932 native_context()->ShortPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000933 PrintF(out, "\n");
934}
935
936
937void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) {
938 PrintF(out, "builtins ");
939 JSObjectPrint(out);
940}
941
942
danno@chromium.org41728482013-06-12 22:31:22 +0000943void Cell::CellPrint(FILE* out) {
944 HeapObject::PrintHeader(out, "Cell");
945}
946
947
dslomov@chromium.orgb752d402013-06-18 11:54:54 +0000948void PropertyCell::PropertyCellPrint(FILE* out) {
949 HeapObject::PrintHeader(out, "PropertyCell");
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000950}
951
952
953void Code::CodePrint(FILE* out) {
954 HeapObject::PrintHeader(out, "Code");
955#ifdef ENABLE_DISASSEMBLER
956 if (FLAG_use_verbose_printer) {
957 Disassemble(NULL, out);
958 }
959#endif
960}
961
962
ager@chromium.orgea91cc52011-05-23 06:06:11 +0000963void Foreign::ForeignPrint(FILE* out) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000964 PrintF(out, "foreign address : %p", foreign_address());
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000965}
966
967
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +0000968void ExecutableAccessorInfo::ExecutableAccessorInfoPrint(FILE* out) {
969 HeapObject::PrintHeader(out, "ExecutableAccessorInfo");
970 PrintF(out, "\n - name: ");
971 name()->ShortPrint(out);
972 PrintF(out, "\n - flag: ");
973 flag()->ShortPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000974 PrintF(out, "\n - getter: ");
975 getter()->ShortPrint(out);
976 PrintF(out, "\n - setter: ");
977 setter()->ShortPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000978 PrintF(out, "\n - data: ");
979 data()->ShortPrint(out);
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +0000980}
981
982
983void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(FILE* out) {
984 HeapObject::PrintHeader(out, "DeclaredAccessorInfo");
985 PrintF(out, "\n - name: ");
986 name()->ShortPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000987 PrintF(out, "\n - flag: ");
988 flag()->ShortPrint(out);
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +0000989 PrintF(out, "\n - descriptor: ");
990 descriptor()->ShortPrint(out);
991}
992
993
994void DeclaredAccessorDescriptor::DeclaredAccessorDescriptorPrint(FILE* out) {
995 HeapObject::PrintHeader(out, "DeclaredAccessorDescriptor");
996 PrintF(out, "\n - internal field: ");
ulan@chromium.org750145a2013-03-07 15:14:13 +0000997 serialized_data()->ShortPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000998}
999
1000
danno@chromium.org1fd77d52013-06-07 16:01:45 +00001001void Box::BoxPrint(FILE* out) {
1002 HeapObject::PrintHeader(out, "Box");
1003 PrintF(out, "\n - value: ");
1004 value()->ShortPrint(out);
1005}
1006
1007
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001008void AccessorPair::AccessorPairPrint(FILE* out) {
1009 HeapObject::PrintHeader(out, "AccessorPair");
1010 PrintF(out, "\n - getter: ");
1011 getter()->ShortPrint(out);
1012 PrintF(out, "\n - setter: ");
1013 setter()->ShortPrint(out);
jkummerow@chromium.org1e8da742013-08-26 17:13:35 +00001014 PrintF(out, "\n - flag: ");
1015 access_flags()->ShortPrint(out);
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001016}
1017
1018
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +00001019void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) {
1020 HeapObject::PrintHeader(out, "AccessCheckInfo");
1021 PrintF(out, "\n - named_callback: ");
1022 named_callback()->ShortPrint(out);
1023 PrintF(out, "\n - indexed_callback: ");
1024 indexed_callback()->ShortPrint(out);
1025 PrintF(out, "\n - data: ");
1026 data()->ShortPrint(out);
1027}
1028
1029
1030void InterceptorInfo::InterceptorInfoPrint(FILE* out) {
1031 HeapObject::PrintHeader(out, "InterceptorInfo");
1032 PrintF(out, "\n - getter: ");
1033 getter()->ShortPrint(out);
1034 PrintF(out, "\n - setter: ");
1035 setter()->ShortPrint(out);
1036 PrintF(out, "\n - query: ");
1037 query()->ShortPrint(out);
1038 PrintF(out, "\n - deleter: ");
1039 deleter()->ShortPrint(out);
1040 PrintF(out, "\n - enumerator: ");
1041 enumerator()->ShortPrint(out);
1042 PrintF(out, "\n - data: ");
1043 data()->ShortPrint(out);
1044}
1045
1046
1047void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) {
1048 HeapObject::PrintHeader(out, "CallHandlerInfo");
1049 PrintF(out, "\n - callback: ");
1050 callback()->ShortPrint(out);
1051 PrintF(out, "\n - data: ");
1052 data()->ShortPrint(out);
1053 PrintF(out, "\n - call_stub_cache: ");
1054}
1055
1056
1057void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) {
1058 HeapObject::PrintHeader(out, "FunctionTemplateInfo");
1059 PrintF(out, "\n - class name: ");
1060 class_name()->ShortPrint(out);
1061 PrintF(out, "\n - tag: ");
1062 tag()->ShortPrint(out);
1063 PrintF(out, "\n - property_list: ");
1064 property_list()->ShortPrint(out);
1065 PrintF(out, "\n - serial_number: ");
1066 serial_number()->ShortPrint(out);
1067 PrintF(out, "\n - call_code: ");
1068 call_code()->ShortPrint(out);
1069 PrintF(out, "\n - property_accessors: ");
1070 property_accessors()->ShortPrint(out);
1071 PrintF(out, "\n - prototype_template: ");
1072 prototype_template()->ShortPrint(out);
1073 PrintF(out, "\n - parent_template: ");
1074 parent_template()->ShortPrint(out);
1075 PrintF(out, "\n - named_property_handler: ");
1076 named_property_handler()->ShortPrint(out);
1077 PrintF(out, "\n - indexed_property_handler: ");
1078 indexed_property_handler()->ShortPrint(out);
1079 PrintF(out, "\n - instance_template: ");
1080 instance_template()->ShortPrint(out);
1081 PrintF(out, "\n - signature: ");
1082 signature()->ShortPrint(out);
1083 PrintF(out, "\n - access_check_info: ");
1084 access_check_info()->ShortPrint(out);
1085 PrintF(out, "\n - hidden_prototype: %s",
1086 hidden_prototype() ? "true" : "false");
1087 PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false");
1088 PrintF(out, "\n - need_access_check: %s",
1089 needs_access_check() ? "true" : "false");
1090}
1091
1092
1093void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) {
1094 HeapObject::PrintHeader(out, "ObjectTemplateInfo");
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +00001095 PrintF(out, " - tag: ");
1096 tag()->ShortPrint(out);
1097 PrintF(out, "\n - property_list: ");
1098 property_list()->ShortPrint(out);
jkummerow@chromium.org3d00d0a2013-09-04 13:57:32 +00001099 PrintF(out, "\n - property_accessors: ");
1100 property_accessors()->ShortPrint(out);
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +00001101 PrintF(out, "\n - constructor: ");
1102 constructor()->ShortPrint(out);
1103 PrintF(out, "\n - internal_field_count: ");
1104 internal_field_count()->ShortPrint(out);
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +00001105 PrintF(out, "\n");
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +00001106}
1107
1108
1109void SignatureInfo::SignatureInfoPrint(FILE* out) {
1110 HeapObject::PrintHeader(out, "SignatureInfo");
1111 PrintF(out, "\n - receiver: ");
1112 receiver()->ShortPrint(out);
1113 PrintF(out, "\n - args: ");
1114 args()->ShortPrint(out);
1115}
1116
1117
1118void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) {
1119 HeapObject::PrintHeader(out, "TypeSwitchInfo");
1120 PrintF(out, "\n - types: ");
1121 types()->ShortPrint(out);
1122}
1123
1124
danno@chromium.orgbee51992013-07-10 14:57:15 +00001125void AllocationSite::AllocationSitePrint(FILE* out) {
1126 HeapObject::PrintHeader(out, "AllocationSite");
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +00001127 PrintF(out, " - weak_next: ");
1128 weak_next()->ShortPrint(out);
machenbach@chromium.org528ce022013-09-23 14:09:36 +00001129 PrintF(out, "\n - dependent code: ");
1130 dependent_code()->ShortPrint(out);
machenbach@chromium.org3d079fe2013-09-25 08:19:55 +00001131 PrintF(out, "\n - nested site: ");
1132 nested_site()->ShortPrint(out);
machenbach@chromium.org90dca012013-11-22 10:04:21 +00001133 PrintF(out, "\n - memento found count: ");
1134 memento_found_count()->ShortPrint(out);
1135 PrintF(out, "\n - memento create count: ");
1136 memento_create_count()->ShortPrint(out);
1137 PrintF(out, "\n - pretenure decision: ");
1138 pretenure_decision()->ShortPrint(out);
machenbach@chromium.org528ce022013-09-23 14:09:36 +00001139 PrintF(out, "\n - transition_info: ");
machenbach@chromium.orgb5be0a92013-11-15 10:32:41 +00001140 if (transition_info()->IsSmi()) {
1141 ElementsKind kind = GetElementsKind();
1142 PrintF(out, "Array allocation with ElementsKind ");
1143 PrintElementsKind(out, kind);
1144 PrintF(out, "\n");
1145 return;
danno@chromium.orgbee51992013-07-10 14:57:15 +00001146 } else if (transition_info()->IsJSArray()) {
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00001147 PrintF(out, "Array literal ");
danno@chromium.orgbee51992013-07-10 14:57:15 +00001148 transition_info()->ShortPrint(out);
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00001149 PrintF(out, "\n");
1150 return;
1151 }
1152
danno@chromium.orgbee51992013-07-10 14:57:15 +00001153 PrintF(out, "unknown transition_info");
1154 transition_info()->ShortPrint(out);
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00001155 PrintF(out, "\n");
1156}
1157
1158
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +00001159void AllocationMemento::AllocationMementoPrint(FILE* out) {
1160 HeapObject::PrintHeader(out, "AllocationMemento");
danno@chromium.orgbee51992013-07-10 14:57:15 +00001161 PrintF(out, " - allocation site: ");
1162 if (IsValid()) {
1163 GetAllocationSite()->Print();
1164 } else {
1165 PrintF(out, "<invalid>\n");
1166 }
1167}
1168
1169
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +00001170void Script::ScriptPrint(FILE* out) {
1171 HeapObject::PrintHeader(out, "Script");
1172 PrintF(out, "\n - source: ");
1173 source()->ShortPrint(out);
1174 PrintF(out, "\n - name: ");
1175 name()->ShortPrint(out);
1176 PrintF(out, "\n - line_offset: ");
1177 line_offset()->ShortPrint(out);
1178 PrintF(out, "\n - column_offset: ");
1179 column_offset()->ShortPrint(out);
1180 PrintF(out, "\n - type: ");
1181 type()->ShortPrint(out);
1182 PrintF(out, "\n - id: ");
1183 id()->ShortPrint(out);
1184 PrintF(out, "\n - data: ");
1185 data()->ShortPrint(out);
1186 PrintF(out, "\n - context data: ");
1187 context_data()->ShortPrint(out);
1188 PrintF(out, "\n - wrapper: ");
1189 wrapper()->ShortPrint(out);
danno@chromium.orgd3c42102013-08-01 16:58:23 +00001190 PrintF(out, "\n - compilation type: %d", compilation_type());
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +00001191 PrintF(out, "\n - line ends: ");
1192 line_ends()->ShortPrint(out);
1193 PrintF(out, "\n - eval from shared: ");
1194 eval_from_shared()->ShortPrint(out);
1195 PrintF(out, "\n - eval from instructions offset: ");
1196 eval_from_instructions_offset()->ShortPrint(out);
1197 PrintF(out, "\n");
1198}
1199
1200
1201#ifdef ENABLE_DEBUGGER_SUPPORT
1202void DebugInfo::DebugInfoPrint(FILE* out) {
1203 HeapObject::PrintHeader(out, "DebugInfo");
1204 PrintF(out, "\n - shared: ");
1205 shared()->ShortPrint(out);
1206 PrintF(out, "\n - original_code: ");
1207 original_code()->ShortPrint(out);
1208 PrintF(out, "\n - code: ");
1209 code()->ShortPrint(out);
1210 PrintF(out, "\n - break_points: ");
1211 break_points()->Print(out);
1212}
1213
1214
1215void BreakPointInfo::BreakPointInfoPrint(FILE* out) {
1216 HeapObject::PrintHeader(out, "BreakPointInfo");
1217 PrintF(out, "\n - code_position: %d", code_position()->value());
1218 PrintF(out, "\n - source_position: %d", source_position()->value());
1219 PrintF(out, "\n - statement_position: %d", statement_position()->value());
1220 PrintF(out, "\n - break_point_objects: ");
1221 break_point_objects()->ShortPrint(out);
1222}
1223#endif // ENABLE_DEBUGGER_SUPPORT
1224
1225
1226void DescriptorArray::PrintDescriptors(FILE* out) {
1227 PrintF(out, "Descriptor array %d\n", number_of_descriptors());
1228 for (int i = 0; i < number_of_descriptors(); i++) {
1229 PrintF(out, " %d: ", i);
1230 Descriptor desc;
1231 Get(i, &desc);
1232 desc.Print(out);
1233 }
1234 PrintF(out, "\n");
1235}
1236
1237
yangguo@chromium.org99aa4902012-07-06 16:21:55 +00001238void TransitionArray::PrintTransitions(FILE* out) {
1239 PrintF(out, "Transition array %d\n", number_of_transitions());
1240 for (int i = 0; i < number_of_transitions(); i++) {
1241 PrintF(out, " %d: ", i);
ulan@chromium.org750145a2013-03-07 15:14:13 +00001242 GetKey(i)->NamePrint(out);
yangguo@chromium.org99aa4902012-07-06 16:21:55 +00001243 PrintF(out, ": ");
1244 switch (GetTargetDetails(i).type()) {
1245 case FIELD: {
1246 PrintF(out, " (transition to field)\n");
1247 break;
1248 }
jkummerow@chromium.orgfb732b12013-07-26 10:27:09 +00001249 case CONSTANT:
1250 PrintF(out, " (transition to constant)\n");
yangguo@chromium.org99aa4902012-07-06 16:21:55 +00001251 break;
1252 case CALLBACKS:
1253 PrintF(out, " (transition to callback)\n");
1254 break;
1255 // Values below are never in the target descriptor array.
1256 case NORMAL:
1257 case HANDLER:
1258 case INTERCEPTOR:
1259 case TRANSITION:
1260 case NONEXISTENT:
1261 UNREACHABLE();
1262 break;
1263 }
1264 }
1265 PrintF(out, "\n");
1266}
1267
1268
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +00001269#endif // OBJECT_PRINT
1270
1271
1272} } // namespace v8::internal