| 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 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2768 // Maximal memory consumption for a single ByteArray. | 2767 // Maximal memory consumption for a single ByteArray. |
| 2769 static const int kMaxSize = 512 * MB; | 2768 static const int kMaxSize = 512 * MB; |
| 2770 // Maximal length of a single ByteArray. | 2769 // Maximal length of a single ByteArray. |
| 2771 static const int kMaxLength = kMaxSize - kHeaderSize; | 2770 static const int kMaxLength = kMaxSize - kHeaderSize; |
| 2772 | 2771 |
| 2773 private: | 2772 private: |
| 2774 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 2773 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
| 2775 }; | 2774 }; |
| 2776 | 2775 |
| 2777 | 2776 |
| 2778 // A PixelArray represents a fixed-size byte array with special semantics | |
| 2779 // used for implementing the CanvasPixelArray object. Please see the | |
| 2780 // specification at: | |
| 2781 // http://www.whatwg.org/specs/web-apps/current-work/ | |
| 2782 // multipage/the-canvas-element.html#canvaspixelarray | |
| 2783 // In particular, write access clamps the value written to 0 or 255 if the | |
| 2784 // value written is outside this range. | |
| 2785 class PixelArray: public HeapObject { | |
| 2786 public: | |
| 2787 // [length]: length of the array. | |
| 2788 inline int length(); | |
| 2789 inline void set_length(int value); | |
| 2790 | |
| 2791 // [external_pointer]: The pointer to the external memory area backing this | |
| 2792 // pixel array. | |
| 2793 DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store. | |
| 2794 | |
| 2795 // Setter and getter. | |
| 2796 inline uint8_t get(int index); | |
| 2797 inline void set(int index, uint8_t value); | |
| 2798 | |
| 2799 // This accessor applies the correct conversion from Smi, HeapNumber and | |
| 2800 // undefined and clamps the converted value between 0 and 255. | |
| 2801 Object* SetValue(uint32_t index, Object* value); | |
| 2802 | |
| 2803 // Casting. | |
| 2804 static inline PixelArray* cast(Object* obj); | |
| 2805 | |
| 2806 #ifdef OBJECT_PRINT | |
| 2807 inline void PixelArrayPrint() { | |
| 2808 PixelArrayPrint(stdout); | |
| 2809 } | |
| 2810 void PixelArrayPrint(FILE* out); | |
| 2811 #endif | |
| 2812 #ifdef DEBUG | |
| 2813 void PixelArrayVerify(); | |
| 2814 #endif // DEBUG | |
| 2815 | |
| 2816 // Maximal acceptable length for a pixel array. | |
| 2817 static const int kMaxLength = 0x3fffffff; | |
| 2818 | |
| 2819 // PixelArray headers are not quadword aligned. | |
| 2820 static const int kLengthOffset = HeapObject::kHeaderSize; | |
| 2821 static const int kExternalPointerOffset = | |
| 2822 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); | |
| 2823 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | |
| 2824 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | |
| 2825 | |
| 2826 private: | |
| 2827 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); | |
| 2828 }; | |
| 2829 | |
| 2830 | |
| 2831 // An ExternalArray represents a fixed-size array of primitive values | 2777 // An ExternalArray represents a fixed-size array of primitive values |
| 2832 // which live outside the JavaScript heap. Its subclasses are used to | 2778 // which live outside the JavaScript heap. Its subclasses are used to |
| 2833 // implement the CanvasArray types being defined in the WebGL | 2779 // implement the CanvasArray types being defined in the WebGL |
| 2834 // specification. As of this writing the first public draft is not yet | 2780 // specification. As of this writing the first public draft is not yet |
| 2835 // available, but Khronos members can access the draft at: | 2781 // available, but Khronos members can access the draft at: |
| 2836 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html | 2782 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html |
| 2837 // | 2783 // |
| 2838 // The semantics of these arrays differ from CanvasPixelArray. | 2784 // The semantics of these arrays differ from CanvasPixelArray. |
| 2839 // Out-of-range values passed to the setter are converted via a C | 2785 // Out-of-range values passed to the setter are converted via a C |
| 2840 // cast, not clamping. Out-of-range indices cause exceptions to be | 2786 // cast, not clamping. Out-of-range indices cause exceptions to be |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2860 static const int kExternalPointerOffset = | 2806 static const int kExternalPointerOffset = |
| 2861 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); | 2807 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); |
| 2862 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | 2808 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; |
| 2863 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | 2809 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); |
| 2864 | 2810 |
| 2865 private: | 2811 private: |
| 2866 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); | 2812 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); |
| 2867 }; | 2813 }; |
| 2868 | 2814 |
| 2869 | 2815 |
| 2816 // A ExternalPixelArray represents a fixed-size byte array with special |
| 2817 // semantics used for implementing the CanvasPixelArray object. Please see the |
| 2818 // specification at: |
| 2819 |
| 2820 // http://www.whatwg.org/specs/web-apps/current-work/ |
| 2821 // multipage/the-canvas-element.html#canvaspixelarray |
| 2822 // In particular, write access clamps the value written to 0 or 255 if the |
| 2823 // value written is outside this range. |
| 2824 class ExternalPixelArray: public ExternalArray { |
| 2825 public: |
| 2826 inline uint8_t* external_pixel_pointer(); |
| 2827 |
| 2828 // Setter and getter. |
| 2829 inline uint8_t get(int index); |
| 2830 inline void set(int index, uint8_t value); |
| 2831 |
| 2832 // This accessor applies the correct conversion from Smi, HeapNumber and |
| 2833 // undefined and clamps the converted value between 0 and 255. |
| 2834 Object* SetValue(uint32_t index, Object* value); |
| 2835 |
| 2836 // Casting. |
| 2837 static inline ExternalPixelArray* cast(Object* obj); |
| 2838 |
| 2839 #ifdef OBJECT_PRINT |
| 2840 inline void ExternalPixelArrayPrint() { |
| 2841 ExternalPixelArrayPrint(stdout); |
| 2842 } |
| 2843 void ExternalPixelArrayPrint(FILE* out); |
| 2844 #endif |
| 2845 #ifdef DEBUG |
| 2846 void ExternalPixelArrayVerify(); |
| 2847 #endif // DEBUG |
| 2848 |
| 2849 private: |
| 2850 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalPixelArray); |
| 2851 }; |
| 2852 |
| 2853 |
| 2870 class ExternalByteArray: public ExternalArray { | 2854 class ExternalByteArray: public ExternalArray { |
| 2871 public: | 2855 public: |
| 2872 // Setter and getter. | 2856 // Setter and getter. |
| 2873 inline int8_t get(int index); | 2857 inline int8_t get(int index); |
| 2874 inline void set(int index, int8_t value); | 2858 inline void set(int index, int8_t value); |
| 2875 | 2859 |
| 2876 // This accessor applies the correct conversion from Smi, HeapNumber | 2860 // This accessor applies the correct conversion from Smi, HeapNumber |
| 2877 // and undefined. | 2861 // and undefined. |
| 2878 MaybeObject* SetValue(uint32_t index, Object* value); | 2862 MaybeObject* SetValue(uint32_t index, Object* value); |
| 2879 | 2863 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3194 FLAGS_MAX_VALUE = kMaxInt | 3178 FLAGS_MAX_VALUE = kMaxInt |
| 3195 }; | 3179 }; |
| 3196 | 3180 |
| 3197 enum Kind { | 3181 enum Kind { |
| 3198 FUNCTION, | 3182 FUNCTION, |
| 3199 OPTIMIZED_FUNCTION, | 3183 OPTIMIZED_FUNCTION, |
| 3200 STUB, | 3184 STUB, |
| 3201 BUILTIN, | 3185 BUILTIN, |
| 3202 LOAD_IC, | 3186 LOAD_IC, |
| 3203 KEYED_LOAD_IC, | 3187 KEYED_LOAD_IC, |
| 3188 KEYED_EXTERNAL_ARRAY_LOAD_IC, |
| 3204 CALL_IC, | 3189 CALL_IC, |
| 3205 KEYED_CALL_IC, | 3190 KEYED_CALL_IC, |
| 3206 STORE_IC, | 3191 STORE_IC, |
| 3207 KEYED_STORE_IC, | 3192 KEYED_STORE_IC, |
| 3193 KEYED_EXTERNAL_ARRAY_STORE_IC, |
| 3208 BINARY_OP_IC, | 3194 BINARY_OP_IC, |
| 3209 TYPE_RECORDING_BINARY_OP_IC, | 3195 TYPE_RECORDING_BINARY_OP_IC, |
| 3210 COMPARE_IC, | 3196 COMPARE_IC, |
| 3211 // No more than 16 kinds. The value currently encoded in four bits in | 3197 // No more than 16 kinds. The value currently encoded in four bits in |
| 3212 // Flags. | 3198 // Flags. |
| 3213 | 3199 |
| 3214 // Pseudo-kinds. | 3200 // Pseudo-kinds. |
| 3215 REGEXP = BUILTIN, | 3201 REGEXP = BUILTIN, |
| 3216 FIRST_IC_KIND = LOAD_IC, | 3202 FIRST_IC_KIND = LOAD_IC, |
| 3217 LAST_IC_KIND = COMPARE_IC | 3203 LAST_IC_KIND = COMPARE_IC |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3272 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } | 3258 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } |
| 3273 inline bool is_store_stub() { return kind() == STORE_IC; } | 3259 inline bool is_store_stub() { return kind() == STORE_IC; } |
| 3274 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } | 3260 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } |
| 3275 inline bool is_call_stub() { return kind() == CALL_IC; } | 3261 inline bool is_call_stub() { return kind() == CALL_IC; } |
| 3276 inline bool is_keyed_call_stub() { return kind() == KEYED_CALL_IC; } | 3262 inline bool is_keyed_call_stub() { return kind() == KEYED_CALL_IC; } |
| 3277 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } | 3263 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } |
| 3278 inline bool is_type_recording_binary_op_stub() { | 3264 inline bool is_type_recording_binary_op_stub() { |
| 3279 return kind() == TYPE_RECORDING_BINARY_OP_IC; | 3265 return kind() == TYPE_RECORDING_BINARY_OP_IC; |
| 3280 } | 3266 } |
| 3281 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } | 3267 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } |
| 3268 inline bool is_external_array_load_stub() { |
| 3269 return kind() == KEYED_EXTERNAL_ARRAY_LOAD_IC; |
| 3270 } |
| 3271 inline bool is_external_array_store_stub() { |
| 3272 return kind() == KEYED_EXTERNAL_ARRAY_STORE_IC; |
| 3273 } |
| 3282 | 3274 |
| 3283 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. | 3275 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. |
| 3284 inline int major_key(); | 3276 inline int major_key(); |
| 3285 inline void set_major_key(int value); | 3277 inline void set_major_key(int value); |
| 3286 | 3278 |
| 3287 // [optimizable]: For FUNCTION kind, tells if it is optimizable. | 3279 // [optimizable]: For FUNCTION kind, tells if it is optimizable. |
| 3288 inline bool optimizable(); | 3280 inline bool optimizable(); |
| 3289 inline void set_optimizable(bool value); | 3281 inline void set_optimizable(bool value); |
| 3290 | 3282 |
| 3291 // [has_deoptimization_support]: For FUNCTION kind, tells if it has | 3283 // [has_deoptimization_support]: For FUNCTION kind, tells if it has |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3313 // [stack_check_table_start]: For kind FUNCTION, the offset in the | 3305 // [stack_check_table_start]: For kind FUNCTION, the offset in the |
| 3314 // instruction stream where the stack check table starts. | 3306 // instruction stream where the stack check table starts. |
| 3315 inline unsigned stack_check_table_offset(); | 3307 inline unsigned stack_check_table_offset(); |
| 3316 inline void set_stack_check_table_offset(unsigned offset); | 3308 inline void set_stack_check_table_offset(unsigned offset); |
| 3317 | 3309 |
| 3318 // [check type]: For kind CALL_IC, tells how to check if the | 3310 // [check type]: For kind CALL_IC, tells how to check if the |
| 3319 // receiver is valid for the given call. | 3311 // receiver is valid for the given call. |
| 3320 inline CheckType check_type(); | 3312 inline CheckType check_type(); |
| 3321 inline void set_check_type(CheckType value); | 3313 inline void set_check_type(CheckType value); |
| 3322 | 3314 |
| 3315 // [external array type]: For kind KEYED_EXTERNAL_ARRAY_LOAD_IC and |
| 3316 // KEYED_EXTERNAL_ARRAY_STORE_IC, identifies the type of external |
| 3317 // array that the code stub is specialized for. |
| 3318 inline ExternalArrayType external_array_type(); |
| 3319 inline void set_external_array_type(ExternalArrayType value); |
| 3320 |
| 3323 // [binary op type]: For all BINARY_OP_IC. | 3321 // [binary op type]: For all BINARY_OP_IC. |
| 3324 inline byte binary_op_type(); | 3322 inline byte binary_op_type(); |
| 3325 inline void set_binary_op_type(byte value); | 3323 inline void set_binary_op_type(byte value); |
| 3326 | 3324 |
| 3327 // [type-recording binary op type]: For all TYPE_RECORDING_BINARY_OP_IC. | 3325 // [type-recording binary op type]: For all TYPE_RECORDING_BINARY_OP_IC. |
| 3328 inline byte type_recording_binary_op_type(); | 3326 inline byte type_recording_binary_op_type(); |
| 3329 inline void set_type_recording_binary_op_type(byte value); | 3327 inline void set_type_recording_binary_op_type(byte value); |
| 3330 inline byte type_recording_binary_op_result_type(); | 3328 inline byte type_recording_binary_op_result_type(); |
| 3331 inline void set_type_recording_binary_op_result_type(byte value); | 3329 inline void set_type_recording_binary_op_result_type(byte value); |
| 3332 | 3330 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3461 // Add padding to align the instruction start following right after | 3459 // Add padding to align the instruction start following right after |
| 3462 // the Code object header. | 3460 // the Code object header. |
| 3463 static const int kHeaderSize = | 3461 static const int kHeaderSize = |
| 3464 (kHeaderPaddingStart + kCodeAlignmentMask) & ~kCodeAlignmentMask; | 3462 (kHeaderPaddingStart + kCodeAlignmentMask) & ~kCodeAlignmentMask; |
| 3465 | 3463 |
| 3466 // Byte offsets within kKindSpecificFlagsOffset. | 3464 // Byte offsets within kKindSpecificFlagsOffset. |
| 3467 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset; | 3465 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset; |
| 3468 static const int kOptimizableOffset = kKindSpecificFlagsOffset; | 3466 static const int kOptimizableOffset = kKindSpecificFlagsOffset; |
| 3469 static const int kStackSlotsOffset = kKindSpecificFlagsOffset; | 3467 static const int kStackSlotsOffset = kKindSpecificFlagsOffset; |
| 3470 static const int kCheckTypeOffset = kKindSpecificFlagsOffset; | 3468 static const int kCheckTypeOffset = kKindSpecificFlagsOffset; |
| 3469 static const int kExternalArrayTypeOffset = kKindSpecificFlagsOffset; |
| 3471 | 3470 |
| 3472 static const int kCompareStateOffset = kStubMajorKeyOffset + 1; | 3471 static const int kCompareStateOffset = kStubMajorKeyOffset + 1; |
| 3473 static const int kBinaryOpTypeOffset = kStubMajorKeyOffset + 1; | 3472 static const int kBinaryOpTypeOffset = kStubMajorKeyOffset + 1; |
| 3474 static const int kHasDeoptimizationSupportOffset = kOptimizableOffset + 1; | 3473 static const int kHasDeoptimizationSupportOffset = kOptimizableOffset + 1; |
| 3475 | 3474 |
| 3476 static const int kBinaryOpReturnTypeOffset = kBinaryOpTypeOffset + 1; | 3475 static const int kBinaryOpReturnTypeOffset = kBinaryOpTypeOffset + 1; |
| 3477 static const int kAllowOSRAtLoopNestingLevelOffset = | 3476 static const int kAllowOSRAtLoopNestingLevelOffset = |
| 3478 kHasDeoptimizationSupportOffset + 1; | 3477 kHasDeoptimizationSupportOffset + 1; |
| 3479 | 3478 |
| 3480 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize; | 3479 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3618 } else { | 3617 } else { |
| 3619 set_bit_field2(bit_field2() & ~(1 << kHasFastElements)); | 3618 set_bit_field2(bit_field2() & ~(1 << kHasFastElements)); |
| 3620 } | 3619 } |
| 3621 } | 3620 } |
| 3622 | 3621 |
| 3623 inline bool has_fast_elements() { | 3622 inline bool has_fast_elements() { |
| 3624 return ((1 << kHasFastElements) & bit_field2()) != 0; | 3623 return ((1 << kHasFastElements) & bit_field2()) != 0; |
| 3625 } | 3624 } |
| 3626 | 3625 |
| 3627 // Tells whether an instance has pixel array elements. | 3626 // Tells whether an instance has pixel array elements. |
| 3628 inline void set_has_pixel_array_elements(bool value) { | 3627 inline void set_has_external_array_elements(bool value) { |
| 3629 if (value) { | 3628 if (value) { |
| 3630 set_bit_field2(bit_field2() | (1 << kHasPixelArrayElements)); | 3629 set_bit_field2(bit_field2() | (1 << kHasExternalArrayElements)); |
| 3631 } else { | 3630 } else { |
| 3632 set_bit_field2(bit_field2() & ~(1 << kHasPixelArrayElements)); | 3631 set_bit_field2(bit_field2() & ~(1 << kHasExternalArrayElements)); |
| 3633 } | 3632 } |
| 3634 } | 3633 } |
| 3635 | 3634 |
| 3636 inline bool has_pixel_array_elements() { | 3635 inline bool has_external_array_elements() { |
| 3637 return ((1 << kHasPixelArrayElements) & bit_field2()) != 0; | 3636 return ((1 << kHasExternalArrayElements) & bit_field2()) != 0; |
| 3638 } | 3637 } |
| 3639 | 3638 |
| 3640 // Tells whether the map is attached to SharedFunctionInfo | 3639 // Tells whether the map is attached to SharedFunctionInfo |
| 3641 // (for inobject slack tracking). | 3640 // (for inobject slack tracking). |
| 3642 inline void set_attached_to_shared_function_info(bool value); | 3641 inline void set_attached_to_shared_function_info(bool value); |
| 3643 | 3642 |
| 3644 inline bool attached_to_shared_function_info(); | 3643 inline bool attached_to_shared_function_info(); |
| 3645 | 3644 |
| 3646 // Tells whether the map is shared between objects that may have different | 3645 // Tells whether the map is shared between objects that may have different |
| 3647 // behavior. If true, the map should never be modified, instead a clone | 3646 // behavior. If true, the map should never be modified, instead a clone |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3688 // Returns this map if it has the fast elements bit set, otherwise | 3687 // Returns this map if it has the fast elements bit set, otherwise |
| 3689 // returns a copy of the map, with all transitions dropped from the | 3688 // returns a copy of the map, with all transitions dropped from the |
| 3690 // descriptors and the fast elements bit set. | 3689 // descriptors and the fast elements bit set. |
| 3691 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); | 3690 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); |
| 3692 | 3691 |
| 3693 // Returns this map if it has the fast elements bit cleared, | 3692 // Returns this map if it has the fast elements bit cleared, |
| 3694 // otherwise returns a copy of the map, with all transitions dropped | 3693 // otherwise returns a copy of the map, with all transitions dropped |
| 3695 // from the descriptors and the fast elements bit cleared. | 3694 // from the descriptors and the fast elements bit cleared. |
| 3696 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); | 3695 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); |
| 3697 | 3696 |
| 3698 // Returns this map if it has the pixel array elements bit is set, otherwise | 3697 // Returns a new map with all transitions dropped from the descriptors and the |
| 3699 // returns a copy of the map, with all transitions dropped from the | 3698 // external array elements bit set. |
| 3700 // descriptors and the pixel array elements bit set. | 3699 MUST_USE_RESULT inline MaybeObject* NewExternalArrayElementsMap(); |
| 3701 MUST_USE_RESULT inline MaybeObject* GetPixelArrayElementsMap(); | |
| 3702 | 3700 |
| 3703 // Returns the property index for name (only valid for FAST MODE). | 3701 // Returns the property index for name (only valid for FAST MODE). |
| 3704 int PropertyIndexFor(String* name); | 3702 int PropertyIndexFor(String* name); |
| 3705 | 3703 |
| 3706 // Returns the next free property index (only valid for FAST MODE). | 3704 // Returns the next free property index (only valid for FAST MODE). |
| 3707 int NextFreePropertyIndex(); | 3705 int NextFreePropertyIndex(); |
| 3708 | 3706 |
| 3709 // Returns the number of properties described in instance_descriptors. | 3707 // Returns the number of properties described in instance_descriptors. |
| 3710 int NumberOfDescribedProperties(); | 3708 int NumberOfDescribedProperties(); |
| 3711 | 3709 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3811 static const int kHasInstanceCallHandler = 6; | 3809 static const int kHasInstanceCallHandler = 6; |
| 3812 static const int kIsAccessCheckNeeded = 7; | 3810 static const int kIsAccessCheckNeeded = 7; |
| 3813 | 3811 |
| 3814 // Bit positions for bit field 2 | 3812 // Bit positions for bit field 2 |
| 3815 static const int kIsExtensible = 0; | 3813 static const int kIsExtensible = 0; |
| 3816 static const int kFunctionWithPrototype = 1; | 3814 static const int kFunctionWithPrototype = 1; |
| 3817 static const int kHasFastElements = 2; | 3815 static const int kHasFastElements = 2; |
| 3818 static const int kStringWrapperSafeForDefaultValueOf = 3; | 3816 static const int kStringWrapperSafeForDefaultValueOf = 3; |
| 3819 static const int kAttachedToSharedFunctionInfo = 4; | 3817 static const int kAttachedToSharedFunctionInfo = 4; |
| 3820 static const int kIsShared = 5; | 3818 static const int kIsShared = 5; |
| 3821 static const int kHasPixelArrayElements = 6; | 3819 static const int kHasExternalArrayElements = 6; |
| 3822 | 3820 |
| 3823 // Layout of the default cache. It holds alternating name and code objects. | 3821 // Layout of the default cache. It holds alternating name and code objects. |
| 3824 static const int kCodeCacheEntrySize = 2; | 3822 static const int kCodeCacheEntrySize = 2; |
| 3825 static const int kCodeCacheEntryNameOffset = 0; | 3823 static const int kCodeCacheEntryNameOffset = 0; |
| 3826 static const int kCodeCacheEntryCodeOffset = 1; | 3824 static const int kCodeCacheEntryCodeOffset = 1; |
| 3827 | 3825 |
| 3828 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, | 3826 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, |
| 3829 kPointerFieldsEndOffset, | 3827 kPointerFieldsEndOffset, |
| 3830 kSize> BodyDescriptor; | 3828 kSize> BodyDescriptor; |
| 3831 | 3829 |
| (...skipping 2746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6578 } else { | 6576 } else { |
| 6579 value &= ~(1 << bit_position); | 6577 value &= ~(1 << bit_position); |
| 6580 } | 6578 } |
| 6581 return value; | 6579 return value; |
| 6582 } | 6580 } |
| 6583 }; | 6581 }; |
| 6584 | 6582 |
| 6585 } } // namespace v8::internal | 6583 } } // namespace v8::internal |
| 6586 | 6584 |
| 6587 #endif // V8_OBJECTS_H_ | 6585 #endif // V8_OBJECTS_H_ |
| OLD | NEW |