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

Side by Side Diff: src/objects.h

Issue 293023: Added infrastructure for optimizing new CanvasArray types in WebGL... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 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/messages.js ('k') | src/objects.cc » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // - JSRegExp 49 // - JSRegExp
50 // - JSFunction 50 // - JSFunction
51 // - GlobalObject 51 // - GlobalObject
52 // - JSGlobalObject 52 // - JSGlobalObject
53 // - JSBuiltinsObject 53 // - JSBuiltinsObject
54 // - JSGlobalProxy 54 // - JSGlobalProxy
55 // - JSValue 55 // - JSValue
56 // - Array 56 // - Array
57 // - ByteArray 57 // - ByteArray
58 // - PixelArray 58 // - PixelArray
59 // - ExternalArray
60 // - ExternalByteArray
61 // - ExternalUnsignedByteArray
62 // - ExternalShortArray
63 // - ExternalUnsignedShortArray
64 // - ExternalIntArray
65 // - ExternalUnsignedIntArray
66 // - ExternalFloatArray
59 // - FixedArray 67 // - FixedArray
60 // - DescriptorArray 68 // - DescriptorArray
61 // - HashTable 69 // - HashTable
62 // - Dictionary 70 // - Dictionary
63 // - SymbolTable 71 // - SymbolTable
64 // - CompilationCacheTable 72 // - CompilationCacheTable
65 // - MapCache 73 // - MapCache
66 // - Context 74 // - Context
67 // - GlobalContext 75 // - GlobalContext
68 // - String 76 // - String
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 \ 275 \
268 V(MAP_TYPE) \ 276 V(MAP_TYPE) \
269 V(HEAP_NUMBER_TYPE) \ 277 V(HEAP_NUMBER_TYPE) \
270 V(FIXED_ARRAY_TYPE) \ 278 V(FIXED_ARRAY_TYPE) \
271 V(CODE_TYPE) \ 279 V(CODE_TYPE) \
272 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ 280 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \
273 V(ODDBALL_TYPE) \ 281 V(ODDBALL_TYPE) \
274 V(PROXY_TYPE) \ 282 V(PROXY_TYPE) \
275 V(BYTE_ARRAY_TYPE) \ 283 V(BYTE_ARRAY_TYPE) \
276 V(PIXEL_ARRAY_TYPE) \ 284 V(PIXEL_ARRAY_TYPE) \
285 /* Note: the order of these external array */ \
286 /* types is relied upon in */ \
287 /* Object::IsExternalArray(). */ \
288 V(EXTERNAL_BYTE_ARRAY_TYPE) \
289 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \
290 V(EXTERNAL_SHORT_ARRAY_TYPE) \
291 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \
292 V(EXTERNAL_INT_ARRAY_TYPE) \
293 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \
294 V(EXTERNAL_FLOAT_ARRAY_TYPE) \
277 V(FILLER_TYPE) \ 295 V(FILLER_TYPE) \
278 \ 296 \
279 V(ACCESSOR_INFO_TYPE) \ 297 V(ACCESSOR_INFO_TYPE) \
280 V(ACCESS_CHECK_INFO_TYPE) \ 298 V(ACCESS_CHECK_INFO_TYPE) \
281 V(INTERCEPTOR_INFO_TYPE) \ 299 V(INTERCEPTOR_INFO_TYPE) \
282 V(SHARED_FUNCTION_INFO_TYPE) \ 300 V(SHARED_FUNCTION_INFO_TYPE) \
283 V(CALL_HANDLER_INFO_TYPE) \ 301 V(CALL_HANDLER_INFO_TYPE) \
284 V(FUNCTION_TEMPLATE_INFO_TYPE) \ 302 V(FUNCTION_TEMPLATE_INFO_TYPE) \
285 V(OBJECT_TEMPLATE_INFO_TYPE) \ 303 V(OBJECT_TEMPLATE_INFO_TYPE) \
286 V(SIGNATURE_INFO_TYPE) \ 304 V(SIGNATURE_INFO_TYPE) \
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 684
667 MAP_TYPE = kNotStringTag, 685 MAP_TYPE = kNotStringTag,
668 HEAP_NUMBER_TYPE, 686 HEAP_NUMBER_TYPE,
669 FIXED_ARRAY_TYPE, 687 FIXED_ARRAY_TYPE,
670 CODE_TYPE, 688 CODE_TYPE,
671 ODDBALL_TYPE, 689 ODDBALL_TYPE,
672 JS_GLOBAL_PROPERTY_CELL_TYPE, 690 JS_GLOBAL_PROPERTY_CELL_TYPE,
673 PROXY_TYPE, 691 PROXY_TYPE,
674 BYTE_ARRAY_TYPE, 692 BYTE_ARRAY_TYPE,
675 PIXEL_ARRAY_TYPE, 693 PIXEL_ARRAY_TYPE,
694 EXTERNAL_BYTE_ARRAY_TYPE,
695 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE,
696 EXTERNAL_SHORT_ARRAY_TYPE,
697 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE,
698 EXTERNAL_INT_ARRAY_TYPE,
699 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE,
700 EXTERNAL_FLOAT_ARRAY_TYPE,
676 FILLER_TYPE, 701 FILLER_TYPE,
677 SMI_TYPE, 702 SMI_TYPE,
678 703
679 ACCESSOR_INFO_TYPE, 704 ACCESSOR_INFO_TYPE,
680 ACCESS_CHECK_INFO_TYPE, 705 ACCESS_CHECK_INFO_TYPE,
681 INTERCEPTOR_INFO_TYPE, 706 INTERCEPTOR_INFO_TYPE,
682 SHARED_FUNCTION_INFO_TYPE, 707 SHARED_FUNCTION_INFO_TYPE,
683 CALL_HANDLER_INFO_TYPE, 708 CALL_HANDLER_INFO_TYPE,
684 FUNCTION_TEMPLATE_INFO_TYPE, 709 FUNCTION_TEMPLATE_INFO_TYPE,
685 OBJECT_TEMPLATE_INFO_TYPE, 710 OBJECT_TEMPLATE_INFO_TYPE,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 inline bool IsExternalTwoByteString(); 798 inline bool IsExternalTwoByteString();
774 inline bool IsExternalAsciiString(); 799 inline bool IsExternalAsciiString();
775 inline bool IsSeqTwoByteString(); 800 inline bool IsSeqTwoByteString();
776 inline bool IsSeqAsciiString(); 801 inline bool IsSeqAsciiString();
777 #endif // DEBUG 802 #endif // DEBUG
778 inline bool IsConsString(); 803 inline bool IsConsString();
779 804
780 inline bool IsNumber(); 805 inline bool IsNumber();
781 inline bool IsByteArray(); 806 inline bool IsByteArray();
782 inline bool IsPixelArray(); 807 inline bool IsPixelArray();
808 inline bool IsExternalArray();
809 inline bool IsExternalByteArray();
810 inline bool IsExternalUnsignedByteArray();
811 inline bool IsExternalShortArray();
812 inline bool IsExternalUnsignedShortArray();
813 inline bool IsExternalIntArray();
814 inline bool IsExternalUnsignedIntArray();
815 inline bool IsExternalFloatArray();
783 inline bool IsFailure(); 816 inline bool IsFailure();
784 inline bool IsRetryAfterGC(); 817 inline bool IsRetryAfterGC();
785 inline bool IsOutOfMemoryFailure(); 818 inline bool IsOutOfMemoryFailure();
786 inline bool IsException(); 819 inline bool IsException();
787 inline bool IsJSObject(); 820 inline bool IsJSObject();
788 inline bool IsJSContextExtensionObject(); 821 inline bool IsJSContextExtensionObject();
789 inline bool IsMap(); 822 inline bool IsMap();
790 inline bool IsFixedArray(); 823 inline bool IsFixedArray();
791 inline bool IsDescriptorArray(); 824 inline bool IsDescriptorArray();
792 inline bool IsContext(); 825 inline bool IsContext();
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 // The JSObject describes real heap allocated JavaScript objects with 1349 // The JSObject describes real heap allocated JavaScript objects with
1317 // properties. 1350 // properties.
1318 // Note that the map of JSObject changes during execution to enable inline 1351 // Note that the map of JSObject changes during execution to enable inline
1319 // caching. 1352 // caching.
1320 class JSObject: public HeapObject { 1353 class JSObject: public HeapObject {
1321 public: 1354 public:
1322 enum DeleteMode { NORMAL_DELETION, FORCE_DELETION }; 1355 enum DeleteMode { NORMAL_DELETION, FORCE_DELETION };
1323 enum ElementsKind { 1356 enum ElementsKind {
1324 FAST_ELEMENTS, 1357 FAST_ELEMENTS,
1325 DICTIONARY_ELEMENTS, 1358 DICTIONARY_ELEMENTS,
1326 PIXEL_ELEMENTS 1359 PIXEL_ELEMENTS,
1360 EXTERNAL_BYTE_ELEMENTS,
1361 EXTERNAL_UNSIGNED_BYTE_ELEMENTS,
1362 EXTERNAL_SHORT_ELEMENTS,
1363 EXTERNAL_UNSIGNED_SHORT_ELEMENTS,
1364 EXTERNAL_INT_ELEMENTS,
1365 EXTERNAL_UNSIGNED_INT_ELEMENTS,
1366 EXTERNAL_FLOAT_ELEMENTS
1327 }; 1367 };
1328 1368
1329 // [properties]: Backing storage for properties. 1369 // [properties]: Backing storage for properties.
1330 // properties is a FixedArray in the fast case, and a Dictionary in the 1370 // properties is a FixedArray in the fast case, and a Dictionary in the
1331 // slow case. 1371 // slow case.
1332 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. 1372 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties.
1333 inline void initialize_properties(); 1373 inline void initialize_properties();
1334 inline bool HasFastProperties(); 1374 inline bool HasFastProperties();
1335 inline StringDictionary* property_dictionary(); // Gets slow properties. 1375 inline StringDictionary* property_dictionary(); // Gets slow properties.
1336 1376
1337 // [elements]: The elements (properties with names that are integers). 1377 // [elements]: The elements (properties with names that are integers).
1338 // elements is a FixedArray in the fast case, and a Dictionary in the slow 1378 // elements is a FixedArray in the fast case, and a Dictionary in the slow
1339 // case or a PixelArray in a special case. 1379 // case or a PixelArray in a special case.
1340 DECL_ACCESSORS(elements, Array) // Get and set fast elements. 1380 DECL_ACCESSORS(elements, Array) // Get and set fast elements.
1341 inline void initialize_elements(); 1381 inline void initialize_elements();
1342 inline ElementsKind GetElementsKind(); 1382 inline ElementsKind GetElementsKind();
1343 inline bool HasFastElements(); 1383 inline bool HasFastElements();
1344 inline bool HasDictionaryElements(); 1384 inline bool HasDictionaryElements();
1345 inline bool HasPixelElements(); 1385 inline bool HasPixelElements();
1386 inline bool HasExternalArrayElements();
1387 inline bool HasExternalByteElements();
1388 inline bool HasExternalUnsignedByteElements();
1389 inline bool HasExternalShortElements();
1390 inline bool HasExternalUnsignedShortElements();
1391 inline bool HasExternalIntElements();
1392 inline bool HasExternalUnsignedIntElements();
1393 inline bool HasExternalFloatElements();
1346 inline NumberDictionary* element_dictionary(); // Gets slow elements. 1394 inline NumberDictionary* element_dictionary(); // Gets slow elements.
1347 1395
1348 // Collects elements starting at index 0. 1396 // Collects elements starting at index 0.
1349 // Undefined values are placed after non-undefined values. 1397 // Undefined values are placed after non-undefined values.
1350 // Returns the number of non-undefined values. 1398 // Returns the number of non-undefined values.
1351 Object* PrepareElementsForSort(uint32_t limit); 1399 Object* PrepareElementsForSort(uint32_t limit);
1352 // As PrepareElementsForSort, but only on objects where elements is 1400 // As PrepareElementsForSort, but only on objects where elements is
1353 // a dictionary, and it will stay a dictionary. 1401 // a dictionary, and it will stay a dictionary.
1354 Object* PrepareSlowElementsForSort(uint32_t limit); 1402 Object* PrepareSlowElementsForSort(uint32_t limit);
1355 1403
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 // PixelArray headers are not quadword aligned. 2548 // PixelArray headers are not quadword aligned.
2501 static const int kExternalPointerOffset = Array::kAlignedSize; 2549 static const int kExternalPointerOffset = Array::kAlignedSize;
2502 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; 2550 static const int kHeaderSize = kExternalPointerOffset + kPointerSize;
2503 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize); 2551 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize);
2504 2552
2505 private: 2553 private:
2506 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); 2554 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray);
2507 }; 2555 };
2508 2556
2509 2557
2558 // An ExternalArray represents a fixed-size array of primitive values
2559 // which live outside the JavaScript heap. Its subclasses are used to
2560 // implement the CanvasArray types being defined in the WebGL
2561 // specification. As of this writing the first public draft is not yet
2562 // available, but Khronos members can access the draft at:
2563 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html
2564 //
2565 // The semantics of these arrays differ from CanvasPixelArray.
2566 // Out-of-range values passed to the setter are converted via a C
2567 // cast, not clamping. Out-of-range indices cause exceptions to be
2568 // raised rather than being silently ignored.
2569 class ExternalArray: public Array {
2570 public:
2571 // [external_pointer]: The pointer to the external memory area backing this
2572 // external array.
2573 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store.
2574
2575 // Casting.
2576 static inline ExternalArray* cast(Object* obj);
2577
2578 // Maximal acceptable length for an external array.
2579 static const int kMaxLength = 0x3fffffff;
2580
2581 // ExternalArray headers are not quadword aligned.
2582 static const int kExternalPointerOffset = Array::kAlignedSize;
2583 static const int kHeaderSize = kExternalPointerOffset + kPointerSize;
2584 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize);
2585
2586 private:
2587 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray);
2588 };
2589
2590
2591 class ExternalByteArray: public ExternalArray {
2592 public:
2593 // Setter and getter.
2594 inline int8_t get(int index);
2595 inline void set(int index, int8_t value);
2596
2597 // This accessor applies the correct conversion from Smi, HeapNumber
2598 // and undefined.
2599 Object* SetValue(uint32_t index, Object* value);
2600
2601 // Casting.
2602 static inline ExternalByteArray* cast(Object* obj);
2603
2604 #ifdef DEBUG
2605 void ExternalByteArrayPrint();
2606 void ExternalByteArrayVerify();
2607 #endif // DEBUG
2608
2609 private:
2610 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalByteArray);
2611 };
2612
2613
2614 class ExternalUnsignedByteArray: public ExternalArray {
2615 public:
2616 // Setter and getter.
2617 inline uint8_t get(int index);
2618 inline void set(int index, uint8_t value);
2619
2620 // This accessor applies the correct conversion from Smi, HeapNumber
2621 // and undefined.
2622 Object* SetValue(uint32_t index, Object* value);
2623
2624 // Casting.
2625 static inline ExternalUnsignedByteArray* cast(Object* obj);
2626
2627 #ifdef DEBUG
2628 void ExternalUnsignedByteArrayPrint();
2629 void ExternalUnsignedByteArrayVerify();
2630 #endif // DEBUG
2631
2632 private:
2633 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedByteArray);
2634 };
2635
2636
2637 class ExternalShortArray: public ExternalArray {
2638 public:
2639 // Setter and getter.
2640 inline int16_t get(int index);
2641 inline void set(int index, int16_t value);
2642
2643 // This accessor applies the correct conversion from Smi, HeapNumber
2644 // and undefined.
2645 Object* SetValue(uint32_t index, Object* value);
2646
2647 // Casting.
2648 static inline ExternalShortArray* cast(Object* obj);
2649
2650 #ifdef DEBUG
2651 void ExternalShortArrayPrint();
2652 void ExternalShortArrayVerify();
2653 #endif // DEBUG
2654
2655 private:
2656 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalShortArray);
2657 };
2658
2659
2660 class ExternalUnsignedShortArray: public ExternalArray {
2661 public:
2662 // Setter and getter.
2663 inline uint16_t get(int index);
2664 inline void set(int index, uint16_t value);
2665
2666 // This accessor applies the correct conversion from Smi, HeapNumber
2667 // and undefined.
2668 Object* SetValue(uint32_t index, Object* value);
2669
2670 // Casting.
2671 static inline ExternalUnsignedShortArray* cast(Object* obj);
2672
2673 #ifdef DEBUG
2674 void ExternalUnsignedShortArrayPrint();
2675 void ExternalUnsignedShortArrayVerify();
2676 #endif // DEBUG
2677
2678 private:
2679 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedShortArray);
2680 };
2681
2682
2683 class ExternalIntArray: public ExternalArray {
2684 public:
2685 // Setter and getter.
2686 inline int32_t get(int index);
2687 inline void set(int index, int32_t value);
2688
2689 // This accessor applies the correct conversion from Smi, HeapNumber
2690 // and undefined.
2691 Object* SetValue(uint32_t index, Object* value);
2692
2693 // Casting.
2694 static inline ExternalIntArray* cast(Object* obj);
2695
2696 #ifdef DEBUG
2697 void ExternalIntArrayPrint();
2698 void ExternalIntArrayVerify();
2699 #endif // DEBUG
2700
2701 private:
2702 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalIntArray);
2703 };
2704
2705
2706 class ExternalUnsignedIntArray: public ExternalArray {
2707 public:
2708 // Setter and getter.
2709 inline uint32_t get(int index);
2710 inline void set(int index, uint32_t value);
2711
2712 // This accessor applies the correct conversion from Smi, HeapNumber
2713 // and undefined.
2714 Object* SetValue(uint32_t index, Object* value);
2715
2716 // Casting.
2717 static inline ExternalUnsignedIntArray* cast(Object* obj);
2718
2719 #ifdef DEBUG
2720 void ExternalUnsignedIntArrayPrint();
2721 void ExternalUnsignedIntArrayVerify();
2722 #endif // DEBUG
2723
2724 private:
2725 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedIntArray);
2726 };
2727
2728
2729 class ExternalFloatArray: public ExternalArray {
2730 public:
2731 // Setter and getter.
2732 inline float get(int index);
2733 inline void set(int index, float value);
2734
2735 // This accessor applies the correct conversion from Smi, HeapNumber
2736 // and undefined.
2737 Object* SetValue(uint32_t index, Object* value);
2738
2739 // Casting.
2740 static inline ExternalFloatArray* cast(Object* obj);
2741
2742 #ifdef DEBUG
2743 void ExternalFloatArrayPrint();
2744 void ExternalFloatArrayVerify();
2745 #endif // DEBUG
2746
2747 private:
2748 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloatArray);
2749 };
2750
2751
2510 // Code describes objects with on-the-fly generated machine code. 2752 // Code describes objects with on-the-fly generated machine code.
2511 class Code: public HeapObject { 2753 class Code: public HeapObject {
2512 public: 2754 public:
2513 // Opaque data type for encapsulating code flags like kind, inline 2755 // Opaque data type for encapsulating code flags like kind, inline
2514 // cache state, and arguments count. 2756 // cache state, and arguments count.
2515 enum Flags { }; 2757 enum Flags { };
2516 2758
2517 enum Kind { 2759 enum Kind {
2518 FUNCTION, 2760 FUNCTION,
2519 STUB, 2761 STUB,
(...skipping 2369 matching lines...) Expand 10 before | Expand all | Expand 10 after
4889 } else { 5131 } else {
4890 value &= ~(1 << bit_position); 5132 value &= ~(1 << bit_position);
4891 } 5133 }
4892 return value; 5134 return value;
4893 } 5135 }
4894 }; 5136 };
4895 5137
4896 } } // namespace v8::internal 5138 } } // namespace v8::internal
4897 5139
4898 #endif // V8_OBJECTS_H_ 5140 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698