diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2014-11-14 00:52:27 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2014-11-14 16:34:58 +0100 |
commit | 5d1b6d3e0fa4b97a490ef964be48aed9872e3ec1 (patch) | |
tree | ab5f510c4d83b175681de629395525bf7ec7cedb /deps/v8/src/objects.h | |
parent | 3b3d89bad26f5dfebe73fef6ae284ee78acbd5c9 (diff) | |
download | node-new-5d1b6d3e0fa4b97a490ef964be48aed9872e3ec1.tar.gz |
deps: upgrade v8 to 3.30.37
Diffstat (limited to 'deps/v8/src/objects.h')
-rw-r--r-- | deps/v8/src/objects.h | 369 |
1 files changed, 248 insertions, 121 deletions
diff --git a/deps/v8/src/objects.h b/deps/v8/src/objects.h index f2e17d34bb..9333e9edc4 100644 --- a/deps/v8/src/objects.h +++ b/deps/v8/src/objects.h @@ -5,6 +5,8 @@ #ifndef V8_OBJECTS_H_ #define V8_OBJECTS_H_ +#include <iosfwd> + #include "src/allocation.h" #include "src/assert-scope.h" #include "src/bailout-reason.h" @@ -18,6 +20,7 @@ #include "src/property-details.h" #include "src/smart-pointers.h" #include "src/unicode-inl.h" +#include "src/unicode-decoder.h" #include "src/zone.h" #if V8_TARGET_ARCH_ARM @@ -140,6 +143,7 @@ // - DebugInfo // - BreakPointInfo // - CodeCache +// - WeakCell // // Formats of Object*: // Smi: [31 bit signed int] 0 @@ -148,8 +152,6 @@ namespace v8 { namespace internal { -class OStream; - enum KeyedAccessStoreMode { STANDARD_STORE, STORE_TRANSITION_SMI_TO_OBJECT, @@ -231,6 +233,9 @@ static inline bool IsGrowStoreMode(KeyedAccessStoreMode store_mode) { } +enum IcCheckType { ELEMENT, PROPERTY }; + + // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER. enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER }; @@ -275,8 +280,9 @@ enum DebugExtraICState { // either extends the current map with a new property, or it modifies the // property that was added last to the current map. enum SimpleTransitionFlag { - SIMPLE_TRANSITION, - FULL_TRANSITION + SIMPLE_PROPERTY_TRANSITION, + PROPERTY_TRANSITION, + SPECIAL_TRANSITION }; @@ -421,6 +427,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1; V(FIXED_DOUBLE_ARRAY_TYPE) \ V(CONSTANT_POOL_ARRAY_TYPE) \ V(SHARED_FUNCTION_INFO_TYPE) \ + V(WEAK_CELL_TYPE) \ \ V(JS_MESSAGE_OBJECT_TYPE) \ \ @@ -717,6 +724,7 @@ enum InstanceType { FIXED_ARRAY_TYPE, CONSTANT_POOL_ARRAY_TYPE, SHARED_FUNCTION_INFO_TYPE, + WEAK_CELL_TYPE, // All the following types are subtypes of JSReceiver, which corresponds to // objects in the JS sense. The first and the last type in this range are @@ -853,6 +861,7 @@ class ObjectVisitor; class LookupIterator; class StringStream; class TypeFeedbackVector; +class WeakCell; // We cannot just say "class HeapType;" if it is created from a template... =8-? template<class> class TypeImpl; struct HeapTypeConfig; @@ -869,7 +878,7 @@ template <class C> inline bool Is(Object* obj); #endif #ifdef OBJECT_PRINT -#define DECLARE_PRINTER(Name) void Name##Print(OStream& os); // NOLINT +#define DECLARE_PRINTER(Name) void Name##Print(std::ostream& os); // NOLINT #else #define DECLARE_PRINTER(Name) #endif @@ -980,6 +989,7 @@ template <class C> inline bool Is(Object* obj); V(AccessCheckNeeded) \ V(Cell) \ V(PropertyCell) \ + V(WeakCell) \ V(ObjectHashTable) \ V(WeakHashTable) \ V(OrderedHashTable) @@ -1122,8 +1132,11 @@ class Object { StorePropertyMode data_store_mode = NORMAL_PROPERTY); MUST_USE_RESULT static MaybeHandle<Object> WriteToReadOnlyProperty( LookupIterator* it, Handle<Object> value, StrictMode strict_mode); - static Handle<Object> SetDataProperty(LookupIterator* it, - Handle<Object> value); + MUST_USE_RESULT static MaybeHandle<Object> WriteToReadOnlyElement( + Isolate* isolate, Handle<Object> receiver, uint32_t index, + Handle<Object> value, StrictMode strict_mode); + MUST_USE_RESULT static MaybeHandle<Object> SetDataProperty( + LookupIterator* it, Handle<Object> value); MUST_USE_RESULT static MaybeHandle<Object> AddDataProperty( LookupIterator* it, Handle<Object> value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode); @@ -1167,6 +1180,13 @@ class Object { Handle<Object> receiver, uint32_t index); + MUST_USE_RESULT static MaybeHandle<Object> SetElementWithReceiver( + Isolate* isolate, Handle<Object> object, Handle<Object> receiver, + uint32_t index, Handle<Object> value, StrictMode strict_mode); + + static inline Handle<Object> GetPrototypeSkipHiddenPrototypes( + Isolate* isolate, Handle<Object> receiver); + // Returns the permanent hash code associated with this object. May return // undefined if not yet created. Object* GetHash(); @@ -1219,7 +1239,7 @@ class Object { void Print(); // Prints this object with details. - void Print(OStream& os); // NOLINT + void Print(std::ostream& os); // NOLINT #endif private: @@ -1239,7 +1259,7 @@ struct Brief { }; -OStream& operator<<(OStream& os, const Brief& v); +std::ostream& operator<<(std::ostream& os, const Brief& v); // Smi represents integer Numbers that can be stored in 31 bits. @@ -1264,7 +1284,7 @@ class Smi: public Object { DECLARE_CAST(Smi) // Dispatched behavior. - void SmiPrint(OStream& os) const; // NOLINT + void SmiPrint(std::ostream& os) const; // NOLINT DECLARE_VERIFIER(Smi) static const int kMinValue = @@ -1407,9 +1427,9 @@ class HeapObject: public Object { const DisallowHeapAllocation& promise); // Dispatched behavior. - void HeapObjectShortPrint(OStream& os); // NOLINT + void HeapObjectShortPrint(std::ostream& os); // NOLINT #ifdef OBJECT_PRINT - void PrintHeader(OStream& os, const char* id); // NOLINT + void PrintHeader(std::ostream& os, const char* id); // NOLINT #endif DECLARE_PRINTER(HeapObject) DECLARE_VERIFIER(HeapObject) @@ -1496,7 +1516,7 @@ class HeapNumber: public HeapObject { // Dispatched behavior. bool HeapNumberBooleanValue(); - void HeapNumberPrint(OStream& os); // NOLINT + void HeapNumberPrint(std::ostream& os); // NOLINT DECLARE_VERIFIER(HeapNumber) inline int get_exponent(); @@ -1621,9 +1641,6 @@ class JSReceiver: public HeapObject { MUST_USE_RESULT static inline Maybe<PropertyAttributes> GetOwnElementAttribute(Handle<JSReceiver> object, uint32_t index); - // Return the constructor function (may be Heap::null_value()). - inline Object* GetConstructor(); - // Retrieves a permanent object identity hash code. The undefined value might // be returned in case no hash was created yet. inline Object* GetIdentityHash(); @@ -1837,10 +1854,6 @@ class JSObject: public JSReceiver { Handle<Object> receiver, Handle<Name> name); - // Returns true if this is an instance of an api function and has - // been modified since it was created. May give false positives. - bool IsDirty(); - // Accessors for hidden properties object. // // Hidden properties are not own properties of the object itself. @@ -1915,8 +1928,7 @@ class JSObject: public JSReceiver { // These methods do not perform access checks! MUST_USE_RESULT static MaybeHandle<AccessorPair> GetOwnElementAccessorPair( - Handle<JSObject> object, - uint32_t index); + Handle<JSObject> object, uint32_t index); MUST_USE_RESULT static MaybeHandle<Object> SetFastElement( Handle<JSObject> object, @@ -2113,9 +2125,9 @@ class JSObject: public JSReceiver { DECLARE_PRINTER(JSObject) DECLARE_VERIFIER(JSObject) #ifdef OBJECT_PRINT - void PrintProperties(OStream& os); // NOLINT - void PrintElements(OStream& os); // NOLINT - void PrintTransitions(OStream& os); // NOLINT + void PrintProperties(std::ostream& os); // NOLINT + void PrintElements(std::ostream& os); // NOLINT + void PrintTransitions(std::ostream& os); // NOLINT #endif static void PrintElementsTransition( @@ -2204,14 +2216,9 @@ class JSObject: public JSReceiver { Context* GetCreationContext(); // Enqueue change record for Object.observe. May cause GC. - static void EnqueueChangeRecord(Handle<JSObject> object, - const char* type, - Handle<Name> name, - Handle<Object> old_value); - - static void MigrateToNewProperty(Handle<JSObject> object, - Handle<Map> transition, - Handle<Object> value); + MUST_USE_RESULT static MaybeHandle<Object> EnqueueChangeRecord( + Handle<JSObject> object, const char* type, Handle<Name> name, + Handle<Object> old_value); private: friend class DictionaryElementsAccessor; @@ -2223,11 +2230,6 @@ class JSObject: public JSReceiver { Handle<Map> new_map, int expected_additional_properties); - static void GeneralizeFieldRepresentation(Handle<JSObject> object, - int modify_index, - Representation new_representation, - Handle<HeapType> new_field_type); - static void UpdateAllocationSite(Handle<JSObject> object, ElementsKind to_kind); @@ -2246,18 +2248,30 @@ class JSObject: public JSReceiver { GetElementAttributeWithInterceptor(Handle<JSObject> object, Handle<JSReceiver> receiver, uint32_t index, bool continue_search); + + // Queries indexed interceptor on an object for property attributes. + // + // We determine property attributes as follows: + // - if interceptor has a query callback, then the property attributes are + // the result of query callback for index. + // - otherwise if interceptor has a getter callback and it returns + // non-empty value on index, then the property attributes is NONE + // (property is present, and it is enumerable, configurable, writable) + // - otherwise there are no property attributes that can be inferred for + // interceptor, and this function returns ABSENT. + MUST_USE_RESULT static Maybe<PropertyAttributes> + GetElementAttributeFromInterceptor(Handle<JSObject> object, + Handle<Object> receiver, + uint32_t index); + MUST_USE_RESULT static Maybe<PropertyAttributes> GetElementAttributeWithoutInterceptor(Handle<JSObject> object, Handle<JSReceiver> receiver, uint32_t index, bool continue_search); MUST_USE_RESULT static MaybeHandle<Object> SetElementWithCallback( - Handle<JSObject> object, - Handle<Object> structure, - uint32_t index, - Handle<Object> value, - Handle<JSObject> holder, - StrictMode strict_mode); + Handle<Object> object, Handle<Object> structure, uint32_t index, + Handle<Object> value, Handle<JSObject> holder, StrictMode strict_mode); MUST_USE_RESULT static MaybeHandle<Object> SetElementWithInterceptor( Handle<JSObject> object, uint32_t index, @@ -2402,7 +2416,7 @@ class IncrementalMarking; class FixedArray: public FixedArrayBase { public: // Setter and getter for elements. - inline Object* get(int index); + inline Object* get(int index) const; static inline Handle<Object> get(Handle<FixedArray> array, int index); // Setter that uses write barrier. inline void set(int index, Object* value); @@ -2844,13 +2858,13 @@ class ConstantPoolArray: public HeapObject { // get_extended_section_header_offset(). static const int kExtendedInt64CountOffset = 0; static const int kExtendedCodePtrCountOffset = - kExtendedInt64CountOffset + kPointerSize; + kExtendedInt64CountOffset + kInt32Size; static const int kExtendedHeapPtrCountOffset = - kExtendedCodePtrCountOffset + kPointerSize; + kExtendedCodePtrCountOffset + kInt32Size; static const int kExtendedInt32CountOffset = - kExtendedHeapPtrCountOffset + kPointerSize; + kExtendedHeapPtrCountOffset + kInt32Size; static const int kExtendedFirstOffset = - kExtendedInt32CountOffset + kPointerSize; + kExtendedInt32CountOffset + kInt32Size; // Dispatched behavior. void ConstantPoolIterateBody(ObjectVisitor* v); @@ -3038,8 +3052,11 @@ class DescriptorArray: public FixedArray { static const int kDescriptorSize = 3; #ifdef OBJECT_PRINT + // For our gdb macros, we should perhaps change these in the future. + void Print(); + // Print all the descriptors. - void PrintDescriptors(OStream& os); // NOLINT + void PrintDescriptors(std::ostream& os); // NOLINT #endif #ifdef DEBUG @@ -3129,12 +3146,9 @@ class DescriptorArray: public FixedArray { enum SearchMode { ALL_ENTRIES, VALID_ENTRIES }; -template<SearchMode search_mode, typename T> -inline int LinearSearch(T* array, Name* name, int len, int valid_entries); - - -template<SearchMode search_mode, typename T> -inline int Search(T* array, Name* name, int valid_entries = 0); +template <SearchMode search_mode, typename T> +inline int Search(T* array, Name* name, int valid_entries = 0, + int* out_insertion_index = NULL); // HashTable is a subclass of FixedArray that implements a hash table @@ -3433,6 +3447,8 @@ class StringTable: public HashTable<StringTable, uint16_t c1, uint16_t c2); + static void EnsureCapacityForDeserialization(Isolate* isolate, int expected); + DECLARE_CAST(StringTable) private: @@ -3532,6 +3548,10 @@ class Dictionary: public HashTable<Derived, Shape, Key> { // Returns the number of enumerable elements in the dictionary. int NumberOfEnumElements(); + // Returns true if the dictionary contains any elements that are non-writable, + // non-configurable, non-enumerable, or have getters/setters. + bool HasComplexElements(); + enum SortMode { UNSORTED, SORTED }; // Copies keys to preallocated fixed array. void CopyKeysTo(FixedArray* storage, @@ -3563,7 +3583,7 @@ class Dictionary: public HashTable<Derived, Shape, Key> { static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key); #ifdef OBJECT_PRINT - void Print(OStream& os); // NOLINT + void Print(std::ostream& os); // NOLINT #endif // Returns the key (slow). Object* SlowReverseLookup(Object* value); @@ -3583,6 +3603,11 @@ class Dictionary: public HashTable<Derived, Shape, Key> { Handle<Object> value, PropertyDetails details); + // Returns iteration indices array for the |dictionary|. + // Values are direct indices in the |HashTable| array. + static Handle<FixedArray> BuildIterationIndicesArray( + Handle<Derived> dictionary); + protected: // Generic at put operation. MUST_USE_RESULT static Handle<Derived> AtPut( @@ -3599,7 +3624,9 @@ class Dictionary: public HashTable<Derived, Shape, Key> { uint32_t hash); // Generate new enumeration indices to avoid enumeration index overflow. - static void GenerateNewEnumerationIndices(Handle<Derived> dictionary); + // Returns iteration indices array for the |dictionary|. + static Handle<FixedArray> GenerateNewEnumerationIndices( + Handle<Derived> dictionary); static const int kMaxNumberKeyIndex = DerivedHashTable::kPrefixStartIndex; static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; }; @@ -3628,7 +3655,7 @@ class NameDictionary: public Dictionary<NameDictionary, // Copies enumerable keys to preallocated fixed array. void CopyEnumKeysTo(FixedArray* storage); - inline static void DoGenerateNewEnumerationIndices( + inline static Handle<FixedArray> DoGenerateNewEnumerationIndices( Handle<NameDictionary> dictionary); // Find entry for key, otherwise return kNotFound. Optimized version of @@ -4298,13 +4325,13 @@ class ScopeInfo : public FixedArray { }; // Properties of scopes. - class ScopeTypeField: public BitField<ScopeType, 0, 3> {}; - class CallsEvalField: public BitField<bool, 3, 1> {}; - class StrictModeField: public BitField<StrictMode, 4, 1> {}; - class FunctionVariableField: public BitField<FunctionVariableInfo, 5, 2> {}; - class FunctionVariableMode: public BitField<VariableMode, 7, 3> {}; - class AsmModuleField : public BitField<bool, 10, 1> {}; - class AsmFunctionField : public BitField<bool, 11, 1> {}; + class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; + class CallsEvalField : public BitField<bool, 4, 1> {}; + class StrictModeField : public BitField<StrictMode, 5, 1> {}; + class FunctionVariableField : public BitField<FunctionVariableInfo, 6, 2> {}; + class FunctionVariableMode : public BitField<VariableMode, 8, 3> {}; + class AsmModuleField : public BitField<bool, 11, 1> {}; + class AsmFunctionField : public BitField<bool, 12, 1> {}; // BitFields representing the encoded information for context locals in the // ContextLocalInfoEntries part. @@ -4865,7 +4892,7 @@ class DeoptimizationInputData: public FixedArray { DECLARE_CAST(DeoptimizationInputData) #ifdef ENABLE_DISASSEMBLER - void DeoptimizationInputDataPrint(OStream& os); // NOLINT + void DeoptimizationInputDataPrint(std::ostream& os); // NOLINT #endif private: @@ -4910,7 +4937,7 @@ class DeoptimizationOutputData: public FixedArray { DECLARE_CAST(DeoptimizationOutputData) #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) - void DeoptimizationOutputDataPrint(OStream& os); // NOLINT + void DeoptimizationOutputDataPrint(std::ostream& os); // NOLINT #endif }; @@ -4976,9 +5003,9 @@ class Code: public HeapObject { // Printing static const char* ICState2String(InlineCacheState state); static const char* StubType2String(StubType type); - static void PrintExtraICState(OStream& os, // NOLINT + static void PrintExtraICState(std::ostream& os, // NOLINT Kind kind, ExtraICState extra); - void Disassemble(const char* name, OStream& os); // NOLINT + void Disassemble(const char* name, std::ostream& os); // NOLINT #endif // ENABLE_DISASSEMBLER // [instruction_size]: Size of the native instructions @@ -5118,6 +5145,10 @@ class Code: public HeapObject { inline void set_profiler_ticks(int ticks); // [builtin_index]: For BUILTIN kind, tells which builtin index it has. + // For builtins, tells which builtin index it has. + // Note that builtins can have a code kind other than BUILTIN, which means + // that for arbitrary code objects, this index value may be random garbage. + // To verify in that case, compare the code object to the indexed builtin. inline int builtin_index(); inline void set_builtin_index(int id); @@ -5310,6 +5341,7 @@ class Code: public HeapObject { // compilation stub. static void MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate); static void MarkCodeAsExecuted(byte* sequence, Isolate* isolate); + void MakeYoung(); void MakeOlder(MarkingParity); static bool IsYoungSequence(Isolate* isolate, byte* sequence); bool IsOld(); @@ -5328,6 +5360,10 @@ class Code: public HeapObject { void VerifyEmbeddedObjectsDependency(); #endif +#ifdef DEBUG + void VerifyEmbeddedObjectsInFullCode(); +#endif // DEBUG + inline bool CanContainWeakObjects() { return is_optimized_code() || is_weak_stub(); } @@ -5346,8 +5382,7 @@ class Code: public HeapObject { static const int kMaxLoopNestingMarker = 6; // Layout description. - static const int kInstructionSizeOffset = HeapObject::kHeaderSize; - static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; + static const int kRelocationInfoOffset = HeapObject::kHeaderSize; static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; static const int kDeoptimizationDataOffset = kHandlerTableOffset + kPointerSize; @@ -5356,8 +5391,8 @@ class Code: public HeapObject { kDeoptimizationDataOffset + kPointerSize; static const int kNextCodeLinkOffset = kTypeFeedbackInfoOffset + kPointerSize; static const int kGCMetadataOffset = kNextCodeLinkOffset + kPointerSize; - static const int kICAgeOffset = - kGCMetadataOffset + kPointerSize; + static const int kInstructionSizeOffset = kGCMetadataOffset + kPointerSize; + static const int kICAgeOffset = kInstructionSizeOffset + kIntSize; static const int kFlagsOffset = kICAgeOffset + kIntSize; static const int kKindSpecificFlags1Offset = kFlagsOffset + kIntSize; static const int kKindSpecificFlags2Offset = @@ -5366,7 +5401,7 @@ class Code: public HeapObject { static const int kPrologueOffset = kKindSpecificFlags2Offset + kIntSize; static const int kConstantPoolOffset = kPrologueOffset + kPointerSize; - static const int kHeaderPaddingStart = kConstantPoolOffset + kIntSize; + static const int kHeaderPaddingStart = kConstantPoolOffset + kPointerSize; // Add padding to align the instruction start following right after // the Code object header. @@ -5786,7 +5821,9 @@ class Map: public HeapObject { inline Map* elements_transition_map(); inline Map* GetTransition(int transition_index); - inline int SearchTransition(Name* name); + inline int SearchSpecialTransition(Symbol* name); + inline int SearchTransition(PropertyType type, Name* name, + PropertyAttributes attributes); inline FixedArrayBase* GetInitialElements(); DECL_ACCESSORS(transitions, TransitionArray) @@ -5924,8 +5961,8 @@ class Map: public HeapObject { Name* name, LookupResult* result); - inline void LookupTransition(JSObject* holder, - Name* name, + inline void LookupTransition(JSObject* holder, Name* name, + PropertyAttributes attributes, LookupResult* result); inline PropertyDetails GetLastDescriptorDetails(); @@ -6085,6 +6122,8 @@ class Map: public HeapObject { static void AppendCallbackDescriptors(Handle<Map> map, Handle<Object> descriptors); + static inline int SlackForArraySize(int old_size, int size_limit); + static void EnsureDescriptorSlack(Handle<Map> map, int slack); // Returns the found code or undefined if absent. @@ -6125,6 +6164,7 @@ class Map: public HeapObject { bool IsJSObjectMap() { return instance_type() >= FIRST_JS_OBJECT_TYPE; } + bool IsStringMap() { return instance_type() < FIRST_NONSTRING_TYPE; } bool IsJSProxyMap() { InstanceType type = instance_type(); return FIRST_JS_PROXY_TYPE <= type && type <= LAST_JS_PROXY_TYPE; @@ -6292,12 +6332,11 @@ class Map: public HeapObject { static Handle<Map> CopyAddDescriptor(Handle<Map> map, Descriptor* descriptor, TransitionFlag flag); - static Handle<Map> CopyReplaceDescriptors( - Handle<Map> map, - Handle<DescriptorArray> descriptors, - TransitionFlag flag, - MaybeHandle<Name> maybe_name, - SimpleTransitionFlag simple_flag = FULL_TRANSITION); + static Handle<Map> CopyReplaceDescriptors(Handle<Map> map, + Handle<DescriptorArray> descriptors, + TransitionFlag flag, + MaybeHandle<Name> maybe_name, + SimpleTransitionFlag simple_flag); static Handle<Map> CopyReplaceDescriptor(Handle<Map> map, Handle<DescriptorArray> descriptors, Descriptor* descriptor, @@ -6325,7 +6364,9 @@ class Map: public HeapObject { void ZapTransitions(); void DeprecateTransitionTree(); - void DeprecateTarget(Name* key, DescriptorArray* new_descriptors); + void DeprecateTarget(PropertyType type, Name* key, + PropertyAttributes attributes, + DescriptorArray* new_descriptors); Map* FindLastMatchMap(int verbatim, int length, DescriptorArray* descriptors); @@ -6431,8 +6472,8 @@ class Script: public Struct { // [context_data]: context data for the context this script was compiled in. DECL_ACCESSORS(context_data, Object) - // [wrapper]: the wrapper cache. - DECL_ACCESSORS(wrapper, Foreign) + // [wrapper]: the wrapper cache. This is either undefined or a WeakCell. + DECL_ACCESSORS(wrapper, HeapObject) // [type]: the script type. DECL_ACCESSORS(type, Smi) @@ -6494,7 +6535,6 @@ class Script: public Struct { // Get the JS object wrapping the given script; create it if none exists. static Handle<JSObject> GetWrapper(Handle<Script> script); - void ClearWrapperCache(); // Dispatched behavior. DECLARE_PRINTER(Script) @@ -6546,9 +6586,11 @@ class Script: public Struct { V(Array.prototype, pop, ArrayPop) \ V(Array.prototype, shift, ArrayShift) \ V(Function.prototype, apply, FunctionApply) \ + V(Function.prototype, call, FunctionCall) \ V(String.prototype, charCodeAt, StringCharCodeAt) \ V(String.prototype, charAt, StringCharAt) \ V(String, fromCharCode, StringFromCharCode) \ + V(Math, random, MathRandom) \ V(Math, floor, MathFloor) \ V(Math, round, MathRound) \ V(Math, ceil, MathCeil) \ @@ -6559,6 +6601,13 @@ class Script: public Struct { V(Math, pow, MathPow) \ V(Math, max, MathMax) \ V(Math, min, MathMin) \ + V(Math, cos, MathCos) \ + V(Math, sin, MathSin) \ + V(Math, tan, MathTan) \ + V(Math, acos, MathAcos) \ + V(Math, asin, MathAsin) \ + V(Math, atan, MathAtan) \ + V(Math, atan2, MathAtan2) \ V(Math, imul, MathImul) \ V(Math, clz32, MathClz32) \ V(Math, fround, MathFround) @@ -6809,6 +6858,9 @@ class SharedFunctionInfo: public HeapObject { // Indicates that this function is an asm function. DECL_BOOLEAN_ACCESSORS(asm_function) + // Indicates that the the shared function info is deserialized from cache. + DECL_BOOLEAN_ACCESSORS(deserialized) + inline FunctionKind kind(); inline void set_kind(FunctionKind kind); @@ -6937,10 +6989,11 @@ class SharedFunctionInfo: public HeapObject { // garbage collections. // To avoid wasting space on 64-bit architectures we use // the following trick: we group integer fields into pairs - // First integer in each pair is shifted left by 1. - // By doing this we guarantee that LSB of each kPointerSize aligned - // word is not set and thus this word cannot be treated as pointer - // to HeapObject during old space traversal. +// The least significant integer in each pair is shifted left by 1. +// By doing this we guarantee that LSB of each kPointerSize aligned +// word is not set and thus this word cannot be treated as pointer +// to HeapObject during old space traversal. +#if V8_TARGET_LITTLE_ENDIAN static const int kLengthOffset = kFeedbackVectorOffset + kPointerSize; static const int kFormalParameterCountOffset = @@ -6974,7 +7027,37 @@ class SharedFunctionInfo: public HeapObject { // Total size. static const int kSize = kProfilerTicksOffset + kIntSize; -#endif +#elif V8_TARGET_BIG_ENDIAN + static const int kFormalParameterCountOffset = + kFeedbackVectorOffset + kPointerSize; + static const int kLengthOffset = kFormalParameterCountOffset + kIntSize; + + static const int kNumLiteralsOffset = kLengthOffset + kIntSize; + static const int kExpectedNofPropertiesOffset = kNumLiteralsOffset + kIntSize; + + static const int kStartPositionAndTypeOffset = + kExpectedNofPropertiesOffset + kIntSize; + static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize; + + static const int kCompilerHintsOffset = kEndPositionOffset + kIntSize; + static const int kFunctionTokenPositionOffset = + kCompilerHintsOffset + kIntSize; + + static const int kCountersOffset = kFunctionTokenPositionOffset + kIntSize; + static const int kOptCountAndBailoutReasonOffset = kCountersOffset + kIntSize; + + static const int kProfilerTicksOffset = + kOptCountAndBailoutReasonOffset + kIntSize; + static const int kAstNodeCountOffset = kProfilerTicksOffset + kIntSize; + + // Total size. + static const int kSize = kAstNodeCountOffset + kIntSize; + +#else +#error Unknown byte ordering +#endif // Big endian +#endif // 64-bit + static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); @@ -7010,6 +7093,7 @@ class SharedFunctionInfo: public HeapObject { kIsGenerator, kIsConciseMethod, kIsAsmFunction, + kDeserialized, kCompilerHintsCount // Pseudo entry }; @@ -7076,7 +7160,7 @@ struct SourceCodeOf { }; -OStream& operator<<(OStream& os, const SourceCodeOf& v); +std::ostream& operator<<(std::ostream& os, const SourceCodeOf& v); class JSGeneratorObject: public JSObject { @@ -7860,26 +7944,40 @@ class CompilationCacheShape : public BaseShape<HashTableKey*> { }; +// This cache is used in two different variants. For regexp caching, it simply +// maps identifying info of the regexp to the cached regexp object. Scripts and +// eval code only gets cached after a second probe for the code object. To do +// so, on first "put" only a hash identifying the source is entered into the +// cache, mapping it to a lifetime count of the hash. On each call to Age all +// such lifetimes get reduced, and removed once they reach zero. If a second put +// is called while such a hash is live in the cache, the hash gets replaced by +// an actual cache entry. Age also removes stale live entries from the cache. +// Such entries are identified by SharedFunctionInfos pointing to either the +// recompilation stub, or to "old" code. This avoids memory leaks due to +// premature caching of scripts and eval strings that are never needed later. class CompilationCacheTable: public HashTable<CompilationCacheTable, CompilationCacheShape, HashTableKey*> { public: // Find cached value for a string key, otherwise return null. Handle<Object> Lookup(Handle<String> src, Handle<Context> context); - Handle<Object> LookupEval(Handle<String> src, Handle<Context> context, - StrictMode strict_mode, int scope_position); + Handle<Object> LookupEval(Handle<String> src, + Handle<SharedFunctionInfo> shared, + StrictMode strict_mode, int scope_position); Handle<Object> LookupRegExp(Handle<String> source, JSRegExp::Flags flags); static Handle<CompilationCacheTable> Put( Handle<CompilationCacheTable> cache, Handle<String> src, Handle<Context> context, Handle<Object> value); static Handle<CompilationCacheTable> PutEval( Handle<CompilationCacheTable> cache, Handle<String> src, - Handle<Context> context, Handle<SharedFunctionInfo> value, + Handle<SharedFunctionInfo> context, Handle<SharedFunctionInfo> value, int scope_position); static Handle<CompilationCacheTable> PutRegExp( Handle<CompilationCacheTable> cache, Handle<String> src, JSRegExp::Flags flags, Handle<FixedArray> value); void Remove(Object* value); + void Age(); + static const int kHashGenerations = 10; DECLARE_CAST(CompilationCacheTable) @@ -8050,7 +8148,6 @@ class TypeFeedbackInfo: public Struct { inline void set_inlined_type_change_checksum(int checksum); inline bool matches_inlined_type_change_checksum(int checksum); - DECLARE_CAST(TypeFeedbackInfo) // Dispatched behavior. @@ -8483,8 +8580,13 @@ class Name: public HeapObject { DECLARE_PRINTER(Name) // Layout description. - static const int kHashFieldOffset = HeapObject::kHeaderSize; - static const int kSize = kHashFieldOffset + kPointerSize; + static const int kHashFieldSlot = HeapObject::kHeaderSize; +#if V8_TARGET_LITTLE_ENDIAN || !V8_HOST_ARCH_64_BIT + static const int kHashFieldOffset = kHashFieldSlot; +#else + static const int kHashFieldOffset = kHashFieldSlot + kIntSize; +#endif + static const int kSize = kHashFieldSlot + kPointerSize; // Mask constant for checking if a name has a computed hash code // and if it is a string that is an array index. The least significant bit @@ -8570,10 +8672,14 @@ class Symbol: public Name { typedef FixedBodyDescriptor<kNameOffset, kFlagsOffset, kSize> BodyDescriptor; + void SymbolShortPrint(std::ostream& os); + private: static const int kPrivateBit = 0; static const int kOwnBit = 1; + const char* PrivateSymbolToName() const; + DISALLOW_IMPLICIT_CONSTRUCTORS(Symbol); }; @@ -8789,7 +8895,7 @@ class String: public Name { // Dispatched behavior. void StringShortPrint(StringStream* accumulator); - void PrintUC16(OStream& os, int start = 0, int end = -1); // NOLINT + void PrintUC16(std::ostream& os, int start = 0, int end = -1); // NOLINT #ifdef OBJECT_PRINT char* ToAsciiArray(); #endif @@ -9268,26 +9374,13 @@ class FlatStringReader : public Relocatable { }; -// A ConsStringOp that returns null. -// Useful when the operation to apply on a ConsString -// requires an expensive data structure. -class ConsStringNullOp { - public: - inline ConsStringNullOp() {} - static inline String* Operate(String*, unsigned*, int32_t*, unsigned*); - private: - DISALLOW_COPY_AND_ASSIGN(ConsStringNullOp); -}; - - // This maintains an off-stack representation of the stack frames required // to traverse a ConsString, allowing an entirely iterative and restartable // traversal of the entire string -class ConsStringIteratorOp { +class ConsStringIterator { public: - inline ConsStringIteratorOp() {} - inline explicit ConsStringIteratorOp(ConsString* cons_string, - int offset = 0) { + inline ConsStringIterator() {} + inline explicit ConsStringIterator(ConsString* cons_string, int offset = 0) { Reset(cons_string, offset); } inline void Reset(ConsString* cons_string, int offset = 0) { @@ -9327,14 +9420,13 @@ class ConsStringIteratorOp { int depth_; int maximum_depth_; int consumed_; - DISALLOW_COPY_AND_ASSIGN(ConsStringIteratorOp); + DISALLOW_COPY_AND_ASSIGN(ConsStringIterator); }; class StringCharacterStream { public: inline StringCharacterStream(String* string, - ConsStringIteratorOp* op, int offset = 0); inline uint16_t GetNext(); inline bool HasMore(); @@ -9343,13 +9435,13 @@ class StringCharacterStream { inline void VisitTwoByteString(const uint16_t* chars, int length); private: + ConsStringIterator iter_; bool is_one_byte_; union { const uint8_t* buffer8_; const uint16_t* buffer16_; }; const uint8_t* end_; - ConsStringIteratorOp* op_; DISALLOW_COPY_AND_ASSIGN(StringCharacterStream); }; @@ -9508,6 +9600,37 @@ class PropertyCell: public Cell { }; +class WeakCell : public HeapObject { + public: + inline Object* value() const; + + // This should not be called by anyone except GC. + inline void clear(); + + // This should not be called by anyone except allocator. + inline void initialize(HeapObject* value); + + inline bool cleared() const; + + DECL_ACCESSORS(next, Object) + + DECLARE_CAST(WeakCell) + + DECLARE_PRINTER(WeakCell) + DECLARE_VERIFIER(WeakCell) + + // Layout description. + static const int kValueOffset = HeapObject::kHeaderSize; + static const int kNextOffset = kValueOffset + kPointerSize; + static const int kSize = kNextOffset + kPointerSize; + + typedef FixedBodyDescriptor<kValueOffset, kSize, kSize> BodyDescriptor; + + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(WeakCell); +}; + + // The JSProxy describes EcmaScript Harmony proxies class JSProxy: public JSReceiver { public: @@ -9714,7 +9837,7 @@ class OrderedHashTableIterator: public JSObject { DECL_ACCESSORS(kind, Object) #ifdef OBJECT_PRINT - void OrderedHashTableIteratorPrint(OStream& os); // NOLINT + void OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT #endif static const int kTableOffset = JSObject::kHeaderSize; @@ -9858,6 +9981,9 @@ class JSArrayBuffer: public JSObject { inline bool should_be_freed(); inline void set_should_be_freed(bool value); + inline bool is_neuterable(); + inline void set_is_neuterable(bool value); + // [weak_next]: linked list of array buffers. DECL_ACCESSORS(weak_next, Object) @@ -9887,6 +10013,7 @@ class JSArrayBuffer: public JSObject { // Bit position in a flag static const int kIsExternalBit = 0; static const int kShouldBeFreed = 1; + static const int kIsNeuterableBit = 2; DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBuffer); }; |