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

Side by Side Diff: src/objects.h

Issue 1316933002: [es6] Initial steps towards a correct implementation of IsCallable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: ia32, arm and arm64 ports. Misc cleanups. Created 5 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
OLDNEW
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 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 INLINE(bool IsFixedArrayBase() const); 999 INLINE(bool IsFixedArrayBase() const);
1000 INLINE(bool IsExternal() const); 1000 INLINE(bool IsExternal() const);
1001 INLINE(bool IsAccessorInfo() const); 1001 INLINE(bool IsAccessorInfo() const);
1002 1002
1003 INLINE(bool IsStruct() const); 1003 INLINE(bool IsStruct() const);
1004 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ 1004 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
1005 INLINE(bool Is##Name() const); 1005 INLINE(bool Is##Name() const);
1006 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) 1006 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
1007 #undef DECLARE_STRUCT_PREDICATE 1007 #undef DECLARE_STRUCT_PREDICATE
1008 1008
1009 // ES6, section 7.2.3 IsCallable.
1010 INLINE(bool IsCallable() const);
1011
1009 INLINE(bool IsSpecObject()) const; 1012 INLINE(bool IsSpecObject()) const;
1013 // TODO(rossberg): IsSpecFunction should be removed in favor of IsCallable.
1010 INLINE(bool IsSpecFunction()) const; 1014 INLINE(bool IsSpecFunction()) const;
1011 INLINE(bool IsTemplateInfo()) const; 1015 INLINE(bool IsTemplateInfo()) const;
1012 INLINE(bool IsNameDictionary() const); 1016 INLINE(bool IsNameDictionary() const);
1013 INLINE(bool IsGlobalDictionary() const); 1017 INLINE(bool IsGlobalDictionary() const);
1014 INLINE(bool IsSeededNumberDictionary() const); 1018 INLINE(bool IsSeededNumberDictionary() const);
1015 INLINE(bool IsUnseededNumberDictionary() const); 1019 INLINE(bool IsUnseededNumberDictionary() const);
1016 INLINE(bool IsOrderedHashSet() const); 1020 INLINE(bool IsOrderedHashSet() const);
1017 INLINE(bool IsOrderedHashMap() const); 1021 INLINE(bool IsOrderedHashMap() const);
1018 bool IsCallable() const;
1019 static bool IsPromise(Handle<Object> object); 1022 static bool IsPromise(Handle<Object> object);
1020 1023
1021 // Oddball testing. 1024 // Oddball testing.
1022 INLINE(bool IsUndefined() const); 1025 INLINE(bool IsUndefined() const);
1023 INLINE(bool IsNull() const); 1026 INLINE(bool IsNull() const);
1024 INLINE(bool IsTheHole() const); 1027 INLINE(bool IsTheHole() const);
1025 INLINE(bool IsException() const); 1028 INLINE(bool IsException() const);
1026 INLINE(bool IsUninitialized() const); 1029 INLINE(bool IsUninitialized() const);
1027 INLINE(bool IsTrue() const); 1030 INLINE(bool IsTrue() const);
1028 INLINE(bool IsFalse() const); 1031 INLINE(bool IsFalse() const);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 bool StrictEquals(Object* that); 1074 bool StrictEquals(Object* that);
1072 1075
1073 // Convert to a JSObject if needed. 1076 // Convert to a JSObject if needed.
1074 // native_context is used when creating wrapper object. 1077 // native_context is used when creating wrapper object.
1075 static inline MaybeHandle<JSReceiver> ToObject(Isolate* isolate, 1078 static inline MaybeHandle<JSReceiver> ToObject(Isolate* isolate,
1076 Handle<Object> object); 1079 Handle<Object> object);
1077 static MaybeHandle<JSReceiver> ToObject(Isolate* isolate, 1080 static MaybeHandle<JSReceiver> ToObject(Isolate* isolate,
1078 Handle<Object> object, 1081 Handle<Object> object,
1079 Handle<Context> context); 1082 Handle<Context> context);
1080 1083
1084 // ES6 section 12.5.6 The typeof Operator
1085 static Handle<String> TypeOf(Isolate* isolate, Handle<Object> object);
1086
1081 MUST_USE_RESULT static MaybeHandle<Object> GetProperty( 1087 MUST_USE_RESULT static MaybeHandle<Object> GetProperty(
1082 LookupIterator* it, LanguageMode language_mode = SLOPPY); 1088 LookupIterator* it, LanguageMode language_mode = SLOPPY);
1083 1089
1084 // Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5. 1090 // Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5.
1085 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( 1091 MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
1086 Handle<Object> object, Handle<Name> name, Handle<Object> value, 1092 Handle<Object> object, Handle<Name> name, Handle<Object> value,
1087 LanguageMode language_mode, 1093 LanguageMode language_mode,
1088 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); 1094 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
1089 1095
1090 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( 1096 MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
(...skipping 4088 matching lines...) Expand 10 before | Expand all | Expand 10 after
5179 inline uint32_t bit_field3() const; 5185 inline uint32_t bit_field3() const;
5180 inline void set_bit_field3(uint32_t bits); 5186 inline void set_bit_field3(uint32_t bits);
5181 5187
5182 class EnumLengthBits: public BitField<int, 5188 class EnumLengthBits: public BitField<int,
5183 0, kDescriptorIndexBitCount> {}; // NOLINT 5189 0, kDescriptorIndexBitCount> {}; // NOLINT
5184 class NumberOfOwnDescriptorsBits: public BitField<int, 5190 class NumberOfOwnDescriptorsBits: public BitField<int,
5185 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT 5191 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT
5186 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); 5192 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20);
5187 class DictionaryMap : public BitField<bool, 20, 1> {}; 5193 class DictionaryMap : public BitField<bool, 20, 1> {};
5188 class OwnsDescriptors : public BitField<bool, 21, 1> {}; 5194 class OwnsDescriptors : public BitField<bool, 21, 1> {};
5189 class HasInstanceCallHandler : public BitField<bool, 22, 1> {}; 5195 class IsHiddenPrototype : public BitField<bool, 22, 1> {};
5190 class Deprecated : public BitField<bool, 23, 1> {}; 5196 class Deprecated : public BitField<bool, 23, 1> {};
5191 class IsUnstable : public BitField<bool, 24, 1> {}; 5197 class IsUnstable : public BitField<bool, 24, 1> {};
5192 class IsMigrationTarget : public BitField<bool, 25, 1> {}; 5198 class IsMigrationTarget : public BitField<bool, 25, 1> {};
5193 class IsStrong : public BitField<bool, 26, 1> {}; 5199 class IsStrong : public BitField<bool, 26, 1> {};
5194 // Bit 27 is free. 5200 // Bit 27 is free.
5195 5201
5196 // Keep this bit field at the very end for better code in 5202 // Keep this bit field at the very end for better code in
5197 // Builtins::kJSConstructStubGeneric stub. 5203 // Builtins::kJSConstructStubGeneric stub.
5198 // This counter is used for in-object slack tracking and for map aging. 5204 // This counter is used for in-object slack tracking and for map aging.
5199 // The in-object slack tracking is considered enabled when the counter is 5205 // The in-object slack tracking is considered enabled when the counter is
(...skipping 14 matching lines...) Expand all
5214 5220
5215 // Tells whether function has special prototype property. If not, prototype 5221 // Tells whether function has special prototype property. If not, prototype
5216 // property will not be created when accessed (will return undefined), 5222 // property will not be created when accessed (will return undefined),
5217 // and construction from this function will not be allowed. 5223 // and construction from this function will not be allowed.
5218 inline void set_function_with_prototype(bool value); 5224 inline void set_function_with_prototype(bool value);
5219 inline bool function_with_prototype(); 5225 inline bool function_with_prototype();
5220 5226
5221 // Tells whether the instance with this map should be ignored by the 5227 // Tells whether the instance with this map should be ignored by the
5222 // Object.getPrototypeOf() function and the __proto__ accessor. 5228 // Object.getPrototypeOf() function and the __proto__ accessor.
5223 inline void set_is_hidden_prototype(); 5229 inline void set_is_hidden_prototype();
5224 inline bool is_hidden_prototype(); 5230 inline bool is_hidden_prototype() const;
5225 5231
5226 // Records and queries whether the instance has a named interceptor. 5232 // Records and queries whether the instance has a named interceptor.
5227 inline void set_has_named_interceptor(); 5233 inline void set_has_named_interceptor();
5228 inline bool has_named_interceptor(); 5234 inline bool has_named_interceptor();
5229 5235
5230 // Records and queries whether the instance has an indexed interceptor. 5236 // Records and queries whether the instance has an indexed interceptor.
5231 inline void set_has_indexed_interceptor(); 5237 inline void set_has_indexed_interceptor();
5232 inline bool has_indexed_interceptor(); 5238 inline bool has_indexed_interceptor();
5233 5239
5234 // Tells whether the instance is undetectable. 5240 // Tells whether the instance is undetectable.
5235 // An undetectable object is a special class of JSObject: 'typeof' operator 5241 // An undetectable object is a special class of JSObject: 'typeof' operator
5236 // returns undefined, ToBoolean returns false. Otherwise it behaves like 5242 // returns undefined, ToBoolean returns false. Otherwise it behaves like
5237 // a normal JS object. It is useful for implementing undetectable 5243 // a normal JS object. It is useful for implementing undetectable
5238 // document.all in Firefox & Safari. 5244 // document.all in Firefox & Safari.
5239 // See https://bugzilla.mozilla.org/show_bug.cgi?id=248549. 5245 // See https://bugzilla.mozilla.org/show_bug.cgi?id=248549.
5240 inline void set_is_undetectable(); 5246 inline void set_is_undetectable();
5241 inline bool is_undetectable(); 5247 inline bool is_undetectable();
5242 5248
5243 // Tells whether the instance has a call-as-function handler. 5249 // Tells whether the instance has a call-as-function handler.
5244 inline void set_is_observed(); 5250 inline void set_is_observed();
5245 inline bool is_observed(); 5251 inline bool is_observed();
5246 5252
5253 // Tells whether the instance has a [[Call]] internal field.
5254 // This property is implemented according to ES6, section 7.2.3.
5255 inline void set_is_callable();
5256 inline bool is_callable() const;
5257
5247 inline void set_is_strong(); 5258 inline void set_is_strong();
5248 inline bool is_strong(); 5259 inline bool is_strong();
5249 inline void set_is_extensible(bool value); 5260 inline void set_is_extensible(bool value);
5250 inline bool is_extensible(); 5261 inline bool is_extensible();
5251 inline void set_is_prototype_map(bool value); 5262 inline void set_is_prototype_map(bool value);
5252 inline bool is_prototype_map() const; 5263 inline bool is_prototype_map() const;
5253 5264
5254 inline void set_elements_kind(ElementsKind elements_kind); 5265 inline void set_elements_kind(ElementsKind elements_kind);
5255 inline ElementsKind elements_kind(); 5266 inline ElementsKind elements_kind();
5256 5267
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
5412 inline int NumberOfOwnDescriptors(); 5423 inline int NumberOfOwnDescriptors();
5413 inline void SetNumberOfOwnDescriptors(int number); 5424 inline void SetNumberOfOwnDescriptors(int number);
5414 5425
5415 inline Cell* RetrieveDescriptorsPointer(); 5426 inline Cell* RetrieveDescriptorsPointer();
5416 5427
5417 inline int EnumLength(); 5428 inline int EnumLength();
5418 inline void SetEnumLength(int length); 5429 inline void SetEnumLength(int length);
5419 5430
5420 inline bool owns_descriptors(); 5431 inline bool owns_descriptors();
5421 inline void set_owns_descriptors(bool owns_descriptors); 5432 inline void set_owns_descriptors(bool owns_descriptors);
5422 inline bool has_instance_call_handler();
5423 inline void set_has_instance_call_handler();
5424 inline void mark_unstable(); 5433 inline void mark_unstable();
5425 inline bool is_stable(); 5434 inline bool is_stable();
5426 inline void set_migration_target(bool value); 5435 inline void set_migration_target(bool value);
5427 inline bool is_migration_target(); 5436 inline bool is_migration_target();
5428 inline void set_counter(int value); 5437 inline void set_counter(int value);
5429 inline int counter(); 5438 inline int counter();
5430 inline void deprecate(); 5439 inline void deprecate();
5431 inline bool is_deprecated(); 5440 inline bool is_deprecated();
5432 inline bool CanBeDeprecated(); 5441 inline bool CanBeDeprecated();
5433 // Returns a non-deprecated version of the input. If the input was not 5442 // Returns a non-deprecated version of the input. If the input was not
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
5662 kInstanceAttributesOffset + 0; 5671 kInstanceAttributesOffset + 0;
5663 static const int kBitField2Offset = kInstanceAttributesOffset + 2; 5672 static const int kBitField2Offset = kInstanceAttributesOffset + 2;
5664 static const int kUnusedPropertyFieldsByte = 3; 5673 static const int kUnusedPropertyFieldsByte = 3;
5665 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 3; 5674 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 3;
5666 5675
5667 STATIC_ASSERT(kInstanceTypeAndBitFieldOffset == 5676 STATIC_ASSERT(kInstanceTypeAndBitFieldOffset ==
5668 Internals::kMapInstanceTypeAndBitFieldOffset); 5677 Internals::kMapInstanceTypeAndBitFieldOffset);
5669 5678
5670 // Bit positions for bit field. 5679 // Bit positions for bit field.
5671 static const int kHasNonInstancePrototype = 0; 5680 static const int kHasNonInstancePrototype = 0;
5672 static const int kIsHiddenPrototype = 1; 5681 static const int kIsCallable = 1;
5673 static const int kHasNamedInterceptor = 2; 5682 static const int kHasNamedInterceptor = 2;
5674 static const int kHasIndexedInterceptor = 3; 5683 static const int kHasIndexedInterceptor = 3;
5675 static const int kIsUndetectable = 4; 5684 static const int kIsUndetectable = 4;
5676 static const int kIsObserved = 5; 5685 static const int kIsObserved = 5;
5677 static const int kIsAccessCheckNeeded = 6; 5686 static const int kIsAccessCheckNeeded = 6;
5678 class FunctionWithPrototype: public BitField<bool, 7, 1> {}; 5687 class FunctionWithPrototype: public BitField<bool, 7, 1> {};
5679 5688
5680 // Bit positions for bit field 2 5689 // Bit positions for bit field 2
5681 static const int kIsExtensible = 0; 5690 static const int kIsExtensible = 0;
5682 static const int kStringWrapperSafeForDefaultValueOf = 1; 5691 static const int kStringWrapperSafeForDefaultValueOf = 1;
(...skipping 3564 matching lines...) Expand 10 before | Expand all | Expand 10 after
9247 9256
9248 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); 9257 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy);
9249 9258
9250 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); 9259 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy);
9251 }; 9260 };
9252 9261
9253 9262
9254 class JSFunctionProxy: public JSProxy { 9263 class JSFunctionProxy: public JSProxy {
9255 public: 9264 public:
9256 // [call_trap]: The call trap. 9265 // [call_trap]: The call trap.
9257 DECL_ACCESSORS(call_trap, Object) 9266 DECL_ACCESSORS(call_trap, JSReceiver)
9258 9267
9259 // [construct_trap]: The construct trap. 9268 // [construct_trap]: The construct trap.
9260 DECL_ACCESSORS(construct_trap, Object) 9269 DECL_ACCESSORS(construct_trap, Object)
9261 9270
9262 DECLARE_CAST(JSFunctionProxy) 9271 DECLARE_CAST(JSFunctionProxy)
9263 9272
9264 // Dispatched behavior. 9273 // Dispatched behavior.
9265 DECLARE_PRINTER(JSFunctionProxy) 9274 DECLARE_PRINTER(JSFunctionProxy)
9266 DECLARE_VERIFIER(JSFunctionProxy) 9275 DECLARE_VERIFIER(JSFunctionProxy)
9267 9276
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
10335 } else { 10344 } else {
10336 value &= ~(1 << bit_position); 10345 value &= ~(1 << bit_position);
10337 } 10346 }
10338 return value; 10347 return value;
10339 } 10348 }
10340 }; 10349 };
10341 10350
10342 } } // namespace v8::internal 10351 } } // namespace v8::internal
10343 10352
10344 #endif // V8_OBJECTS_H_ 10353 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698