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

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

Issue 101413006: Implement in-heap backing store for typed arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: GC fixes Created 6 years, 11 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/objects-inl.h ('k') | src/objects-visiting.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 break; 129 break;
130 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: 130 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
131 ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint(out); 131 ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint(out);
132 break; 132 break;
133 case EXTERNAL_FLOAT_ARRAY_TYPE: 133 case EXTERNAL_FLOAT_ARRAY_TYPE:
134 ExternalFloatArray::cast(this)->ExternalFloatArrayPrint(out); 134 ExternalFloatArray::cast(this)->ExternalFloatArrayPrint(out);
135 break; 135 break;
136 case EXTERNAL_DOUBLE_ARRAY_TYPE: 136 case EXTERNAL_DOUBLE_ARRAY_TYPE:
137 ExternalDoubleArray::cast(this)->ExternalDoubleArrayPrint(out); 137 ExternalDoubleArray::cast(this)->ExternalDoubleArrayPrint(out);
138 break; 138 break;
139 #define PRINT_FIXED_TYPED_ARRAY(Type) \
140 case Fixed##Type##Array::kInstanceType: \
141 Fixed##Type##Array::cast(this)->FixedTypedArrayPrint(out); \
142 break;
143
144 PRINT_FIXED_TYPED_ARRAY(Uint8)
145 PRINT_FIXED_TYPED_ARRAY(Int8)
146 PRINT_FIXED_TYPED_ARRAY(Uint16)
147 PRINT_FIXED_TYPED_ARRAY(Int16)
148 PRINT_FIXED_TYPED_ARRAY(Uint32)
149 PRINT_FIXED_TYPED_ARRAY(Int32)
150 PRINT_FIXED_TYPED_ARRAY(Float32)
151 PRINT_FIXED_TYPED_ARRAY(Float64)
152 PRINT_FIXED_TYPED_ARRAY(Uint8Clamped)
153
154 #undef PPINT_FIXED_TYPED_ARRAY
155
156
139 case FILLER_TYPE: 157 case FILLER_TYPE:
140 PrintF(out, "filler"); 158 PrintF(out, "filler");
141 break; 159 break;
142 case JS_OBJECT_TYPE: // fall through 160 case JS_OBJECT_TYPE: // fall through
143 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: 161 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
144 case JS_ARRAY_TYPE: 162 case JS_ARRAY_TYPE:
145 case JS_GENERATOR_OBJECT_TYPE: 163 case JS_GENERATOR_OBJECT_TYPE:
146 case JS_REGEXP_TYPE: 164 case JS_REGEXP_TYPE:
147 JSObject::cast(this)->JSObjectPrint(out); 165 JSObject::cast(this)->JSObjectPrint(out);
148 break; 166 break;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 296
279 void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) { 297 void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) {
280 PrintF(out, "external float array"); 298 PrintF(out, "external float array");
281 } 299 }
282 300
283 301
284 void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) { 302 void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) {
285 PrintF(out, "external double array"); 303 PrintF(out, "external double array");
286 } 304 }
287 305
306 template <class Traits>
307 void FixedTypedArray<Traits>::FixedTypedArrayPrint(FILE* out) {
308 PrintF(out, "fixed %s", Traits::Designator());
309 }
310
288 311
289 void JSObject::PrintProperties(FILE* out) { 312 void JSObject::PrintProperties(FILE* out) {
290 if (HasFastProperties()) { 313 if (HasFastProperties()) {
291 DescriptorArray* descs = map()->instance_descriptors(); 314 DescriptorArray* descs = map()->instance_descriptors();
292 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { 315 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
293 PrintF(out, " "); 316 PrintF(out, " ");
294 descs->GetKey(i)->NamePrint(out); 317 descs->GetKey(i)->NamePrint(out);
295 PrintF(out, ": "); 318 PrintF(out, ": ");
296 switch (descs->GetType(i)) { 319 switch (descs->GetType(i)) {
297 case FIELD: { 320 case FIELD: {
(...skipping 19 matching lines...) Expand all
317 UNREACHABLE(); 340 UNREACHABLE();
318 break; 341 break;
319 } 342 }
320 } 343 }
321 } else { 344 } else {
322 property_dictionary()->Print(out); 345 property_dictionary()->Print(out);
323 } 346 }
324 } 347 }
325 348
326 349
350 template<class T>
351 static void DoPrintElements(FILE *out, Object* object) {
352 T* p = T::cast(object);
353 for (int i = 0; i < p->length(); i++) {
354 PrintF(out, " %d: %d\n", i, p->get_scalar(i));
355 }
356 }
357
358
359 template<class T>
360 static void DoPrintDoubleElements(FILE* out, Object* object) {
361 T* p = T::cast(object);
362 for (int i = 0; i < p->length(); i++) {
363 PrintF(out, " %d: %f\n", i, p->get_scalar(i));
364 }
365 }
366
367
327 void JSObject::PrintElements(FILE* out) { 368 void JSObject::PrintElements(FILE* out) {
328 // Don't call GetElementsKind, its validation code can cause the printer to 369 // Don't call GetElementsKind, its validation code can cause the printer to
329 // fail when debugging. 370 // fail when debugging.
330 switch (map()->elements_kind()) { 371 switch (map()->elements_kind()) {
331 case FAST_HOLEY_SMI_ELEMENTS: 372 case FAST_HOLEY_SMI_ELEMENTS:
332 case FAST_SMI_ELEMENTS: 373 case FAST_SMI_ELEMENTS:
333 case FAST_HOLEY_ELEMENTS: 374 case FAST_HOLEY_ELEMENTS:
334 case FAST_ELEMENTS: { 375 case FAST_ELEMENTS: {
335 // Print in array notation for non-sparse arrays. 376 // Print in array notation for non-sparse arrays.
336 FixedArray* p = FixedArray::cast(elements()); 377 FixedArray* p = FixedArray::cast(elements());
(...skipping 13 matching lines...) Expand all
350 if (p->is_the_hole(i)) { 391 if (p->is_the_hole(i)) {
351 PrintF(out, " %d: <the hole>", i); 392 PrintF(out, " %d: <the hole>", i);
352 } else { 393 } else {
353 PrintF(out, " %d: %g", i, p->get_scalar(i)); 394 PrintF(out, " %d: %g", i, p->get_scalar(i));
354 } 395 }
355 PrintF(out, "\n"); 396 PrintF(out, "\n");
356 } 397 }
357 } 398 }
358 break; 399 break;
359 } 400 }
360 case EXTERNAL_PIXEL_ELEMENTS: { 401
361 ExternalPixelArray* p = ExternalPixelArray::cast(elements()); 402
362 for (int i = 0; i < p->length(); i++) { 403 #define PRINT_ELEMENTS(Kind, Type) \
363 PrintF(out, " %d: %d\n", i, p->get_scalar(i)); 404 case Kind: { \
364 } 405 DoPrintElements<Type>(out, elements()); \
365 break; 406 break; \
366 } 407 }
367 case EXTERNAL_BYTE_ELEMENTS: { 408
368 ExternalByteArray* p = ExternalByteArray::cast(elements()); 409 #define PRINT_DOUBLE_ELEMENTS(Kind, Type) \
369 for (int i = 0; i < p->length(); i++) { 410 case Kind: { \
370 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); 411 DoPrintDoubleElements<Type>(out, elements()); \
371 } 412 break; \
372 break;
373 } 413 }
374 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { 414
375 ExternalUnsignedByteArray* p = 415 PRINT_ELEMENTS(EXTERNAL_PIXEL_ELEMENTS, ExternalPixelArray)
376 ExternalUnsignedByteArray::cast(elements()); 416 PRINT_ELEMENTS(EXTERNAL_BYTE_ELEMENTS, ExternalByteArray)
377 for (int i = 0; i < p->length(); i++) { 417 PRINT_ELEMENTS(EXTERNAL_UNSIGNED_BYTE_ELEMENTS,
378 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); 418 ExternalUnsignedByteArray)
379 } 419 PRINT_ELEMENTS(EXTERNAL_SHORT_ELEMENTS, ExternalShortArray)
380 break; 420 PRINT_ELEMENTS(EXTERNAL_UNSIGNED_SHORT_ELEMENTS,
381 } 421 ExternalUnsignedShortArray)
382 case EXTERNAL_SHORT_ELEMENTS: { 422 PRINT_ELEMENTS(EXTERNAL_INT_ELEMENTS, ExternalIntArray)
383 ExternalShortArray* p = ExternalShortArray::cast(elements()); 423 PRINT_ELEMENTS(EXTERNAL_UNSIGNED_INT_ELEMENTS,
384 for (int i = 0; i < p->length(); i++) { 424 ExternalUnsignedIntArray)
385 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); 425 PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT_ELEMENTS, ExternalFloatArray)
386 } 426 PRINT_DOUBLE_ELEMENTS(EXTERNAL_DOUBLE_ELEMENTS, ExternalDoubleArray)
387 break; 427
388 } 428
389 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { 429 PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array)
390 ExternalUnsignedShortArray* p = 430 PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray)
391 ExternalUnsignedShortArray::cast(elements()); 431 PRINT_ELEMENTS(INT8_ELEMENTS, FixedInt8Array)
392 for (int i = 0; i < p->length(); i++) { 432 PRINT_ELEMENTS(UINT16_ELEMENTS, FixedUint16Array)
393 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); 433 PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array)
394 } 434 PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array)
395 break; 435 PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array)
396 } 436 PRINT_DOUBLE_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array)
397 case EXTERNAL_INT_ELEMENTS: { 437 PRINT_DOUBLE_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array)
398 ExternalIntArray* p = ExternalIntArray::cast(elements()); 438
399 for (int i = 0; i < p->length(); i++) { 439 #undef PRINT_DOUBLE_ELEMENTS
400 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); 440 #undef PRINT_ELEMENTS
401 } 441
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++) {
408 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i)));
409 }
410 break;
411 }
412 case EXTERNAL_FLOAT_ELEMENTS: {
413 ExternalFloatArray* p = ExternalFloatArray::cast(elements());
414 for (int i = 0; i < p->length(); i++) {
415 PrintF(out, " %d: %f\n", i, p->get_scalar(i));
416 }
417 break;
418 }
419 case EXTERNAL_DOUBLE_ELEMENTS: {
420 ExternalDoubleArray* p = ExternalDoubleArray::cast(elements());
421 for (int i = 0; i < p->length(); i++) {
422 PrintF(out, " %d: %f\n", i, p->get_scalar(i));
423 }
424 break;
425 }
426 case DICTIONARY_ELEMENTS: 442 case DICTIONARY_ELEMENTS:
427 elements()->Print(out); 443 elements()->Print(out);
428 break; 444 break;
429 case NON_STRICT_ARGUMENTS_ELEMENTS: { 445 case NON_STRICT_ARGUMENTS_ELEMENTS: {
430 FixedArray* p = FixedArray::cast(elements()); 446 FixedArray* p = FixedArray::cast(elements());
431 PrintF(out, " parameter map:"); 447 PrintF(out, " parameter map:");
432 for (int i = 2; i < p->length(); i++) { 448 for (int i = 2; i < p->length(); i++) {
433 PrintF(out, " %d:", i - 2); 449 PrintF(out, " %d:", i - 2);
434 p->get(i)->ShortPrint(out); 450 p->get(i)->ShortPrint(out);
435 } 451 }
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 } 1284 }
1269 } 1285 }
1270 PrintF(out, "\n"); 1286 PrintF(out, "\n");
1271 } 1287 }
1272 1288
1273 1289
1274 #endif // OBJECT_PRINT 1290 #endif // OBJECT_PRINT
1275 1291
1276 1292
1277 } } // namespace v8::internal 1293 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/objects-visiting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698