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

Side by Side Diff: src/objects.h

Issue 1909433003: Remove support for Object.observe (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 8 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
« no previous file with comments | « src/messages.h ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/assert-scope.h" 10 #include "src/assert-scope.h"
(...skipping 2377 matching lines...) Expand 10 before | Expand all | Expand 10 after
2388 Object* pre_allocated_value, Object* filler_value); 2388 Object* pre_allocated_value, Object* filler_value);
2389 2389
2390 // Check whether this object references another object 2390 // Check whether this object references another object
2391 bool ReferencesObject(Object* obj); 2391 bool ReferencesObject(Object* obj);
2392 2392
2393 MUST_USE_RESULT static Maybe<bool> PreventExtensions( 2393 MUST_USE_RESULT static Maybe<bool> PreventExtensions(
2394 Handle<JSObject> object, ShouldThrow should_throw); 2394 Handle<JSObject> object, ShouldThrow should_throw);
2395 2395
2396 static bool IsExtensible(Handle<JSObject> object); 2396 static bool IsExtensible(Handle<JSObject> object);
2397 2397
2398 // Called the first time an object is observed with ES7 Object.observe.
2399 static void SetObserved(Handle<JSObject> object);
2400
2401 // Copy object. 2398 // Copy object.
2402 enum DeepCopyHints { kNoHints = 0, kObjectIsShallow = 1 }; 2399 enum DeepCopyHints { kNoHints = 0, kObjectIsShallow = 1 };
2403 2400
2404 MUST_USE_RESULT static MaybeHandle<JSObject> DeepCopy( 2401 MUST_USE_RESULT static MaybeHandle<JSObject> DeepCopy(
2405 Handle<JSObject> object, 2402 Handle<JSObject> object,
2406 AllocationSiteUsageContext* site_context, 2403 AllocationSiteUsageContext* site_context,
2407 DeepCopyHints hints = kNoHints); 2404 DeepCopyHints hints = kNoHints);
2408 MUST_USE_RESULT static MaybeHandle<JSObject> DeepWalk( 2405 MUST_USE_RESULT static MaybeHandle<JSObject> DeepWalk(
2409 Handle<JSObject> object, 2406 Handle<JSObject> object,
2410 AllocationSiteCreationContext* site_context); 2407 AllocationSiteCreationContext* site_context);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 static const int kFieldsAdded = 3; 2488 static const int kFieldsAdded = 3;
2492 2489
2493 // Layout description. 2490 // Layout description.
2494 static const int kElementsOffset = JSReceiver::kHeaderSize; 2491 static const int kElementsOffset = JSReceiver::kHeaderSize;
2495 static const int kHeaderSize = kElementsOffset + kPointerSize; 2492 static const int kHeaderSize = kElementsOffset + kPointerSize;
2496 2493
2497 STATIC_ASSERT(kHeaderSize == Internals::kJSObjectHeaderSize); 2494 STATIC_ASSERT(kHeaderSize == Internals::kJSObjectHeaderSize);
2498 2495
2499 typedef FlexibleBodyDescriptor<JSReceiver::kPropertiesOffset> BodyDescriptor; 2496 typedef FlexibleBodyDescriptor<JSReceiver::kPropertiesOffset> BodyDescriptor;
2500 2497
2501 // Enqueue change record for Object.observe. May cause GC.
2502 MUST_USE_RESULT static MaybeHandle<Object> EnqueueChangeRecord(
2503 Handle<JSObject> object, const char* type, Handle<Name> name,
2504 Handle<Object> old_value);
2505
2506 // Gets the number of currently used elements. 2498 // Gets the number of currently used elements.
2507 int GetFastElementsUsage(); 2499 int GetFastElementsUsage();
2508 2500
2509 static bool AllCanRead(LookupIterator* it); 2501 static bool AllCanRead(LookupIterator* it);
2510 static bool AllCanWrite(LookupIterator* it); 2502 static bool AllCanWrite(LookupIterator* it);
2511 2503
2512 private: 2504 private:
2513 friend class JSReceiver; 2505 friend class JSReceiver;
2514 friend class Object; 2506 friend class Object;
2515 2507
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 Handle<JSObject> object); 2544 Handle<JSObject> object);
2553 2545
2554 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSObject> object); 2546 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSObject> object);
2555 2547
2556 // Helper for fast versions of preventExtensions, seal, and freeze. 2548 // Helper for fast versions of preventExtensions, seal, and freeze.
2557 // attrs is one of NONE, SEALED, or FROZEN (depending on the operation). 2549 // attrs is one of NONE, SEALED, or FROZEN (depending on the operation).
2558 template <PropertyAttributes attrs> 2550 template <PropertyAttributes attrs>
2559 MUST_USE_RESULT static Maybe<bool> PreventExtensionsWithTransition( 2551 MUST_USE_RESULT static Maybe<bool> PreventExtensionsWithTransition(
2560 Handle<JSObject> object, ShouldThrow should_throw); 2552 Handle<JSObject> object, ShouldThrow should_throw);
2561 2553
2562 MUST_USE_RESULT static Maybe<bool> SetPrototypeUnobserved(
2563 Handle<JSObject> object, Handle<Object> value, bool from_javascript,
2564 ShouldThrow should_throw);
2565
2566 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); 2554 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject);
2567 }; 2555 };
2568 2556
2569 2557
2570 // JSAccessorPropertyDescriptor is just a JSObject with a specific initial 2558 // JSAccessorPropertyDescriptor is just a JSObject with a specific initial
2571 // map. This initial map adds in-object properties for "get", "set", 2559 // map. This initial map adds in-object properties for "get", "set",
2572 // "enumerable" and "configurable" properties, as assigned by the 2560 // "enumerable" and "configurable" properties, as assigned by the
2573 // FromPropertyDescriptor function for regular accessor properties. 2561 // FromPropertyDescriptor function for regular accessor properties.
2574 class JSAccessorPropertyDescriptor: public JSObject { 2562 class JSAccessorPropertyDescriptor: public JSObject {
2575 public: 2563 public:
(...skipping 3150 matching lines...) Expand 10 before | Expand all | Expand 10 after
5726 5714
5727 // Tells whether the instance is undetectable. 5715 // Tells whether the instance is undetectable.
5728 // An undetectable object is a special class of JSObject: 'typeof' operator 5716 // An undetectable object is a special class of JSObject: 'typeof' operator
5729 // returns undefined, ToBoolean returns false. Otherwise it behaves like 5717 // returns undefined, ToBoolean returns false. Otherwise it behaves like
5730 // a normal JS object. It is useful for implementing undetectable 5718 // a normal JS object. It is useful for implementing undetectable
5731 // document.all in Firefox & Safari. 5719 // document.all in Firefox & Safari.
5732 // See https://bugzilla.mozilla.org/show_bug.cgi?id=248549. 5720 // See https://bugzilla.mozilla.org/show_bug.cgi?id=248549.
5733 inline void set_is_undetectable(); 5721 inline void set_is_undetectable();
5734 inline bool is_undetectable(); 5722 inline bool is_undetectable();
5735 5723
5736 // Tells whether the instance has a call-as-function handler.
5737 inline void set_is_observed();
5738 inline bool is_observed();
5739
5740 // Tells whether the instance has a [[Call]] internal method. 5724 // Tells whether the instance has a [[Call]] internal method.
5741 // This property is implemented according to ES6, section 7.2.3. 5725 // This property is implemented according to ES6, section 7.2.3.
5742 inline void set_is_callable(); 5726 inline void set_is_callable();
5743 inline bool is_callable() const; 5727 inline bool is_callable() const;
5744 5728
5745 inline void set_new_target_is_base(bool value); 5729 inline void set_new_target_is_base(bool value);
5746 inline bool new_target_is_base(); 5730 inline bool new_target_is_base();
5747 inline void set_is_extensible(bool value); 5731 inline void set_is_extensible(bool value);
5748 inline bool is_extensible(); 5732 inline bool is_extensible();
5749 inline void set_is_prototype_map(bool value); 5733 inline void set_is_prototype_map(bool value);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
5968 5952
5969 static Handle<Map> CopyAsElementsKind(Handle<Map> map, 5953 static Handle<Map> CopyAsElementsKind(Handle<Map> map,
5970 ElementsKind kind, 5954 ElementsKind kind,
5971 TransitionFlag flag); 5955 TransitionFlag flag);
5972 5956
5973 static Handle<Map> AsLanguageMode(Handle<Map> initial_map, 5957 static Handle<Map> AsLanguageMode(Handle<Map> initial_map,
5974 LanguageMode language_mode, 5958 LanguageMode language_mode,
5975 FunctionKind kind); 5959 FunctionKind kind);
5976 5960
5977 5961
5978 static Handle<Map> CopyForObserved(Handle<Map> map);
5979
5980 static Handle<Map> CopyForPreventExtensions(Handle<Map> map, 5962 static Handle<Map> CopyForPreventExtensions(Handle<Map> map,
5981 PropertyAttributes attrs_to_add, 5963 PropertyAttributes attrs_to_add,
5982 Handle<Symbol> transition_marker, 5964 Handle<Symbol> transition_marker,
5983 const char* reason); 5965 const char* reason);
5984 5966
5985 static Handle<Map> FixProxy(Handle<Map> map, InstanceType type, int size); 5967 static Handle<Map> FixProxy(Handle<Map> map, InstanceType type, int size);
5986 5968
5987 5969
5988 // Maximal number of fast properties. Used to restrict the number of map 5970 // Maximal number of fast properties. Used to restrict the number of map
5989 // transitions to avoid an explosion in the number of maps for objects used as 5971 // transitions to avoid an explosion in the number of maps for objects used as
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
6165 6147
6166 STATIC_ASSERT(kInstanceTypeAndBitFieldOffset == 6148 STATIC_ASSERT(kInstanceTypeAndBitFieldOffset ==
6167 Internals::kMapInstanceTypeAndBitFieldOffset); 6149 Internals::kMapInstanceTypeAndBitFieldOffset);
6168 6150
6169 // Bit positions for bit field. 6151 // Bit positions for bit field.
6170 static const int kHasNonInstancePrototype = 0; 6152 static const int kHasNonInstancePrototype = 0;
6171 static const int kIsCallable = 1; 6153 static const int kIsCallable = 1;
6172 static const int kHasNamedInterceptor = 2; 6154 static const int kHasNamedInterceptor = 2;
6173 static const int kHasIndexedInterceptor = 3; 6155 static const int kHasIndexedInterceptor = 3;
6174 static const int kIsUndetectable = 4; 6156 static const int kIsUndetectable = 4;
6175 static const int kIsObserved = 5; 6157 static const int kIsAccessCheckNeeded = 5;
6176 static const int kIsAccessCheckNeeded = 6; 6158 static const int kIsConstructor = 6;
6177 static const int kIsConstructor = 7; 6159 // Bit 7 is free.
6178 6160
6179 // Bit positions for bit field 2 6161 // Bit positions for bit field 2
6180 static const int kIsExtensible = 0; 6162 static const int kIsExtensible = 0;
6181 // Bit 1 is free. 6163 // Bit 1 is free.
6182 class IsPrototypeMapBits : public BitField<bool, 2, 1> {}; 6164 class IsPrototypeMapBits : public BitField<bool, 2, 1> {};
6183 class ElementsKindBits: public BitField<ElementsKind, 3, 5> {}; 6165 class ElementsKindBits: public BitField<ElementsKind, 3, 5> {};
6184 6166
6185 // Derived values from bit field 2 6167 // Derived values from bit field 2
6186 static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>( 6168 static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>(
6187 (FAST_ELEMENTS + 1) << Map::ElementsKindBits::kShift) - 1; 6169 (FAST_ELEMENTS + 1) << Map::ElementsKindBits::kShift) - 1;
(...skipping 3972 matching lines...) Expand 10 before | Expand all | Expand 10 after
10160 10142
10161 // If the JSArray has fast elements, and new_length would result in 10143 // If the JSArray has fast elements, and new_length would result in
10162 // normalization, returns true. 10144 // normalization, returns true.
10163 bool SetLengthWouldNormalize(uint32_t new_length); 10145 bool SetLengthWouldNormalize(uint32_t new_length);
10164 static inline bool SetLengthWouldNormalize(Heap* heap, uint32_t new_length); 10146 static inline bool SetLengthWouldNormalize(Heap* heap, uint32_t new_length);
10165 10147
10166 // Initializes the array to a certain length. 10148 // Initializes the array to a certain length.
10167 inline bool AllowsSetLength(); 10149 inline bool AllowsSetLength();
10168 10150
10169 static void SetLength(Handle<JSArray> array, uint32_t length); 10151 static void SetLength(Handle<JSArray> array, uint32_t length);
10170 // Same as above but will also queue splice records if |array| is observed.
10171 static MaybeHandle<Object> ObservableSetLength(Handle<JSArray> array,
10172 uint32_t length);
10173 10152
10174 // Set the content of the array to the content of storage. 10153 // Set the content of the array to the content of storage.
10175 static inline void SetContent(Handle<JSArray> array, 10154 static inline void SetContent(Handle<JSArray> array,
10176 Handle<FixedArrayBase> storage); 10155 Handle<FixedArrayBase> storage);
10177 10156
10178 // ES6 9.4.2.1 10157 // ES6 9.4.2.1
10179 MUST_USE_RESULT static Maybe<bool> DefineOwnProperty( 10158 MUST_USE_RESULT static Maybe<bool> DefineOwnProperty(
10180 Isolate* isolate, Handle<JSArray> o, Handle<Object> name, 10159 Isolate* isolate, Handle<JSArray> o, Handle<Object> name,
10181 PropertyDescriptor* desc, ShouldThrow should_throw); 10160 PropertyDescriptor* desc, ShouldThrow should_throw);
10182 10161
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
10797 } 10776 }
10798 return value; 10777 return value;
10799 } 10778 }
10800 }; 10779 };
10801 10780
10802 10781
10803 } // NOLINT, false-positive due to second-order macros. 10782 } // NOLINT, false-positive due to second-order macros.
10804 } // NOLINT, false-positive due to second-order macros. 10783 } // NOLINT, false-positive due to second-order macros.
10805 10784
10806 #endif // V8_OBJECTS_H_ 10785 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698