OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // - JSArray | 50 // - JSArray |
51 // - JSRegExp | 51 // - JSRegExp |
52 // - JSFunction | 52 // - JSFunction |
53 // - GlobalObject | 53 // - GlobalObject |
54 // - JSGlobalObject | 54 // - JSGlobalObject |
55 // - JSBuiltinsObject | 55 // - JSBuiltinsObject |
56 // - JSGlobalProxy | 56 // - JSGlobalProxy |
57 // - JSValue | 57 // - JSValue |
58 // - JSMessageObject | 58 // - JSMessageObject |
59 // - ByteArray | 59 // - ByteArray |
60 // - PixelArray | |
61 // - ExternalArray | 60 // - ExternalArray |
| 61 // - ExternalPixelArray |
62 // - ExternalByteArray | 62 // - ExternalByteArray |
63 // - ExternalUnsignedByteArray | 63 // - ExternalUnsignedByteArray |
64 // - ExternalShortArray | 64 // - ExternalShortArray |
65 // - ExternalUnsignedShortArray | 65 // - ExternalUnsignedShortArray |
66 // - ExternalIntArray | 66 // - ExternalIntArray |
67 // - ExternalUnsignedIntArray | 67 // - ExternalUnsignedIntArray |
68 // - ExternalFloatArray | 68 // - ExternalFloatArray |
69 // - FixedArray | 69 // - FixedArray |
70 // - DescriptorArray | 70 // - DescriptorArray |
71 // - HashTable | 71 // - HashTable |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ | 255 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ |
256 \ | 256 \ |
257 V(MAP_TYPE) \ | 257 V(MAP_TYPE) \ |
258 V(CODE_TYPE) \ | 258 V(CODE_TYPE) \ |
259 V(ODDBALL_TYPE) \ | 259 V(ODDBALL_TYPE) \ |
260 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ | 260 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ |
261 \ | 261 \ |
262 V(HEAP_NUMBER_TYPE) \ | 262 V(HEAP_NUMBER_TYPE) \ |
263 V(PROXY_TYPE) \ | 263 V(PROXY_TYPE) \ |
264 V(BYTE_ARRAY_TYPE) \ | 264 V(BYTE_ARRAY_TYPE) \ |
265 V(PIXEL_ARRAY_TYPE) \ | |
266 /* Note: the order of these external array */ \ | 265 /* Note: the order of these external array */ \ |
267 /* types is relied upon in */ \ | 266 /* types is relied upon in */ \ |
268 /* Object::IsExternalArray(). */ \ | 267 /* Object::IsExternalArray(). */ \ |
269 V(EXTERNAL_BYTE_ARRAY_TYPE) \ | 268 V(EXTERNAL_BYTE_ARRAY_TYPE) \ |
270 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ | 269 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ |
271 V(EXTERNAL_SHORT_ARRAY_TYPE) \ | 270 V(EXTERNAL_SHORT_ARRAY_TYPE) \ |
272 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ | 271 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ |
273 V(EXTERNAL_INT_ARRAY_TYPE) \ | 272 V(EXTERNAL_INT_ARRAY_TYPE) \ |
274 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ | 273 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ |
275 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ | 274 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ |
| 275 V(EXTERNAL_PIXEL_ARRAY_TYPE) \ |
276 V(FILLER_TYPE) \ | 276 V(FILLER_TYPE) \ |
277 \ | 277 \ |
278 V(ACCESSOR_INFO_TYPE) \ | 278 V(ACCESSOR_INFO_TYPE) \ |
279 V(ACCESS_CHECK_INFO_TYPE) \ | 279 V(ACCESS_CHECK_INFO_TYPE) \ |
280 V(INTERCEPTOR_INFO_TYPE) \ | 280 V(INTERCEPTOR_INFO_TYPE) \ |
281 V(CALL_HANDLER_INFO_TYPE) \ | 281 V(CALL_HANDLER_INFO_TYPE) \ |
282 V(FUNCTION_TEMPLATE_INFO_TYPE) \ | 282 V(FUNCTION_TEMPLATE_INFO_TYPE) \ |
283 V(OBJECT_TEMPLATE_INFO_TYPE) \ | 283 V(OBJECT_TEMPLATE_INFO_TYPE) \ |
284 V(SIGNATURE_INFO_TYPE) \ | 284 V(SIGNATURE_INFO_TYPE) \ |
285 V(TYPE_SWITCH_INFO_TYPE) \ | 285 V(TYPE_SWITCH_INFO_TYPE) \ |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE | 483 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE |
484 CODE_TYPE, | 484 CODE_TYPE, |
485 ODDBALL_TYPE, | 485 ODDBALL_TYPE, |
486 JS_GLOBAL_PROPERTY_CELL_TYPE, | 486 JS_GLOBAL_PROPERTY_CELL_TYPE, |
487 | 487 |
488 // "Data", objects that cannot contain non-map-word pointers to heap | 488 // "Data", objects that cannot contain non-map-word pointers to heap |
489 // objects. | 489 // objects. |
490 HEAP_NUMBER_TYPE, | 490 HEAP_NUMBER_TYPE, |
491 PROXY_TYPE, | 491 PROXY_TYPE, |
492 BYTE_ARRAY_TYPE, | 492 BYTE_ARRAY_TYPE, |
493 PIXEL_ARRAY_TYPE, | |
494 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | 493 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE |
495 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, | 494 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, |
496 EXTERNAL_SHORT_ARRAY_TYPE, | 495 EXTERNAL_SHORT_ARRAY_TYPE, |
497 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, | 496 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, |
498 EXTERNAL_INT_ARRAY_TYPE, | 497 EXTERNAL_INT_ARRAY_TYPE, |
499 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, | 498 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, |
500 EXTERNAL_FLOAT_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE | 499 EXTERNAL_FLOAT_ARRAY_TYPE, |
| 500 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE |
501 FILLER_TYPE, // LAST_DATA_TYPE | 501 FILLER_TYPE, // LAST_DATA_TYPE |
502 | 502 |
503 // Structs. | 503 // Structs. |
504 ACCESSOR_INFO_TYPE, | 504 ACCESSOR_INFO_TYPE, |
505 ACCESS_CHECK_INFO_TYPE, | 505 ACCESS_CHECK_INFO_TYPE, |
506 INTERCEPTOR_INFO_TYPE, | 506 INTERCEPTOR_INFO_TYPE, |
507 CALL_HANDLER_INFO_TYPE, | 507 CALL_HANDLER_INFO_TYPE, |
508 FUNCTION_TEMPLATE_INFO_TYPE, | 508 FUNCTION_TEMPLATE_INFO_TYPE, |
509 OBJECT_TEMPLATE_INFO_TYPE, | 509 OBJECT_TEMPLATE_INFO_TYPE, |
510 SIGNATURE_INFO_TYPE, | 510 SIGNATURE_INFO_TYPE, |
(...skipping 26 matching lines...) Expand all Loading... |
537 | 537 |
538 // Pseudo-types | 538 // Pseudo-types |
539 FIRST_TYPE = 0x0, | 539 FIRST_TYPE = 0x0, |
540 LAST_TYPE = JS_FUNCTION_TYPE, | 540 LAST_TYPE = JS_FUNCTION_TYPE, |
541 INVALID_TYPE = FIRST_TYPE - 1, | 541 INVALID_TYPE = FIRST_TYPE - 1, |
542 FIRST_NONSTRING_TYPE = MAP_TYPE, | 542 FIRST_NONSTRING_TYPE = MAP_TYPE, |
543 FIRST_STRING_TYPE = FIRST_TYPE, | 543 FIRST_STRING_TYPE = FIRST_TYPE, |
544 LAST_STRING_TYPE = FIRST_NONSTRING_TYPE - 1, | 544 LAST_STRING_TYPE = FIRST_NONSTRING_TYPE - 1, |
545 // Boundaries for testing for an external array. | 545 // Boundaries for testing for an external array. |
546 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, | 546 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, |
547 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_FLOAT_ARRAY_TYPE, | 547 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE, |
548 // Boundary for promotion to old data space/old pointer space. | 548 // Boundary for promotion to old data space/old pointer space. |
549 LAST_DATA_TYPE = FILLER_TYPE, | 549 LAST_DATA_TYPE = FILLER_TYPE, |
550 // Boundaries for testing the type is a JavaScript "object". Note that | 550 // Boundaries for testing the type is a JavaScript "object". Note that |
551 // function objects are not counted as objects, even though they are | 551 // function objects are not counted as objects, even though they are |
552 // implemented as such; only values whose typeof is "object" are included. | 552 // implemented as such; only values whose typeof is "object" are included. |
553 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, | 553 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, |
554 LAST_JS_OBJECT_TYPE = JS_REGEXP_TYPE, | 554 LAST_JS_OBJECT_TYPE = JS_REGEXP_TYPE, |
555 // RegExp objects have [[Class]] "function" because they are callable. | 555 // RegExp objects have [[Class]] "function" because they are callable. |
556 // All types from this type and above are objects with [[Class]] "function". | 556 // All types from this type and above are objects with [[Class]] "function". |
557 FIRST_FUNCTION_CLASS_TYPE = JS_REGEXP_TYPE | 557 FIRST_FUNCTION_CLASS_TYPE = JS_REGEXP_TYPE |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 V(String) \ | 648 V(String) \ |
649 V(Symbol) \ | 649 V(Symbol) \ |
650 V(SeqString) \ | 650 V(SeqString) \ |
651 V(ExternalString) \ | 651 V(ExternalString) \ |
652 V(ConsString) \ | 652 V(ConsString) \ |
653 V(ExternalTwoByteString) \ | 653 V(ExternalTwoByteString) \ |
654 V(ExternalAsciiString) \ | 654 V(ExternalAsciiString) \ |
655 V(SeqTwoByteString) \ | 655 V(SeqTwoByteString) \ |
656 V(SeqAsciiString) \ | 656 V(SeqAsciiString) \ |
657 \ | 657 \ |
658 V(PixelArray) \ | |
659 V(ExternalArray) \ | 658 V(ExternalArray) \ |
660 V(ExternalByteArray) \ | 659 V(ExternalByteArray) \ |
661 V(ExternalUnsignedByteArray) \ | 660 V(ExternalUnsignedByteArray) \ |
662 V(ExternalShortArray) \ | 661 V(ExternalShortArray) \ |
663 V(ExternalUnsignedShortArray) \ | 662 V(ExternalUnsignedShortArray) \ |
664 V(ExternalIntArray) \ | 663 V(ExternalIntArray) \ |
665 V(ExternalUnsignedIntArray) \ | 664 V(ExternalUnsignedIntArray) \ |
666 V(ExternalFloatArray) \ | 665 V(ExternalFloatArray) \ |
| 666 V(ExternalPixelArray) \ |
667 V(ByteArray) \ | 667 V(ByteArray) \ |
668 V(JSObject) \ | 668 V(JSObject) \ |
669 V(JSContextExtensionObject) \ | 669 V(JSContextExtensionObject) \ |
670 V(Map) \ | 670 V(Map) \ |
671 V(DescriptorArray) \ | 671 V(DescriptorArray) \ |
672 V(DeoptimizationInputData) \ | 672 V(DeoptimizationInputData) \ |
673 V(DeoptimizationOutputData) \ | 673 V(DeoptimizationOutputData) \ |
674 V(FixedArray) \ | 674 V(FixedArray) \ |
675 V(Context) \ | 675 V(Context) \ |
676 V(CatchContext) \ | 676 V(CatchContext) \ |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 NORMAL_DELETION, | 1290 NORMAL_DELETION, |
1291 STRICT_DELETION, | 1291 STRICT_DELETION, |
1292 FORCE_DELETION | 1292 FORCE_DELETION |
1293 }; | 1293 }; |
1294 | 1294 |
1295 enum ElementsKind { | 1295 enum ElementsKind { |
1296 // The only "fast" kind. | 1296 // The only "fast" kind. |
1297 FAST_ELEMENTS, | 1297 FAST_ELEMENTS, |
1298 // All the kinds below are "slow". | 1298 // All the kinds below are "slow". |
1299 DICTIONARY_ELEMENTS, | 1299 DICTIONARY_ELEMENTS, |
1300 PIXEL_ELEMENTS, | |
1301 EXTERNAL_BYTE_ELEMENTS, | 1300 EXTERNAL_BYTE_ELEMENTS, |
1302 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, | 1301 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, |
1303 EXTERNAL_SHORT_ELEMENTS, | 1302 EXTERNAL_SHORT_ELEMENTS, |
1304 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, | 1303 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, |
1305 EXTERNAL_INT_ELEMENTS, | 1304 EXTERNAL_INT_ELEMENTS, |
1306 EXTERNAL_UNSIGNED_INT_ELEMENTS, | 1305 EXTERNAL_UNSIGNED_INT_ELEMENTS, |
1307 EXTERNAL_FLOAT_ELEMENTS | 1306 EXTERNAL_FLOAT_ELEMENTS, |
| 1307 EXTERNAL_PIXEL_ELEMENTS |
1308 }; | 1308 }; |
1309 | 1309 |
1310 // [properties]: Backing storage for properties. | 1310 // [properties]: Backing storage for properties. |
1311 // properties is a FixedArray in the fast case and a Dictionary in the | 1311 // properties is a FixedArray in the fast case and a Dictionary in the |
1312 // slow case. | 1312 // slow case. |
1313 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. | 1313 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. |
1314 inline void initialize_properties(); | 1314 inline void initialize_properties(); |
1315 inline bool HasFastProperties(); | 1315 inline bool HasFastProperties(); |
1316 inline StringDictionary* property_dictionary(); // Gets slow properties. | 1316 inline StringDictionary* property_dictionary(); // Gets slow properties. |
1317 | 1317 |
1318 // [elements]: The elements (properties with names that are integers). | 1318 // [elements]: The elements (properties with names that are integers). |
1319 // | 1319 // |
1320 // Elements can be in two general modes: fast and slow. Each mode | 1320 // Elements can be in two general modes: fast and slow. Each mode |
1321 // corrensponds to a set of object representations of elements that | 1321 // corrensponds to a set of object representations of elements that |
1322 // have something in common. | 1322 // have something in common. |
1323 // | 1323 // |
1324 // In the fast mode elements is a FixedArray and so each element can | 1324 // In the fast mode elements is a FixedArray and so each element can |
1325 // be quickly accessed. This fact is used in the generated code. The | 1325 // be quickly accessed. This fact is used in the generated code. The |
1326 // elements array can have one of the two maps in this mode: | 1326 // elements array can have one of the two maps in this mode: |
1327 // fixed_array_map or fixed_cow_array_map (for copy-on-write | 1327 // fixed_array_map or fixed_cow_array_map (for copy-on-write |
1328 // arrays). In the latter case the elements array may be shared by a | 1328 // arrays). In the latter case the elements array may be shared by a |
1329 // few objects and so before writing to any element the array must | 1329 // few objects and so before writing to any element the array must |
1330 // be copied. Use EnsureWritableFastElements in this case. | 1330 // be copied. Use EnsureWritableFastElements in this case. |
1331 // | 1331 // |
1332 // In the slow mode elements is either a NumberDictionary or a | 1332 // In the slow mode elements is either a NumberDictionary or an ExternalArray. |
1333 // PixelArray or an ExternalArray. | |
1334 DECL_ACCESSORS(elements, HeapObject) | 1333 DECL_ACCESSORS(elements, HeapObject) |
1335 inline void initialize_elements(); | 1334 inline void initialize_elements(); |
1336 MUST_USE_RESULT inline MaybeObject* ResetElements(); | 1335 MUST_USE_RESULT inline MaybeObject* ResetElements(); |
1337 inline ElementsKind GetElementsKind(); | 1336 inline ElementsKind GetElementsKind(); |
1338 inline bool HasFastElements(); | 1337 inline bool HasFastElements(); |
1339 inline bool HasDictionaryElements(); | 1338 inline bool HasDictionaryElements(); |
1340 inline bool HasPixelElements(); | 1339 inline bool HasExternalPixelElements(); |
1341 inline bool HasExternalArrayElements(); | 1340 inline bool HasExternalArrayElements(); |
1342 inline bool HasExternalByteElements(); | 1341 inline bool HasExternalByteElements(); |
1343 inline bool HasExternalUnsignedByteElements(); | 1342 inline bool HasExternalUnsignedByteElements(); |
1344 inline bool HasExternalShortElements(); | 1343 inline bool HasExternalShortElements(); |
1345 inline bool HasExternalUnsignedShortElements(); | 1344 inline bool HasExternalUnsignedShortElements(); |
1346 inline bool HasExternalIntElements(); | 1345 inline bool HasExternalIntElements(); |
1347 inline bool HasExternalUnsignedIntElements(); | 1346 inline bool HasExternalUnsignedIntElements(); |
1348 inline bool HasExternalFloatElements(); | 1347 inline bool HasExternalFloatElements(); |
1349 inline bool AllowsSetElementsLength(); | 1348 inline bool AllowsSetElementsLength(); |
1350 inline NumberDictionary* element_dictionary(); // Gets slow elements. | 1349 inline NumberDictionary* element_dictionary(); // Gets slow elements. |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2743 // Maximal memory consumption for a single ByteArray. | 2742 // Maximal memory consumption for a single ByteArray. |
2744 static const int kMaxSize = 512 * MB; | 2743 static const int kMaxSize = 512 * MB; |
2745 // Maximal length of a single ByteArray. | 2744 // Maximal length of a single ByteArray. |
2746 static const int kMaxLength = kMaxSize - kHeaderSize; | 2745 static const int kMaxLength = kMaxSize - kHeaderSize; |
2747 | 2746 |
2748 private: | 2747 private: |
2749 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 2748 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
2750 }; | 2749 }; |
2751 | 2750 |
2752 | 2751 |
2753 // A PixelArray represents a fixed-size byte array with special semantics | |
2754 // used for implementing the CanvasPixelArray object. Please see the | |
2755 // specification at: | |
2756 // http://www.whatwg.org/specs/web-apps/current-work/ | |
2757 // multipage/the-canvas-element.html#canvaspixelarray | |
2758 // In particular, write access clamps the value written to 0 or 255 if the | |
2759 // value written is outside this range. | |
2760 class PixelArray: public HeapObject { | |
2761 public: | |
2762 // [length]: length of the array. | |
2763 inline int length(); | |
2764 inline void set_length(int value); | |
2765 | |
2766 // [external_pointer]: The pointer to the external memory area backing this | |
2767 // pixel array. | |
2768 DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store. | |
2769 | |
2770 // Setter and getter. | |
2771 inline uint8_t get(int index); | |
2772 inline void set(int index, uint8_t value); | |
2773 | |
2774 // This accessor applies the correct conversion from Smi, HeapNumber and | |
2775 // undefined and clamps the converted value between 0 and 255. | |
2776 Object* SetValue(uint32_t index, Object* value); | |
2777 | |
2778 // Casting. | |
2779 static inline PixelArray* cast(Object* obj); | |
2780 | |
2781 #ifdef OBJECT_PRINT | |
2782 inline void PixelArrayPrint() { | |
2783 PixelArrayPrint(stdout); | |
2784 } | |
2785 void PixelArrayPrint(FILE* out); | |
2786 #endif | |
2787 #ifdef DEBUG | |
2788 void PixelArrayVerify(); | |
2789 #endif // DEBUG | |
2790 | |
2791 // Maximal acceptable length for a pixel array. | |
2792 static const int kMaxLength = 0x3fffffff; | |
2793 | |
2794 // PixelArray headers are not quadword aligned. | |
2795 static const int kLengthOffset = HeapObject::kHeaderSize; | |
2796 static const int kExternalPointerOffset = | |
2797 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); | |
2798 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | |
2799 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | |
2800 | |
2801 private: | |
2802 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); | |
2803 }; | |
2804 | |
2805 | |
2806 // An ExternalArray represents a fixed-size array of primitive values | 2752 // An ExternalArray represents a fixed-size array of primitive values |
2807 // which live outside the JavaScript heap. Its subclasses are used to | 2753 // which live outside the JavaScript heap. Its subclasses are used to |
2808 // implement the CanvasArray types being defined in the WebGL | 2754 // implement the CanvasArray types being defined in the WebGL |
2809 // specification. As of this writing the first public draft is not yet | 2755 // specification. As of this writing the first public draft is not yet |
2810 // available, but Khronos members can access the draft at: | 2756 // available, but Khronos members can access the draft at: |
2811 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html | 2757 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html |
2812 // | 2758 // |
2813 // The semantics of these arrays differ from CanvasPixelArray. | 2759 // The semantics of these arrays differ from CanvasPixelArray. |
2814 // Out-of-range values passed to the setter are converted via a C | 2760 // Out-of-range values passed to the setter are converted via a C |
2815 // cast, not clamping. Out-of-range indices cause exceptions to be | 2761 // cast, not clamping. Out-of-range indices cause exceptions to be |
(...skipping 19 matching lines...) Expand all Loading... |
2835 static const int kExternalPointerOffset = | 2781 static const int kExternalPointerOffset = |
2836 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); | 2782 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); |
2837 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | 2783 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; |
2838 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | 2784 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); |
2839 | 2785 |
2840 private: | 2786 private: |
2841 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); | 2787 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); |
2842 }; | 2788 }; |
2843 | 2789 |
2844 | 2790 |
| 2791 // A ExternalPixelArray represents a fixed-size byte array with special |
| 2792 // semantics used for implementing the CanvasPixelArray object. Please see the |
| 2793 // specification at: |
| 2794 |
| 2795 // http://www.whatwg.org/specs/web-apps/current-work/ |
| 2796 // multipage/the-canvas-element.html#canvaspixelarray |
| 2797 // In particular, write access clamps the value written to 0 or 255 if the |
| 2798 // value written is outside this range. |
| 2799 class ExternalPixelArray: public ExternalArray { |
| 2800 public: |
| 2801 inline uint8_t* external_pixel_pointer(); |
| 2802 |
| 2803 // Setter and getter. |
| 2804 inline uint8_t get(int index); |
| 2805 inline void set(int index, uint8_t value); |
| 2806 |
| 2807 // This accessor applies the correct conversion from Smi, HeapNumber and |
| 2808 // undefined and clamps the converted value between 0 and 255. |
| 2809 Object* SetValue(uint32_t index, Object* value); |
| 2810 |
| 2811 // Casting. |
| 2812 static inline ExternalPixelArray* cast(Object* obj); |
| 2813 |
| 2814 #ifdef OBJECT_PRINT |
| 2815 inline void ExternalPixelArrayPrint() { |
| 2816 ExternalPixelArrayPrint(stdout); |
| 2817 } |
| 2818 void ExternalPixelArrayPrint(FILE* out); |
| 2819 #endif |
| 2820 #ifdef DEBUG |
| 2821 void ExternalPixelArrayVerify(); |
| 2822 #endif // DEBUG |
| 2823 |
| 2824 private: |
| 2825 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalPixelArray); |
| 2826 }; |
| 2827 |
| 2828 |
2845 class ExternalByteArray: public ExternalArray { | 2829 class ExternalByteArray: public ExternalArray { |
2846 public: | 2830 public: |
2847 // Setter and getter. | 2831 // Setter and getter. |
2848 inline int8_t get(int index); | 2832 inline int8_t get(int index); |
2849 inline void set(int index, int8_t value); | 2833 inline void set(int index, int8_t value); |
2850 | 2834 |
2851 // This accessor applies the correct conversion from Smi, HeapNumber | 2835 // This accessor applies the correct conversion from Smi, HeapNumber |
2852 // and undefined. | 2836 // and undefined. |
2853 MaybeObject* SetValue(uint32_t index, Object* value); | 2837 MaybeObject* SetValue(uint32_t index, Object* value); |
2854 | 2838 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3169 FLAGS_MAX_VALUE = kMaxInt | 3153 FLAGS_MAX_VALUE = kMaxInt |
3170 }; | 3154 }; |
3171 | 3155 |
3172 enum Kind { | 3156 enum Kind { |
3173 FUNCTION, | 3157 FUNCTION, |
3174 OPTIMIZED_FUNCTION, | 3158 OPTIMIZED_FUNCTION, |
3175 STUB, | 3159 STUB, |
3176 BUILTIN, | 3160 BUILTIN, |
3177 LOAD_IC, | 3161 LOAD_IC, |
3178 KEYED_LOAD_IC, | 3162 KEYED_LOAD_IC, |
| 3163 KEYED_EXTERNAL_ARRAY_LOAD_IC, |
3179 CALL_IC, | 3164 CALL_IC, |
3180 KEYED_CALL_IC, | 3165 KEYED_CALL_IC, |
3181 STORE_IC, | 3166 STORE_IC, |
3182 KEYED_STORE_IC, | 3167 KEYED_STORE_IC, |
| 3168 KEYED_EXTERNAL_ARRAY_STORE_IC, |
3183 BINARY_OP_IC, | 3169 BINARY_OP_IC, |
3184 TYPE_RECORDING_BINARY_OP_IC, | 3170 TYPE_RECORDING_BINARY_OP_IC, |
3185 COMPARE_IC, | 3171 COMPARE_IC, |
3186 // No more than 16 kinds. The value currently encoded in four bits in | 3172 // No more than 16 kinds. The value currently encoded in four bits in |
3187 // Flags. | 3173 // Flags. |
3188 | 3174 |
3189 // Pseudo-kinds. | 3175 // Pseudo-kinds. |
3190 REGEXP = BUILTIN, | 3176 REGEXP = BUILTIN, |
3191 FIRST_IC_KIND = LOAD_IC, | 3177 FIRST_IC_KIND = LOAD_IC, |
3192 LAST_IC_KIND = COMPARE_IC | 3178 LAST_IC_KIND = COMPARE_IC |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3666 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); | 3652 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); |
3667 | 3653 |
3668 // Returns this map if it has the fast elements bit cleared, | 3654 // Returns this map if it has the fast elements bit cleared, |
3669 // otherwise returns a copy of the map, with all transitions dropped | 3655 // otherwise returns a copy of the map, with all transitions dropped |
3670 // from the descriptors and the fast elements bit cleared. | 3656 // from the descriptors and the fast elements bit cleared. |
3671 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); | 3657 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); |
3672 | 3658 |
3673 // Returns this map if it has the pixel array elements bit is set, otherwise | 3659 // Returns this map if it has the pixel array elements bit is set, otherwise |
3674 // returns a copy of the map, with all transitions dropped from the | 3660 // returns a copy of the map, with all transitions dropped from the |
3675 // descriptors and the pixel array elements bit set. | 3661 // descriptors and the pixel array elements bit set. |
3676 MUST_USE_RESULT inline MaybeObject* GetPixelArrayElementsMap(); | 3662 MUST_USE_RESULT inline MaybeObject* GetExternalPixelArrayElementsMap(); |
3677 | 3663 |
3678 // Returns the property index for name (only valid for FAST MODE). | 3664 // Returns the property index for name (only valid for FAST MODE). |
3679 int PropertyIndexFor(String* name); | 3665 int PropertyIndexFor(String* name); |
3680 | 3666 |
3681 // Returns the next free property index (only valid for FAST MODE). | 3667 // Returns the next free property index (only valid for FAST MODE). |
3682 int NextFreePropertyIndex(); | 3668 int NextFreePropertyIndex(); |
3683 | 3669 |
3684 // Returns the number of properties described in instance_descriptors. | 3670 // Returns the number of properties described in instance_descriptors. |
3685 int NumberOfDescribedProperties(); | 3671 int NumberOfDescribedProperties(); |
3686 | 3672 |
(...skipping 2866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6553 } else { | 6539 } else { |
6554 value &= ~(1 << bit_position); | 6540 value &= ~(1 << bit_position); |
6555 } | 6541 } |
6556 return value; | 6542 return value; |
6557 } | 6543 } |
6558 }; | 6544 }; |
6559 | 6545 |
6560 } } // namespace v8::internal | 6546 } } // namespace v8::internal |
6561 | 6547 |
6562 #endif // V8_OBJECTS_H_ | 6548 #endif // V8_OBJECTS_H_ |
OLD | NEW |