OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 9547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9558 typedef FixedBodyDescriptor<kValueOffset, kSize, kSize> BodyDescriptor; | 9558 typedef FixedBodyDescriptor<kValueOffset, kSize, kSize> BodyDescriptor; |
9559 | 9559 |
9560 private: | 9560 private: |
9561 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakCell); | 9561 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakCell); |
9562 }; | 9562 }; |
9563 | 9563 |
9564 | 9564 |
9565 // The JSProxy describes EcmaScript Harmony proxies | 9565 // The JSProxy describes EcmaScript Harmony proxies |
9566 class JSProxy: public JSReceiver { | 9566 class JSProxy: public JSReceiver { |
9567 public: | 9567 public: |
| 9568 // [target]: The target property. |
| 9569 DECL_ACCESSORS(target, Object) |
| 9570 |
9568 // [handler]: The handler property. | 9571 // [handler]: The handler property. |
9569 DECL_ACCESSORS(handler, Object) | 9572 DECL_ACCESSORS(handler, Object) |
9570 | 9573 |
9571 // [hash]: The hash code property (undefined if not initialized yet). | 9574 // [hash]: The hash code property (undefined if not initialized yet). |
9572 DECL_ACCESSORS(hash, Object) | 9575 DECL_ACCESSORS(hash, Object) |
9573 | 9576 |
9574 DECLARE_CAST(JSProxy) | 9577 DECLARE_CAST(JSProxy) |
9575 | 9578 |
9576 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( | 9579 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( |
9577 Handle<JSProxy> proxy, | 9580 Handle<JSProxy> proxy, |
(...skipping 11 matching lines...) Expand all Loading... |
9589 Handle<Object> value, ShouldThrow should_throw, bool* done); | 9592 Handle<Object> value, ShouldThrow should_throw, bool* done); |
9590 | 9593 |
9591 MUST_USE_RESULT static Maybe<PropertyAttributes> | 9594 MUST_USE_RESULT static Maybe<PropertyAttributes> |
9592 GetPropertyAttributesWithHandler(Handle<JSProxy> proxy, | 9595 GetPropertyAttributesWithHandler(Handle<JSProxy> proxy, |
9593 Handle<Object> receiver, | 9596 Handle<Object> receiver, |
9594 Handle<Name> name); | 9597 Handle<Name> name); |
9595 MUST_USE_RESULT static Maybe<bool> SetPropertyWithHandler( | 9598 MUST_USE_RESULT static Maybe<bool> SetPropertyWithHandler( |
9596 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, | 9599 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, |
9597 Handle<Object> value, ShouldThrow should_throw); | 9600 Handle<Object> value, ShouldThrow should_throw); |
9598 | 9601 |
9599 // Turn the proxy into an (empty) JSObject. | |
9600 static void Fix(Handle<JSProxy> proxy); | |
9601 | |
9602 // Initializes the body after the handler slot. | |
9603 inline void InitializeBody(int object_size, Object* value); | |
9604 | |
9605 // Invoke a trap by name. If the trap does not exist on this's handler, | |
9606 // but derived_trap is non-NULL, invoke that instead. May cause GC. | |
9607 MUST_USE_RESULT static MaybeHandle<Object> CallTrap( | |
9608 Handle<JSProxy> proxy, | |
9609 const char* name, | |
9610 Handle<Object> derived_trap, | |
9611 int argc, | |
9612 Handle<Object> args[]); | |
9613 | |
9614 // Dispatched behavior. | 9602 // Dispatched behavior. |
9615 DECLARE_PRINTER(JSProxy) | 9603 DECLARE_PRINTER(JSProxy) |
9616 DECLARE_VERIFIER(JSProxy) | 9604 DECLARE_VERIFIER(JSProxy) |
9617 | 9605 |
9618 // Layout description. We add padding so that a proxy has the same | 9606 // Layout description. We add padding so that a proxy has the same |
9619 // size as a virgin JSObject. This is essential for becoming a JSObject | 9607 // size as a virgin JSObject. This is essential for becoming a JSObject |
9620 // upon freeze. | 9608 // upon freeze. |
9621 static const int kHandlerOffset = HeapObject::kHeaderSize; | 9609 static const int kTargetOffset = HeapObject::kHeaderSize; |
| 9610 static const int kHandlerOffset = kTargetOffset + kPointerSize; |
9622 static const int kHashOffset = kHandlerOffset + kPointerSize; | 9611 static const int kHashOffset = kHandlerOffset + kPointerSize; |
9623 static const int kPaddingOffset = kHashOffset + kPointerSize; | 9612 static const int kSize = kHashOffset + kPointerSize; |
9624 static const int kSize = JSObject::kHeaderSize; | |
9625 static const int kHeaderSize = kPaddingOffset; | |
9626 static const int kPaddingSize = kSize - kPaddingOffset; | |
9627 | 9613 |
9628 STATIC_ASSERT(kPaddingSize >= 0); | 9614 typedef FixedBodyDescriptor<kTargetOffset, kSize, kSize> BodyDescriptor; |
9629 | |
9630 typedef FixedBodyDescriptor<kHandlerOffset, | |
9631 kPaddingOffset, | |
9632 kSize> BodyDescriptor; | |
9633 | 9615 |
9634 private: | 9616 private: |
9635 friend class JSReceiver; | 9617 friend class JSReceiver; |
9636 | 9618 |
| 9619 // Invoke a trap by name. If the trap does not exist on this's handler, |
| 9620 // but derived_trap is non-NULL, invoke that instead. May cause GC. |
| 9621 MUST_USE_RESULT static MaybeHandle<Object> CallTrap( |
| 9622 Handle<JSProxy> proxy, const char* name, Handle<Object> derived_trap, |
| 9623 int argc, Handle<Object> args[]); |
| 9624 |
9637 MUST_USE_RESULT static Maybe<bool> HasPropertyWithHandler( | 9625 MUST_USE_RESULT static Maybe<bool> HasPropertyWithHandler( |
9638 Handle<JSProxy> proxy, Handle<Name> name); | 9626 Handle<JSProxy> proxy, Handle<Name> name); |
9639 | 9627 |
9640 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( | 9628 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( |
9641 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); | 9629 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); |
9642 | 9630 |
9643 MUST_USE_RESULT Object* GetIdentityHash(); | 9631 MUST_USE_RESULT Object* GetIdentityHash(); |
9644 | 9632 |
9645 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); | 9633 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); |
9646 | 9634 |
9647 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); | 9635 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); |
9648 }; | 9636 }; |
9649 | 9637 |
9650 | 9638 |
9651 class JSFunctionProxy: public JSProxy { | 9639 class JSFunctionProxy: public JSProxy { |
9652 public: | 9640 public: |
9653 // [call_trap]: The call trap. | 9641 // [call_trap]: The call trap. |
9654 DECL_ACCESSORS(call_trap, JSReceiver) | 9642 DECL_ACCESSORS(call_trap, JSReceiver) |
9655 | 9643 |
9656 // [construct_trap]: The construct trap. | 9644 // [construct_trap]: The construct trap. |
9657 DECL_ACCESSORS(construct_trap, Object) | 9645 DECL_ACCESSORS(construct_trap, Object) |
9658 | 9646 |
9659 DECLARE_CAST(JSFunctionProxy) | 9647 DECLARE_CAST(JSFunctionProxy) |
9660 | 9648 |
9661 // Dispatched behavior. | 9649 // Dispatched behavior. |
9662 DECLARE_PRINTER(JSFunctionProxy) | 9650 DECLARE_PRINTER(JSFunctionProxy) |
9663 DECLARE_VERIFIER(JSFunctionProxy) | 9651 DECLARE_VERIFIER(JSFunctionProxy) |
9664 | 9652 |
9665 // Layout description. | 9653 // Layout description. |
9666 static const int kCallTrapOffset = JSProxy::kPaddingOffset; | 9654 static const int kCallTrapOffset = JSProxy::kSize; |
9667 static const int kConstructTrapOffset = kCallTrapOffset + kPointerSize; | 9655 static const int kConstructTrapOffset = kCallTrapOffset + kPointerSize; |
9668 static const int kPaddingOffset = kConstructTrapOffset + kPointerSize; | 9656 static const int kSize = kConstructTrapOffset + kPointerSize; |
9669 static const int kSize = JSFunction::kSize; | |
9670 static const int kPaddingSize = kSize - kPaddingOffset; | |
9671 | 9657 |
9672 STATIC_ASSERT(kPaddingSize >= 0); | 9658 typedef FixedBodyDescriptor<kTargetOffset, kSize, kSize> BodyDescriptor; |
9673 | |
9674 typedef FixedBodyDescriptor<kHandlerOffset, | |
9675 kConstructTrapOffset + kPointerSize, | |
9676 kSize> BodyDescriptor; | |
9677 | 9659 |
9678 private: | 9660 private: |
9679 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy); | 9661 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy); |
9680 }; | 9662 }; |
9681 | 9663 |
9682 | 9664 |
9683 class JSCollection : public JSObject { | 9665 class JSCollection : public JSObject { |
9684 public: | 9666 public: |
9685 // [table]: the backing hash table | 9667 // [table]: the backing hash table |
9686 DECL_ACCESSORS(table, Object) | 9668 DECL_ACCESSORS(table, Object) |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10788 } | 10770 } |
10789 return value; | 10771 return value; |
10790 } | 10772 } |
10791 }; | 10773 }; |
10792 | 10774 |
10793 | 10775 |
10794 } // NOLINT, false-positive due to second-order macros. | 10776 } // NOLINT, false-positive due to second-order macros. |
10795 } // NOLINT, false-positive due to second-order macros. | 10777 } // NOLINT, false-positive due to second-order macros. |
10796 | 10778 |
10797 #endif // V8_OBJECTS_H_ | 10779 #endif // V8_OBJECTS_H_ |
OLD | NEW |