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

Side by Side Diff: src/objects.h

Issue 7623011: Implement function proxies (except for their use as constructors). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed second round of comments. Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/messages.js ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 4700 matching lines...) Expand 10 before | Expand all | Expand 10 after
4711 // Indicates whether the function is a strict mode function. 4711 // Indicates whether the function is a strict mode function.
4712 DECL_BOOLEAN_ACCESSORS(strict_mode) 4712 DECL_BOOLEAN_ACCESSORS(strict_mode)
4713 4713
4714 // False if the function definitely does not allocate an arguments object. 4714 // False if the function definitely does not allocate an arguments object.
4715 DECL_BOOLEAN_ACCESSORS(uses_arguments) 4715 DECL_BOOLEAN_ACCESSORS(uses_arguments)
4716 4716
4717 // True if the function has any duplicated parameter names. 4717 // True if the function has any duplicated parameter names.
4718 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters) 4718 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters)
4719 4719
4720 // Indicates whether the function is a native function. 4720 // Indicates whether the function is a native function.
4721 // These needs special threatment in .call and .apply since 4721 // These needs special treatment in .call and .apply since
4722 // null passed as the receiver should not be translated to the 4722 // null passed as the receiver should not be translated to the
4723 // global object. 4723 // global object.
4724 DECL_BOOLEAN_ACCESSORS(native) 4724 DECL_BOOLEAN_ACCESSORS(native)
4725 4725
4726 // Indicates that the function was created by the Function function. 4726 // Indicates that the function was created by the Function function.
4727 // Though it's anonymous, toString should treat it as if it had the name 4727 // Though it's anonymous, toString should treat it as if it had the name
4728 // "anonymous". We don't set the name itself so that the system does not 4728 // "anonymous". We don't set the name itself so that the system does not
4729 // see a binding for it. 4729 // see a binding for it.
4730 DECL_BOOLEAN_ACCESSORS(name_should_print_as_anonymous) 4730 DECL_BOOLEAN_ACCESSORS(name_should_print_as_anonymous)
4731 4731
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
4978 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); 4978 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo);
4979 }; 4979 };
4980 4980
4981 4981
4982 // JSFunction describes JavaScript functions. 4982 // JSFunction describes JavaScript functions.
4983 class JSFunction: public JSObject { 4983 class JSFunction: public JSObject {
4984 public: 4984 public:
4985 // [prototype_or_initial_map]: 4985 // [prototype_or_initial_map]:
4986 DECL_ACCESSORS(prototype_or_initial_map, Object) 4986 DECL_ACCESSORS(prototype_or_initial_map, Object)
4987 4987
4988 // [shared_function_info]: The information about the function that 4988 // [shared]: The information about the function that
4989 // can be shared by instances. 4989 // can be shared by instances.
4990 DECL_ACCESSORS(shared, SharedFunctionInfo) 4990 DECL_ACCESSORS(shared, SharedFunctionInfo)
4991 4991
4992 inline SharedFunctionInfo* unchecked_shared(); 4992 inline SharedFunctionInfo* unchecked_shared();
4993 4993
4994 // [context]: The context for this function. 4994 // [context]: The context for this function.
4995 inline Context* context(); 4995 inline Context* context();
4996 inline Object* unchecked_context(); 4996 inline Object* unchecked_context();
4997 inline void set_context(Object* context); 4997 inline void set_context(Object* context);
4998 4998
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after
6577 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); 6577 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell);
6578 }; 6578 };
6579 6579
6580 6580
6581 // The JSProxy describes EcmaScript Harmony proxies 6581 // The JSProxy describes EcmaScript Harmony proxies
6582 class JSProxy: public JSReceiver { 6582 class JSProxy: public JSReceiver {
6583 public: 6583 public:
6584 // [handler]: The handler property. 6584 // [handler]: The handler property.
6585 DECL_ACCESSORS(handler, Object) 6585 DECL_ACCESSORS(handler, Object)
6586 6586
6587 // [padding]: The padding slot (unused, see below).
6588 DECL_ACCESSORS(padding, Object)
6589
6590 // Casting. 6587 // Casting.
6591 static inline JSProxy* cast(Object* obj); 6588 static inline JSProxy* cast(Object* obj);
6592 6589
6593 bool HasPropertyWithHandler(String* name); 6590 bool HasPropertyWithHandler(String* name);
6594 6591
6595 MUST_USE_RESULT MaybeObject* SetPropertyWithHandler( 6592 MUST_USE_RESULT MaybeObject* SetPropertyWithHandler(
6596 String* name, 6593 String* name,
6597 Object* value, 6594 Object* value,
6598 PropertyAttributes attributes, 6595 PropertyAttributes attributes,
6599 StrictModeFlag strict_mode); 6596 StrictModeFlag strict_mode);
6600 6597
6601 MUST_USE_RESULT MaybeObject* DeletePropertyWithHandler( 6598 MUST_USE_RESULT MaybeObject* DeletePropertyWithHandler(
6602 String* name, 6599 String* name,
6603 DeleteMode mode); 6600 DeleteMode mode);
6604 6601
6605 MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler( 6602 MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler(
6606 JSReceiver* receiver, 6603 JSReceiver* receiver,
6607 String* name, 6604 String* name,
6608 bool* has_exception); 6605 bool* has_exception);
6609 6606
6610 // Turn this into an (empty) JSObject. 6607 // Turn this into an (empty) JSObject.
6611 void Fix(); 6608 void Fix();
6612 6609
6610 // Initializes the body after the handler slot.
6611 inline void InitializeBody(int object_size, Object* value);
6612
6613 // Dispatched behavior. 6613 // Dispatched behavior.
6614 #ifdef OBJECT_PRINT 6614 #ifdef OBJECT_PRINT
6615 inline void JSProxyPrint() { 6615 inline void JSProxyPrint() {
6616 JSProxyPrint(stdout); 6616 JSProxyPrint(stdout);
6617 } 6617 }
6618 void JSProxyPrint(FILE* out); 6618 void JSProxyPrint(FILE* out);
6619 #endif 6619 #endif
6620 #ifdef DEBUG 6620 #ifdef DEBUG
6621 void JSProxyVerify(); 6621 void JSProxyVerify();
6622 #endif 6622 #endif
6623 6623
6624 // Layout description. We add padding so that a proxy has the same 6624 // Layout description. We add padding so that a proxy has the same
6625 // size as a virgin JSObject. This is essential for becoming a JSObject 6625 // size as a virgin JSObject. This is essential for becoming a JSObject
6626 // upon freeze. 6626 // upon freeze.
6627 static const int kHandlerOffset = HeapObject::kHeaderSize; 6627 static const int kHandlerOffset = HeapObject::kHeaderSize;
6628 static const int kPaddingOffset = kHandlerOffset + kPointerSize; 6628 static const int kPaddingOffset = kHandlerOffset + kPointerSize;
6629 static const int kSize = kPaddingOffset + kPointerSize; 6629 static const int kSize = JSObject::kHeaderSize;
6630 static const int kHeaderSize = kPaddingOffset;
6631 static const int kPaddingSize = kSize - kPaddingOffset;
6630 6632
6631 STATIC_CHECK(kSize == JSObject::kHeaderSize); 6633 STATIC_CHECK(kPaddingSize >= 0);
6632 6634
6633 typedef FixedBodyDescriptor<kHandlerOffset, 6635 typedef FixedBodyDescriptor<kHandlerOffset,
6634 kHandlerOffset + kPointerSize, 6636 kHandlerOffset + kPointerSize,
6635 kSize> BodyDescriptor; 6637 kSize> BodyDescriptor;
6636 6638
6637 private: 6639 private:
6638 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); 6640 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy);
6639 }; 6641 };
6640 6642
6641 6643
6642 // TODO(rossberg): Only a stub for now.
6643 class JSFunctionProxy: public JSProxy { 6644 class JSFunctionProxy: public JSProxy {
6644 public: 6645 public:
6646 // [call_trap]: The call trap.
6647 DECL_ACCESSORS(call_trap, Object)
6648
6649 // [construct_trap]: The construct trap.
6650 DECL_ACCESSORS(construct_trap, Object)
6651
6645 // Casting. 6652 // Casting.
6646 static inline JSFunctionProxy* cast(Object* obj); 6653 static inline JSFunctionProxy* cast(Object* obj);
6647 6654
6655 // Dispatched behavior.
6656 #ifdef OBJECT_PRINT
6657 inline void JSFunctionProxyPrint() {
6658 JSFunctionProxyPrint(stdout);
6659 }
6660 void JSFunctionProxyPrint(FILE* out);
6661 #endif
6662 #ifdef DEBUG
6663 void JSFunctionProxyVerify();
6664 #endif
6665
6666 // Layout description.
6667 static const int kCallTrapOffset = kHandlerOffset + kPointerSize;
6668 static const int kConstructTrapOffset = kCallTrapOffset + kPointerSize;
6669 static const int kPaddingOffset = kConstructTrapOffset + kPointerSize;
6670 static const int kSize = JSFunction::kSize;
6671 static const int kPaddingSize = kSize - kPaddingOffset;
6672
6673 STATIC_CHECK(kPaddingSize >= 0);
6674
6675 typedef FixedBodyDescriptor<kHandlerOffset,
6676 kConstructTrapOffset + kPointerSize,
6677 kSize> BodyDescriptor;
6678
6648 private: 6679 private:
6649 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy); 6680 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy);
6650 }; 6681 };
6651 6682
6652 6683
6653 // The JSWeakMap describes EcmaScript Harmony weak maps 6684 // The JSWeakMap describes EcmaScript Harmony weak maps
6654 class JSWeakMap: public JSObject { 6685 class JSWeakMap: public JSObject {
6655 public: 6686 public:
6656 // [table]: the backing hash table mapping keys to values. 6687 // [table]: the backing hash table mapping keys to values.
6657 DECL_ACCESSORS(table, ObjectHashTable) 6688 DECL_ACCESSORS(table, ObjectHashTable)
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
7320 } else { 7351 } else {
7321 value &= ~(1 << bit_position); 7352 value &= ~(1 << bit_position);
7322 } 7353 }
7323 return value; 7354 return value;
7324 } 7355 }
7325 }; 7356 };
7326 7357
7327 } } // namespace v8::internal 7358 } } // namespace v8::internal
7328 7359
7329 #endif // V8_OBJECTS_H_ 7360 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698