| Index: src/objects.h
|
| ===================================================================
|
| --- src/objects.h (revision 7180)
|
| +++ src/objects.h (working copy)
|
| @@ -57,8 +57,8 @@
|
| // - JSValue
|
| // - JSMessageObject
|
| // - ByteArray
|
| -// - PixelArray
|
| // - ExternalArray
|
| +// - ExternalPixelArray
|
| // - ExternalByteArray
|
| // - ExternalUnsignedByteArray
|
| // - ExternalShortArray
|
| @@ -262,7 +262,6 @@
|
| V(HEAP_NUMBER_TYPE) \
|
| V(PROXY_TYPE) \
|
| V(BYTE_ARRAY_TYPE) \
|
| - V(PIXEL_ARRAY_TYPE) \
|
| /* Note: the order of these external array */ \
|
| /* types is relied upon in */ \
|
| /* Object::IsExternalArray(). */ \
|
| @@ -273,6 +272,7 @@
|
| V(EXTERNAL_INT_ARRAY_TYPE) \
|
| V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \
|
| V(EXTERNAL_FLOAT_ARRAY_TYPE) \
|
| + V(EXTERNAL_PIXEL_ARRAY_TYPE) \
|
| V(FILLER_TYPE) \
|
| \
|
| V(ACCESSOR_INFO_TYPE) \
|
| @@ -490,14 +490,14 @@
|
| HEAP_NUMBER_TYPE,
|
| PROXY_TYPE,
|
| BYTE_ARRAY_TYPE,
|
| - PIXEL_ARRAY_TYPE,
|
| EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE
|
| EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE,
|
| EXTERNAL_SHORT_ARRAY_TYPE,
|
| EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE,
|
| EXTERNAL_INT_ARRAY_TYPE,
|
| EXTERNAL_UNSIGNED_INT_ARRAY_TYPE,
|
| - EXTERNAL_FLOAT_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE
|
| + EXTERNAL_FLOAT_ARRAY_TYPE,
|
| + EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE
|
| FILLER_TYPE, // LAST_DATA_TYPE
|
|
|
| // Structs.
|
| @@ -544,7 +544,7 @@
|
| LAST_STRING_TYPE = FIRST_NONSTRING_TYPE - 1,
|
| // Boundaries for testing for an external array.
|
| FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE,
|
| - LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_FLOAT_ARRAY_TYPE,
|
| + LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE,
|
| // Boundary for promotion to old data space/old pointer space.
|
| LAST_DATA_TYPE = FILLER_TYPE,
|
| // Boundaries for testing the type is a JavaScript "object". Note that
|
| @@ -655,7 +655,6 @@
|
| V(SeqTwoByteString) \
|
| V(SeqAsciiString) \
|
| \
|
| - V(PixelArray) \
|
| V(ExternalArray) \
|
| V(ExternalByteArray) \
|
| V(ExternalUnsignedByteArray) \
|
| @@ -664,6 +663,7 @@
|
| V(ExternalIntArray) \
|
| V(ExternalUnsignedIntArray) \
|
| V(ExternalFloatArray) \
|
| + V(ExternalPixelArray) \
|
| V(ByteArray) \
|
| V(JSObject) \
|
| V(JSContextExtensionObject) \
|
| @@ -1198,14 +1198,14 @@
|
| FAST_ELEMENTS,
|
| // All the kinds below are "slow".
|
| DICTIONARY_ELEMENTS,
|
| - PIXEL_ELEMENTS,
|
| EXTERNAL_BYTE_ELEMENTS,
|
| EXTERNAL_UNSIGNED_BYTE_ELEMENTS,
|
| EXTERNAL_SHORT_ELEMENTS,
|
| EXTERNAL_UNSIGNED_SHORT_ELEMENTS,
|
| EXTERNAL_INT_ELEMENTS,
|
| EXTERNAL_UNSIGNED_INT_ELEMENTS,
|
| - EXTERNAL_FLOAT_ELEMENTS
|
| + EXTERNAL_FLOAT_ELEMENTS,
|
| + EXTERNAL_PIXEL_ELEMENTS
|
| };
|
|
|
| // [properties]: Backing storage for properties.
|
| @@ -1230,15 +1230,14 @@
|
| // few objects and so before writing to any element the array must
|
| // be copied. Use EnsureWritableFastElements in this case.
|
| //
|
| - // In the slow mode elements is either a NumberDictionary or a
|
| - // PixelArray or an ExternalArray.
|
| + // In the slow mode elements is either a NumberDictionary or an ExternalArray.
|
| DECL_ACCESSORS(elements, HeapObject)
|
| inline void initialize_elements();
|
| MUST_USE_RESULT inline MaybeObject* ResetElements();
|
| inline ElementsKind GetElementsKind();
|
| inline bool HasFastElements();
|
| inline bool HasDictionaryElements();
|
| - inline bool HasPixelElements();
|
| + inline bool HasExternalPixelElements();
|
| inline bool HasExternalArrayElements();
|
| inline bool HasExternalByteElements();
|
| inline bool HasExternalUnsignedByteElements();
|
| @@ -1262,11 +1261,13 @@
|
|
|
| MUST_USE_RESULT MaybeObject* SetProperty(String* key,
|
| Object* value,
|
| - PropertyAttributes attributes);
|
| + PropertyAttributes attributes,
|
| + StrictModeFlag strict_mode);
|
| MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result,
|
| String* key,
|
| Object* value,
|
| - PropertyAttributes attributes);
|
| + PropertyAttributes attributes,
|
| + StrictModeFlag strict_mode);
|
| MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck(
|
| LookupResult* result,
|
| String* name,
|
| @@ -1281,11 +1282,13 @@
|
| MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor(
|
| String* name,
|
| Object* value,
|
| - PropertyAttributes attributes);
|
| + PropertyAttributes attributes,
|
| + StrictModeFlag strict_mode);
|
| MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor(
|
| String* name,
|
| Object* value,
|
| - PropertyAttributes attributes);
|
| + PropertyAttributes attributes,
|
| + StrictModeFlag strict_mode);
|
| MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes(
|
| String* key,
|
| Object* value,
|
| @@ -1412,6 +1415,12 @@
|
| inline bool HasElement(uint32_t index);
|
| bool HasElementWithReceiver(JSObject* receiver, uint32_t index);
|
|
|
| + // Computes the new capacity when expanding the elements of a JSObject.
|
| + static int NewElementsCapacity(int old_capacity) {
|
| + // (old_capacity + 50%) + 16
|
| + return old_capacity + (old_capacity >> 1) + 16;
|
| + }
|
| +
|
| // Tells whether the index'th element is present and how it is stored.
|
| enum LocalElementType {
|
| // There is no element with given index.
|
| @@ -1437,19 +1446,26 @@
|
|
|
| MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index,
|
| Object* value,
|
| + StrictModeFlag strict_mode,
|
| bool check_prototype = true);
|
|
|
| // Set the index'th array element.
|
| // A Failure object is returned if GC is needed.
|
| MUST_USE_RESULT MaybeObject* SetElement(uint32_t index,
|
| Object* value,
|
| + StrictModeFlag strict_mode,
|
| bool check_prototype = true);
|
|
|
| // Returns the index'th element.
|
| // The undefined object if index is out of bounds.
|
| - MaybeObject* GetElementWithReceiver(JSObject* receiver, uint32_t index);
|
| - MaybeObject* GetElementWithInterceptor(JSObject* receiver, uint32_t index);
|
| + MaybeObject* GetElementWithReceiver(Object* receiver, uint32_t index);
|
| + MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index);
|
|
|
| + // Get external element value at index if there is one and undefined
|
| + // otherwise. Can return a failure if allocation of a heap number
|
| + // failed.
|
| + MaybeObject* GetExternalElement(uint32_t index);
|
| +
|
| MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength(int capacity,
|
| int length);
|
| MUST_USE_RESULT MaybeObject* SetSlowElements(Object* length);
|
| @@ -1697,15 +1713,18 @@
|
| uint32_t index,
|
| Object* value,
|
| JSObject* holder);
|
| - MUST_USE_RESULT MaybeObject* SetElementWithInterceptor(uint32_t index,
|
| - Object* value,
|
| - bool check_prototype);
|
| + MUST_USE_RESULT MaybeObject* SetElementWithInterceptor(
|
| + uint32_t index,
|
| + Object* value,
|
| + StrictModeFlag strict_mode,
|
| + bool check_prototype);
|
| MUST_USE_RESULT MaybeObject* SetElementWithoutInterceptor(
|
| uint32_t index,
|
| Object* value,
|
| + StrictModeFlag strict_mode,
|
| bool check_prototype);
|
|
|
| - MaybeObject* GetElementPostInterceptor(JSObject* receiver, uint32_t index);
|
| + MaybeObject* GetElementPostInterceptor(Object* receiver, uint32_t index);
|
|
|
| MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name,
|
| DeleteMode mode);
|
| @@ -2339,13 +2358,18 @@
|
| }
|
|
|
| // Set the value for entry.
|
| - void ValueAtPut(int entry, Object* value) {
|
| + // Returns false if the put wasn't performed due to property being read only.
|
| + // Returns true on successful put.
|
| + bool ValueAtPut(int entry, Object* value) {
|
| // Check that this value can actually be written.
|
| PropertyDetails details = DetailsAt(entry);
|
| // If a value has not been initilized we allow writing to it even if
|
| // it is read only (a declared const that has not been initialized).
|
| - if (details.IsReadOnly() && !ValueAt(entry)->IsTheHole()) return;
|
| - this->set(HashTable<Shape, Key>::EntryToIndex(entry)+1, value);
|
| + if (details.IsReadOnly() && !ValueAt(entry)->IsTheHole()) {
|
| + return false;
|
| + }
|
| + this->set(HashTable<Shape, Key>::EntryToIndex(entry) + 1, value);
|
| + return true;
|
| }
|
|
|
| // Returns the property details for the property at entry.
|
| @@ -2651,59 +2675,6 @@
|
| };
|
|
|
|
|
| -// A PixelArray represents a fixed-size byte array with special semantics
|
| -// used for implementing the CanvasPixelArray object. Please see the
|
| -// specification at:
|
| -// http://www.whatwg.org/specs/web-apps/current-work/
|
| -// multipage/the-canvas-element.html#canvaspixelarray
|
| -// In particular, write access clamps the value written to 0 or 255 if the
|
| -// value written is outside this range.
|
| -class PixelArray: public HeapObject {
|
| - public:
|
| - // [length]: length of the array.
|
| - inline int length();
|
| - inline void set_length(int value);
|
| -
|
| - // [external_pointer]: The pointer to the external memory area backing this
|
| - // pixel array.
|
| - DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store.
|
| -
|
| - // Setter and getter.
|
| - inline uint8_t get(int index);
|
| - inline void set(int index, uint8_t value);
|
| -
|
| - // This accessor applies the correct conversion from Smi, HeapNumber and
|
| - // undefined and clamps the converted value between 0 and 255.
|
| - Object* SetValue(uint32_t index, Object* value);
|
| -
|
| - // Casting.
|
| - static inline PixelArray* cast(Object* obj);
|
| -
|
| -#ifdef OBJECT_PRINT
|
| - inline void PixelArrayPrint() {
|
| - PixelArrayPrint(stdout);
|
| - }
|
| - void PixelArrayPrint(FILE* out);
|
| -#endif
|
| -#ifdef DEBUG
|
| - void PixelArrayVerify();
|
| -#endif // DEBUG
|
| -
|
| - // Maximal acceptable length for a pixel array.
|
| - static const int kMaxLength = 0x3fffffff;
|
| -
|
| - // PixelArray headers are not quadword aligned.
|
| - static const int kLengthOffset = HeapObject::kHeaderSize;
|
| - static const int kExternalPointerOffset =
|
| - POINTER_SIZE_ALIGN(kLengthOffset + kIntSize);
|
| - static const int kHeaderSize = kExternalPointerOffset + kPointerSize;
|
| - static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
|
| -
|
| - private:
|
| - DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray);
|
| -};
|
| -
|
| -
|
| // An ExternalArray represents a fixed-size array of primitive values
|
| // which live outside the JavaScript heap. Its subclasses are used to
|
| // implement the CanvasArray types being defined in the WebGL
|
| @@ -2743,6 +2714,44 @@
|
| };
|
|
|
|
|
| +// A ExternalPixelArray represents a fixed-size byte array with special
|
| +// semantics used for implementing the CanvasPixelArray object. Please see the
|
| +// specification at:
|
| +
|
| +// http://www.whatwg.org/specs/web-apps/current-work/
|
| +// multipage/the-canvas-element.html#canvaspixelarray
|
| +// In particular, write access clamps the value written to 0 or 255 if the
|
| +// value written is outside this range.
|
| +class ExternalPixelArray: public ExternalArray {
|
| + public:
|
| + inline uint8_t* external_pixel_pointer();
|
| +
|
| + // Setter and getter.
|
| + inline uint8_t get(int index);
|
| + inline void set(int index, uint8_t value);
|
| +
|
| + // This accessor applies the correct conversion from Smi, HeapNumber and
|
| + // undefined and clamps the converted value between 0 and 255.
|
| + Object* SetValue(uint32_t index, Object* value);
|
| +
|
| + // Casting.
|
| + static inline ExternalPixelArray* cast(Object* obj);
|
| +
|
| +#ifdef OBJECT_PRINT
|
| + inline void ExternalPixelArrayPrint() {
|
| + ExternalPixelArrayPrint(stdout);
|
| + }
|
| + void ExternalPixelArrayPrint(FILE* out);
|
| +#endif
|
| +#ifdef DEBUG
|
| + void ExternalPixelArrayVerify();
|
| +#endif // DEBUG
|
| +
|
| + private:
|
| + DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalPixelArray);
|
| +};
|
| +
|
| +
|
| class ExternalByteArray: public ExternalArray {
|
| public:
|
| // Setter and getter.
|
| @@ -3077,10 +3086,12 @@
|
| BUILTIN,
|
| LOAD_IC,
|
| KEYED_LOAD_IC,
|
| + KEYED_EXTERNAL_ARRAY_LOAD_IC,
|
| CALL_IC,
|
| KEYED_CALL_IC,
|
| STORE_IC,
|
| KEYED_STORE_IC,
|
| + KEYED_EXTERNAL_ARRAY_STORE_IC,
|
| BINARY_OP_IC,
|
| TYPE_RECORDING_BINARY_OP_IC,
|
| COMPARE_IC,
|
| @@ -3155,6 +3166,12 @@
|
| return kind() == TYPE_RECORDING_BINARY_OP_IC;
|
| }
|
| inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; }
|
| + inline bool is_external_array_load_stub() {
|
| + return kind() == KEYED_EXTERNAL_ARRAY_LOAD_IC;
|
| + }
|
| + inline bool is_external_array_store_stub() {
|
| + return kind() == KEYED_EXTERNAL_ARRAY_STORE_IC;
|
| + }
|
|
|
| // [major_key]: For kind STUB or BINARY_OP_IC, the major key.
|
| inline int major_key();
|
| @@ -3196,6 +3213,12 @@
|
| inline CheckType check_type();
|
| inline void set_check_type(CheckType value);
|
|
|
| + // [external array type]: For kind KEYED_EXTERNAL_ARRAY_LOAD_IC and
|
| + // KEYED_EXTERNAL_ARRAY_STORE_IC, identifies the type of external
|
| + // array that the code stub is specialized for.
|
| + inline ExternalArrayType external_array_type();
|
| + inline void set_external_array_type(ExternalArrayType value);
|
| +
|
| // [binary op type]: For all BINARY_OP_IC.
|
| inline byte binary_op_type();
|
| inline void set_binary_op_type(byte value);
|
| @@ -3344,6 +3367,7 @@
|
| static const int kOptimizableOffset = kKindSpecificFlagsOffset;
|
| static const int kStackSlotsOffset = kKindSpecificFlagsOffset;
|
| static const int kCheckTypeOffset = kKindSpecificFlagsOffset;
|
| + static const int kExternalArrayTypeOffset = kKindSpecificFlagsOffset;
|
|
|
| static const int kCompareStateOffset = kStubMajorKeyOffset + 1;
|
| static const int kBinaryOpTypeOffset = kStubMajorKeyOffset + 1;
|
| @@ -3501,16 +3525,16 @@
|
| }
|
|
|
| // Tells whether an instance has pixel array elements.
|
| - inline void set_has_pixel_array_elements(bool value) {
|
| + inline void set_has_external_array_elements(bool value) {
|
| if (value) {
|
| - set_bit_field2(bit_field2() | (1 << kHasPixelArrayElements));
|
| + set_bit_field2(bit_field2() | (1 << kHasExternalArrayElements));
|
| } else {
|
| - set_bit_field2(bit_field2() & ~(1 << kHasPixelArrayElements));
|
| + set_bit_field2(bit_field2() & ~(1 << kHasExternalArrayElements));
|
| }
|
| }
|
|
|
| - inline bool has_pixel_array_elements() {
|
| - return ((1 << kHasPixelArrayElements) & bit_field2()) != 0;
|
| + inline bool has_external_array_elements() {
|
| + return ((1 << kHasExternalArrayElements) & bit_field2()) != 0;
|
| }
|
|
|
| // Tells whether the map is attached to SharedFunctionInfo
|
| @@ -3571,10 +3595,9 @@
|
| // from the descriptors and the fast elements bit cleared.
|
| MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap();
|
|
|
| - // Returns this map if it has the pixel array elements bit is set, otherwise
|
| - // returns a copy of the map, with all transitions dropped from the
|
| - // descriptors and the pixel array elements bit set.
|
| - MUST_USE_RESULT inline MaybeObject* GetPixelArrayElementsMap();
|
| + // Returns a new map with all transitions dropped from the descriptors and the
|
| + // external array elements bit set.
|
| + MUST_USE_RESULT inline MaybeObject* NewExternalArrayElementsMap();
|
|
|
| // Returns the property index for name (only valid for FAST MODE).
|
| int PropertyIndexFor(String* name);
|
| @@ -3694,7 +3717,7 @@
|
| static const int kStringWrapperSafeForDefaultValueOf = 3;
|
| static const int kAttachedToSharedFunctionInfo = 4;
|
| static const int kIsShared = 5;
|
| - static const int kHasPixelArrayElements = 6;
|
| + static const int kHasExternalArrayElements = 6;
|
|
|
| // Layout of the default cache. It holds alternating name and code objects.
|
| static const int kCodeCacheEntrySize = 2;
|
| @@ -5032,6 +5055,11 @@
|
| };
|
|
|
|
|
| +// Calculates string hash.
|
| +template <typename schar>
|
| +inline uint32_t HashSequentialString(const schar* chars, int length);
|
| +
|
| +
|
| // The characteristics of a string are stored in its map. Retrieving these
|
| // few bits of information is moderately expensive, involving two memory
|
| // loads where the second is dependent on the first. To improve efficiency
|
| @@ -6413,6 +6441,9 @@
|
| VisitExternalReferences(p, p + 1);
|
| }
|
|
|
| + // Visits a handle that has an embedder-assigned class ID.
|
| + virtual void VisitEmbedderReference(Object** p, uint16_t class_id) {}
|
| +
|
| #ifdef DEBUG
|
| // Intended for serialization/deserialization checking: insert, or
|
| // check for the presence of, a tag at this position in the stream.
|
|
|