2015-12-16 14:27:15 +00:00
|
|
|
// Copyright 2015 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#ifndef V8_OBJECTS_H_
|
|
|
|
#define V8_OBJECTS_H_
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
#include <iosfwd>
|
2016-07-25 10:24:45 +00:00
|
|
|
#include <memory>
|
2014-09-30 10:29:32 +00:00
|
|
|
|
2018-09-07 09:03:35 +00:00
|
|
|
#include "include/v8-internal.h"
|
2018-05-16 10:49:30 +00:00
|
|
|
#include "include/v8.h"
|
|
|
|
#include "include/v8config.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/assert-scope.h"
|
2014-09-02 13:36:35 +00:00
|
|
|
#include "src/base/bits.h"
|
2018-05-16 10:49:30 +00:00
|
|
|
#include "src/base/build_config.h"
|
2015-11-25 13:46:09 +00:00
|
|
|
#include "src/base/flags.h"
|
2018-05-16 10:49:30 +00:00
|
|
|
#include "src/base/logging.h"
|
2014-06-30 13:25:46 +00:00
|
|
|
#include "src/checks.h"
|
2018-10-24 22:52:04 +00:00
|
|
|
#include "src/constants-arch.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/elements-kind.h"
|
2014-06-10 14:01:08 +00:00
|
|
|
#include "src/field-index.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/flags.h"
|
2018-10-11 21:35:34 +00:00
|
|
|
#include "src/message-template.h"
|
2018-07-03 14:27:16 +00:00
|
|
|
#include "src/objects-definitions.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/property-details.h"
|
2018-07-03 08:37:51 +00:00
|
|
|
#include "src/roots.h"
|
2018-05-16 10:49:30 +00:00
|
|
|
#include "src/utils.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2018-12-13 10:50:29 +00:00
|
|
|
#ifdef V8_COMPRESS_POINTERS
|
|
|
|
#include "src/ptr-compr.h"
|
|
|
|
#endif
|
2014-06-20 08:40:11 +00:00
|
|
|
|
2017-01-10 16:05:34 +00:00
|
|
|
// Has to be the last include (doesn't have include guards):
|
|
|
|
#include "src/objects/object-macros.h"
|
2011-10-21 10:32:38 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2010-07-20 07:14:19 +00:00
|
|
|
// Most object types in the V8 JavaScript are described in this file.
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
|
|
|
// Inheritance hierarchy:
|
2014-04-30 12:25:18 +00:00
|
|
|
// - Object
|
|
|
|
// - Smi (immediate small integer)
|
|
|
|
// - HeapObject (superclass for everything allocated in the heap)
|
|
|
|
// - JSReceiver (suitable for property access)
|
|
|
|
// - JSObject
|
|
|
|
// - JSArray
|
|
|
|
// - JSArrayBuffer
|
|
|
|
// - JSArrayBufferView
|
|
|
|
// - JSTypedArray
|
|
|
|
// - JSDataView
|
2015-12-27 06:30:53 +00:00
|
|
|
// - JSBoundFunction
|
2014-07-10 10:54:47 +00:00
|
|
|
// - JSCollection
|
|
|
|
// - JSSet
|
|
|
|
// - JSMap
|
2016-09-21 14:17:42 +00:00
|
|
|
// - JSStringIterator
|
2014-04-30 12:25:18 +00:00
|
|
|
// - JSSetIterator
|
|
|
|
// - JSMapIterator
|
|
|
|
// - JSWeakCollection
|
|
|
|
// - JSWeakMap
|
|
|
|
// - JSWeakSet
|
|
|
|
// - JSRegExp
|
|
|
|
// - JSFunction
|
|
|
|
// - JSGeneratorObject
|
2015-11-02 14:57:59 +00:00
|
|
|
// - JSGlobalObject
|
2014-04-30 12:25:18 +00:00
|
|
|
// - JSGlobalProxy
|
|
|
|
// - JSValue
|
|
|
|
// - JSDate
|
|
|
|
// - JSMessageObject
|
2016-10-07 19:37:04 +00:00
|
|
|
// - JSModuleNamespace
|
2018-09-05 02:17:38 +00:00
|
|
|
// - JSV8BreakIterator // If V8_INTL_SUPPORT enabled.
|
2018-08-08 09:23:07 +00:00
|
|
|
// - JSCollator // If V8_INTL_SUPPORT enabled.
|
2018-08-29 04:40:53 +00:00
|
|
|
// - JSDateTimeFormat // If V8_INTL_SUPPORT enabled.
|
2018-08-08 09:23:07 +00:00
|
|
|
// - JSListFormat // If V8_INTL_SUPPORT enabled.
|
|
|
|
// - JSLocale // If V8_INTL_SUPPORT enabled.
|
2018-09-04 18:32:51 +00:00
|
|
|
// - JSNumberFormat // If V8_INTL_SUPPORT enabled.
|
2018-08-08 09:23:07 +00:00
|
|
|
// - JSPluralRules // If V8_INTL_SUPPORT enabled.
|
2018-07-10 12:52:05 +00:00
|
|
|
// - JSRelativeTimeFormat // If V8_INTL_SUPPORT enabled.
|
2018-10-18 07:59:28 +00:00
|
|
|
// - JSSegmentIterator // If V8_INTL_SUPPORT enabled.
|
2018-10-05 01:57:05 +00:00
|
|
|
// - JSSegmenter // If V8_INTL_SUPPORT enabled.
|
2018-09-10 10:28:00 +00:00
|
|
|
// - WasmExceptionObject
|
2018-04-03 18:17:57 +00:00
|
|
|
// - WasmGlobalObject
|
2017-07-07 12:27:56 +00:00
|
|
|
// - WasmInstanceObject
|
|
|
|
// - WasmMemoryObject
|
|
|
|
// - WasmModuleObject
|
|
|
|
// - WasmTableObject
|
2014-04-30 12:25:18 +00:00
|
|
|
// - JSProxy
|
|
|
|
// - FixedArrayBase
|
|
|
|
// - ByteArray
|
2015-07-24 12:02:41 +00:00
|
|
|
// - BytecodeArray
|
2014-04-30 12:25:18 +00:00
|
|
|
// - FixedArray
|
2016-08-24 08:48:34 +00:00
|
|
|
// - FrameArray
|
2014-04-30 12:25:18 +00:00
|
|
|
// - HashTable
|
|
|
|
// - Dictionary
|
|
|
|
// - StringTable
|
2016-03-31 05:58:42 +00:00
|
|
|
// - StringSet
|
2014-04-30 12:25:18 +00:00
|
|
|
// - CompilationCacheTable
|
|
|
|
// - MapCache
|
|
|
|
// - OrderedHashTable
|
|
|
|
// - OrderedHashSet
|
|
|
|
// - OrderedHashMap
|
2017-02-07 14:05:02 +00:00
|
|
|
// - FeedbackMetadata
|
2016-08-01 14:28:06 +00:00
|
|
|
// - TemplateList
|
2014-04-30 12:25:18 +00:00
|
|
|
// - TransitionArray
|
2016-08-01 14:28:06 +00:00
|
|
|
// - ScopeInfo
|
2016-08-31 14:25:28 +00:00
|
|
|
// - ModuleInfo
|
2014-11-12 11:34:09 +00:00
|
|
|
// - ScriptContextTable
|
2014-04-30 12:25:18 +00:00
|
|
|
// - FixedDoubleArray
|
|
|
|
// - Name
|
|
|
|
// - String
|
|
|
|
// - SeqString
|
|
|
|
// - SeqOneByteString
|
|
|
|
// - SeqTwoByteString
|
|
|
|
// - SlicedString
|
|
|
|
// - ConsString
|
2017-01-19 13:27:59 +00:00
|
|
|
// - ThinString
|
2014-04-30 12:25:18 +00:00
|
|
|
// - ExternalString
|
2014-09-10 12:38:12 +00:00
|
|
|
// - ExternalOneByteString
|
2014-04-30 12:25:18 +00:00
|
|
|
// - ExternalTwoByteString
|
|
|
|
// - InternalizedString
|
|
|
|
// - SeqInternalizedString
|
|
|
|
// - SeqOneByteInternalizedString
|
|
|
|
// - SeqTwoByteInternalizedString
|
|
|
|
// - ConsInternalizedString
|
|
|
|
// - ExternalInternalizedString
|
2014-09-10 12:38:12 +00:00
|
|
|
// - ExternalOneByteInternalizedString
|
2014-04-30 12:25:18 +00:00
|
|
|
// - ExternalTwoByteInternalizedString
|
|
|
|
// - Symbol
|
2018-11-26 17:05:59 +00:00
|
|
|
// - Context
|
|
|
|
// - NativeContext
|
2014-04-30 12:25:18 +00:00
|
|
|
// - HeapNumber
|
2017-09-11 13:16:27 +00:00
|
|
|
// - BigInt
|
2014-04-30 12:25:18 +00:00
|
|
|
// - Cell
|
2018-11-26 15:40:55 +00:00
|
|
|
// - DescriptorArray
|
2015-03-18 12:54:02 +00:00
|
|
|
// - PropertyCell
|
2017-07-11 20:56:40 +00:00
|
|
|
// - PropertyArray
|
2014-04-30 12:25:18 +00:00
|
|
|
// - Code
|
2016-01-28 12:11:55 +00:00
|
|
|
// - AbstractCode, a wrapper around Code or BytecodeArray
|
2014-04-30 12:25:18 +00:00
|
|
|
// - Map
|
|
|
|
// - Oddball
|
|
|
|
// - Foreign
|
2017-06-19 23:19:16 +00:00
|
|
|
// - SmallOrderedHashTable
|
|
|
|
// - SmallOrderedHashMap
|
|
|
|
// - SmallOrderedHashSet
|
2014-04-30 12:25:18 +00:00
|
|
|
// - SharedFunctionInfo
|
|
|
|
// - Struct
|
|
|
|
// - AccessorInfo
|
2018-11-21 21:19:18 +00:00
|
|
|
// - AsmWasmData
|
2018-02-08 16:36:52 +00:00
|
|
|
// - PromiseReaction
|
2017-08-30 17:03:38 +00:00
|
|
|
// - PromiseCapability
|
2014-04-30 12:25:18 +00:00
|
|
|
// - AccessorPair
|
|
|
|
// - AccessCheckInfo
|
|
|
|
// - InterceptorInfo
|
|
|
|
// - CallHandlerInfo
|
2017-08-30 04:21:29 +00:00
|
|
|
// - EnumCache
|
2014-04-30 12:25:18 +00:00
|
|
|
// - TemplateInfo
|
|
|
|
// - FunctionTemplateInfo
|
|
|
|
// - ObjectTemplateInfo
|
|
|
|
// - Script
|
|
|
|
// - DebugInfo
|
2017-08-01 16:41:20 +00:00
|
|
|
// - BreakPoint
|
2014-04-30 12:25:18 +00:00
|
|
|
// - BreakPointInfo
|
2017-04-03 14:58:49 +00:00
|
|
|
// - StackFrameInfo
|
2017-05-23 13:01:29 +00:00
|
|
|
// - SourcePositionTableWithFrameCache
|
2014-04-30 12:25:18 +00:00
|
|
|
// - CodeCache
|
2015-04-07 10:42:45 +00:00
|
|
|
// - PrototypeInfo
|
2018-02-08 16:36:52 +00:00
|
|
|
// - Microtask
|
|
|
|
// - CallbackTask
|
|
|
|
// - CallableTask
|
|
|
|
// - PromiseReactionJobTask
|
|
|
|
// - PromiseFulfillReactionJobTask
|
|
|
|
// - PromiseRejectReactionJobTask
|
|
|
|
// - PromiseResolveThenableJobTask
|
2016-09-16 16:47:07 +00:00
|
|
|
// - Module
|
2016-11-04 09:37:22 +00:00
|
|
|
// - ModuleInfoEntry
|
2018-02-22 12:04:01 +00:00
|
|
|
// - FeedbackCell
|
2017-07-27 12:45:00 +00:00
|
|
|
// - FeedbackVector
|
2018-07-10 16:05:04 +00:00
|
|
|
// - PreParsedScopeData
|
2018-07-09 09:34:34 +00:00
|
|
|
// - UncompiledData
|
|
|
|
// - UncompiledDataWithoutPreParsedScope
|
|
|
|
// - UncompiledDataWithPreParsedScope
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
|
|
|
// Formats of Object*:
|
|
|
|
// Smi: [31 bit signed int] 0
|
|
|
|
// HeapObject: [32 bit direct pointer] (4 byte aligned) | 01
|
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
This CL enables precise source positions for all V8 compilers. It merges compiler::SourcePosition and internal::SourcePosition to a single class used throughout the codebase. The new internal::SourcePosition instances store an id identifying an inlined function in addition to a script offset.
SourcePosition::InliningId() refers to a the new table DeoptimizationInputData::InliningPositions(), which provides the following data for every inlining id:
- The inlined SharedFunctionInfo as an offset into DeoptimizationInfo::LiteralArray
- The SourcePosition of the inlining. Recursively, this yields the full inlining stack.
Before the Code object is created, the same information can be found in CompilationInfo::inlined_functions().
If SourcePosition::InliningId() is SourcePosition::kNotInlined, it refers to the outer (non-inlined) function.
So every SourcePosition has full information about its inlining stack, as long as the corresponding Code object is known. The internal represenation of a source position is a positive 64bit integer.
All compilers create now appropriate source positions for inlined functions. In the case of Turbofan, this required using AstGraphBuilderWithPositions for inlined functions too. So this class is now moved to a header file.
At the moment, the additional information in source positions is only used in --trace-deopt and --code-comments. The profiler needs to be updated, at the moment it gets the correct script offsets from the deopt info, but the wrong script id from the reconstructed deopt stack, which can lead to wrong outputs. This should be resolved by making the profiler use the new inlining information for deopts.
I activated the inlined deoptimization tests in test-cpu-profiler.cc for Turbofan, changing them to a case where the deopt stack and the inlining position agree. It is currently still broken for other cases.
The following additional changes were necessary:
- The source position table (internal::SourcePositionTableBuilder etc.) supports now 64bit source positions. Encoding source positions in a single 64bit int together with the difference encoding in the source position table results in very little overhead for the inlining id, since only 12% of the source positions in Octane have a changed inlining id.
- The class HPositionInfo was effectively dead code and is now removed.
- SourcePosition has new printing and information facilities, including computing a full inlining stack.
- I had to rename compiler/source-position.{h,cc} to compiler/compiler-source-position-table.{h,cc} to avoid clashes with the new src/source-position.cc file.
- I wrote the new wrapper PodArray for ByteArray. It is a template working with any POD-type. This is used in DeoptimizationInputData::InliningPositions().
- I removed HInlinedFunctionInfo and HGraph::inlined_function_infos, because they were only used for the now obsolete Crankshaft inlining ids.
- Crankshaft managed a list of inlined functions in Lithium: LChunk::inlined_functions. This is an analog structure to CompilationInfo::inlined_functions. So I removed LChunk::inlined_functions and made Crankshaft use CompilationInfo::inlined_functions instead, because this was necessary to register the offsets into the literal array in a uniform way. This is a safe change because LChunk::inlined_functions has no other uses and the functions in CompilationInfo::inlined_functions have a strictly longer lifespan, being created earlier (in Hydrogen already).
BUG=v8:5432
Review-Url: https://codereview.chromium.org/2451853002
Cr-Commit-Position: refs/heads/master@{#40975}
2016-11-14 17:21:37 +00:00
|
|
|
struct InliningPosition;
|
2017-09-25 08:21:07 +00:00
|
|
|
class PropertyDescriptorObject;
|
This CL enables precise source positions for all V8 compilers. It merges compiler::SourcePosition and internal::SourcePosition to a single class used throughout the codebase. The new internal::SourcePosition instances store an id identifying an inlined function in addition to a script offset.
SourcePosition::InliningId() refers to a the new table DeoptimizationInputData::InliningPositions(), which provides the following data for every inlining id:
- The inlined SharedFunctionInfo as an offset into DeoptimizationInfo::LiteralArray
- The SourcePosition of the inlining. Recursively, this yields the full inlining stack.
Before the Code object is created, the same information can be found in CompilationInfo::inlined_functions().
If SourcePosition::InliningId() is SourcePosition::kNotInlined, it refers to the outer (non-inlined) function.
So every SourcePosition has full information about its inlining stack, as long as the corresponding Code object is known. The internal represenation of a source position is a positive 64bit integer.
All compilers create now appropriate source positions for inlined functions. In the case of Turbofan, this required using AstGraphBuilderWithPositions for inlined functions too. So this class is now moved to a header file.
At the moment, the additional information in source positions is only used in --trace-deopt and --code-comments. The profiler needs to be updated, at the moment it gets the correct script offsets from the deopt info, but the wrong script id from the reconstructed deopt stack, which can lead to wrong outputs. This should be resolved by making the profiler use the new inlining information for deopts.
I activated the inlined deoptimization tests in test-cpu-profiler.cc for Turbofan, changing them to a case where the deopt stack and the inlining position agree. It is currently still broken for other cases.
The following additional changes were necessary:
- The source position table (internal::SourcePositionTableBuilder etc.) supports now 64bit source positions. Encoding source positions in a single 64bit int together with the difference encoding in the source position table results in very little overhead for the inlining id, since only 12% of the source positions in Octane have a changed inlining id.
- The class HPositionInfo was effectively dead code and is now removed.
- SourcePosition has new printing and information facilities, including computing a full inlining stack.
- I had to rename compiler/source-position.{h,cc} to compiler/compiler-source-position-table.{h,cc} to avoid clashes with the new src/source-position.cc file.
- I wrote the new wrapper PodArray for ByteArray. It is a template working with any POD-type. This is used in DeoptimizationInputData::InliningPositions().
- I removed HInlinedFunctionInfo and HGraph::inlined_function_infos, because they were only used for the now obsolete Crankshaft inlining ids.
- Crankshaft managed a list of inlined functions in Lithium: LChunk::inlined_functions. This is an analog structure to CompilationInfo::inlined_functions. So I removed LChunk::inlined_functions and made Crankshaft use CompilationInfo::inlined_functions instead, because this was necessary to register the offsets into the literal array in a uniform way. This is a safe change because LChunk::inlined_functions has no other uses and the functions in CompilationInfo::inlined_functions have a strictly longer lifespan, being created earlier (in Hydrogen already).
BUG=v8:5432
Review-Url: https://codereview.chromium.org/2451853002
Cr-Commit-Position: refs/heads/master@{#40975}
2016-11-14 17:21:37 +00:00
|
|
|
|
2015-05-27 14:13:04 +00:00
|
|
|
// SKIP_WRITE_BARRIER skips the write barrier.
|
|
|
|
// UPDATE_WEAK_WRITE_BARRIER skips the marking part of the write barrier and
|
|
|
|
// only performs the generational part.
|
|
|
|
// UPDATE_WRITE_BARRIER is doing the full barrier, marking and generational.
|
|
|
|
enum WriteBarrierMode {
|
|
|
|
SKIP_WRITE_BARRIER,
|
|
|
|
UPDATE_WEAK_WRITE_BARRIER,
|
|
|
|
UPDATE_WRITE_BARRIER
|
|
|
|
};
|
2008-10-23 08:46:32 +00:00
|
|
|
|
2009-01-12 10:59:58 +00:00
|
|
|
|
2009-01-12 11:07:02 +00:00
|
|
|
// PropertyNormalizationMode is used to specify whether to keep
|
|
|
|
// inobject properties when normalizing properties of a JSObject.
|
2009-01-12 10:59:58 +00:00
|
|
|
enum PropertyNormalizationMode {
|
|
|
|
CLEAR_INOBJECT_PROPERTIES,
|
|
|
|
KEEP_INOBJECT_PROPERTIES
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-17 13:50:19 +00:00
|
|
|
// Indicates whether transitions can be added to a source map or not.
|
|
|
|
enum TransitionFlag {
|
|
|
|
INSERT_TRANSITION,
|
|
|
|
OMIT_TRANSITION
|
|
|
|
};
|
|
|
|
|
2012-09-19 09:54:10 +00:00
|
|
|
|
|
|
|
// Indicates whether the transition is simple: the target map of the transition
|
|
|
|
// either extends the current map with a new property, or it modifies the
|
|
|
|
// property that was added last to the current map.
|
2014-12-10 15:18:44 +00:00
|
|
|
enum SimpleTransitionFlag {
|
|
|
|
SIMPLE_PROPERTY_TRANSITION,
|
|
|
|
PROPERTY_TRANSITION,
|
2017-07-21 15:57:33 +00:00
|
|
|
SPECIAL_TRANSITION
|
2014-12-10 15:18:44 +00:00
|
|
|
};
|
2012-09-19 09:54:10 +00:00
|
|
|
|
Sharing of descriptor arrays.
This CL adds multiple things:
Transition arrays do not directly point at their descriptor array anymore, but rather do so via an indirect pointer (a JSGlobalPropertyCell).
An ownership bit is added to maps indicating whether it owns its own descriptor array or not.
Maps owning a descriptor array can pass on ownership if a transition from that map is generated; but only if the descriptor array stays exactly the same; or if a descriptor is added.
Maps that don't have ownership get ownership back if their direct child to which ownership was passed is cleared in ClearNonLiveTransitions.
To detect which descriptors in an array are valid, each map knows its own NumberOfOwnDescriptors. Since the descriptors are sorted in order of addition, if we search and find a descriptor with index bigger than this number, it is not valid for the given map.
We currently still build up an enumeration cache (although this may disappear). The enumeration cache is always built for the entire descriptor array, even if not all descriptors are owned by the map. Once a descriptor array has an enumeration cache for a given map; this invariant will always be true, even if the descriptor array was extended. The extended array will inherit the enumeration cache from the smaller descriptor array. If a map with more descriptors needs an enumeration cache, it's EnumLength will still be set to invalid, so it will have to recompute the enumeration cache. This new cache will also be valid for smaller maps since they have their own enumlength; and use this to loop over the cache. If the EnumLength is still invalid, but there is already a cache present that is big enough; we just initialize the EnumLength field for the map.
When we apply ClearNonLiveTransitions and descriptor ownership is passed back to a parent map, the descriptor array is trimmed in-place and resorted. At the same time, the enumeration cache is trimmed in-place.
Only transition arrays contain descriptor arrays. If we transition to a map and pass ownership of the descriptor array along, the child map will not store the descriptor array it owns. Rather its parent will keep the pointer. So for every leaf-map, we find the descriptor array by following the back pointer, reading out the transition array, and fetching the descriptor array from the JSGlobalPropertyCell. If a map has a transition array, we fetch it from there. If a map has undefined as its back-pointer and has no transition array; it is considered to have an empty descriptor array.
When we modify properties, we cannot share the descriptor array. To accommodate this, the child map will get its own transition array; even if there are not necessarily any transitions leaving from the child map. This is necessary since it's the only way to store its own descriptor array.
Review URL: https://chromiumcodereview.appspot.com/10909007
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12492 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-09-12 16:43:57 +00:00
|
|
|
// Indicates whether we are only interested in the descriptors of a particular
|
|
|
|
// map, or in all descriptors in the descriptor array.
|
|
|
|
enum DescriptorFlag {
|
|
|
|
ALL_DESCRIPTORS,
|
|
|
|
OWN_DESCRIPTORS
|
|
|
|
};
|
|
|
|
|
2010-08-18 13:00:38 +00:00
|
|
|
// Instance size sentinel for objects of variable size.
|
2011-11-29 10:56:11 +00:00
|
|
|
const int kVariableSizeSentinel = 0;
|
2010-08-18 13:00:38 +00:00
|
|
|
|
2014-07-31 07:50:26 +00:00
|
|
|
// We may store the unsigned bit field as signed Smi value and do not
|
|
|
|
// use the sign bit.
|
2016-04-13 13:51:23 +00:00
|
|
|
const int kStubMajorKeyBits = 8;
|
2014-07-31 07:50:26 +00:00
|
|
|
const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
|
2010-08-18 13:00:38 +00:00
|
|
|
|
2015-09-18 06:35:36 +00:00
|
|
|
// Result of an abstract relational comparison of x and y, implemented according
|
|
|
|
// to ES6 section 7.2.11 Abstract Relational Comparison.
|
|
|
|
enum class ComparisonResult {
|
|
|
|
kLessThan, // x < y
|
|
|
|
kEqual, // x = y
|
2015-09-28 18:05:56 +00:00
|
|
|
kGreaterThan, // x > y
|
2015-09-18 06:35:36 +00:00
|
|
|
kUndefined // at least one of x or y was undefined or NaN
|
|
|
|
};
|
|
|
|
|
2017-10-24 09:39:35 +00:00
|
|
|
// (Returns false whenever {result} is kUndefined.)
|
2017-10-25 17:43:04 +00:00
|
|
|
bool ComparisonResultToBool(Operation op, ComparisonResult result);
|
2017-10-24 09:39:35 +00:00
|
|
|
|
2018-07-05 09:06:51 +00:00
|
|
|
enum class OnNonExistent { kThrowReferenceError, kReturnUndefined };
|
|
|
|
|
2016-08-24 08:48:34 +00:00
|
|
|
class AbstractCode;
|
2012-05-24 10:40:24 +00:00
|
|
|
class AccessorPair;
|
2018-04-30 13:27:37 +00:00
|
|
|
class AccessCheckInfo;
|
2013-10-16 08:10:36 +00:00
|
|
|
class AllocationSite;
|
2017-12-01 11:33:03 +00:00
|
|
|
class ByteArray;
|
2015-06-25 12:19:55 +00:00
|
|
|
class Cell;
|
2014-11-26 11:53:27 +00:00
|
|
|
class ConsString;
|
2017-10-13 13:24:26 +00:00
|
|
|
class DependentCode;
|
2011-08-03 11:12:46 +00:00
|
|
|
class ElementsAccessor;
|
2017-08-30 04:21:29 +00:00
|
|
|
class EnumCache;
|
2011-08-12 13:54:27 +00:00
|
|
|
class FixedArrayBase;
|
2018-11-03 00:13:22 +00:00
|
|
|
class FixedDoubleArray;
|
2015-02-12 13:21:06 +00:00
|
|
|
class FunctionLiteral;
|
2018-04-27 08:31:07 +00:00
|
|
|
class FunctionTemplateInfo;
|
2018-11-07 03:24:08 +00:00
|
|
|
class JSAsyncGeneratorObject;
|
2018-11-03 00:13:22 +00:00
|
|
|
class JSGlobalProxy;
|
|
|
|
class JSPromise;
|
|
|
|
class JSProxy;
|
2015-10-19 13:47:24 +00:00
|
|
|
class KeyAccumulator;
|
2014-11-11 10:24:52 +00:00
|
|
|
class LayoutDescriptor;
|
2014-11-10 17:43:51 +00:00
|
|
|
class LookupIterator;
|
2016-01-26 15:03:40 +00:00
|
|
|
class FieldType;
|
2016-10-07 19:37:04 +00:00
|
|
|
class Module;
|
2016-09-12 12:54:47 +00:00
|
|
|
class ModuleInfoEntry;
|
2015-06-25 12:19:55 +00:00
|
|
|
class ObjectHashTable;
|
2018-04-27 08:31:07 +00:00
|
|
|
class ObjectTemplateInfo;
|
2014-11-11 10:24:52 +00:00
|
|
|
class ObjectVisitor;
|
2018-07-10 16:05:04 +00:00
|
|
|
class PreParsedScopeData;
|
2018-11-03 00:13:22 +00:00
|
|
|
class PropertyArray;
|
2015-06-25 12:19:55 +00:00
|
|
|
class PropertyCell;
|
2015-10-13 14:38:16 +00:00
|
|
|
class PropertyDescriptor;
|
2018-11-03 00:13:22 +00:00
|
|
|
class RegExpMatchInfo;
|
2017-04-25 13:32:18 +00:00
|
|
|
class RootVisitor;
|
2015-06-25 12:19:55 +00:00
|
|
|
class SafepointEntry;
|
2018-11-03 00:13:22 +00:00
|
|
|
class ScriptContextTable;
|
2015-06-25 12:19:55 +00:00
|
|
|
class SharedFunctionInfo;
|
2011-08-12 13:54:27 +00:00
|
|
|
class StringStream;
|
2018-11-03 00:13:22 +00:00
|
|
|
class Symbol;
|
2018-02-22 12:04:01 +00:00
|
|
|
class FeedbackCell;
|
2017-02-07 14:05:02 +00:00
|
|
|
class FeedbackMetadata;
|
|
|
|
class FeedbackVector;
|
2018-07-09 09:34:34 +00:00
|
|
|
class UncompiledData;
|
2018-04-27 08:31:07 +00:00
|
|
|
class TemplateInfo;
|
2015-12-03 13:18:19 +00:00
|
|
|
class TransitionArray;
|
2016-08-01 14:28:06 +00:00
|
|
|
class TemplateList;
|
2018-11-03 00:13:22 +00:00
|
|
|
class WasmInstanceObject;
|
|
|
|
class WasmMemoryObject;
|
2017-06-28 12:56:11 +00:00
|
|
|
template <typename T>
|
|
|
|
class ZoneForwardList;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-12-13 10:17:37 +00:00
|
|
|
#ifdef OBJECT_PRINT
|
2017-06-29 13:14:20 +00:00
|
|
|
#define DECL_PRINTER(Name) void Name##Print(std::ostream& os); // NOLINT
|
2012-12-13 10:17:37 +00:00
|
|
|
#else
|
2017-06-29 13:14:20 +00:00
|
|
|
#define DECL_PRINTER(Name)
|
2012-12-13 10:17:37 +00:00
|
|
|
#endif
|
|
|
|
|
2014-09-10 12:38:12 +00:00
|
|
|
#define OBJECT_TYPE_LIST(V) \
|
|
|
|
V(Smi) \
|
2016-02-16 12:57:29 +00:00
|
|
|
V(LayoutDescriptor) \
|
2014-09-10 12:38:12 +00:00
|
|
|
V(HeapObject) \
|
2016-02-16 12:57:29 +00:00
|
|
|
V(Primitive) \
|
2017-10-23 10:49:42 +00:00
|
|
|
V(Number) \
|
|
|
|
V(Numeric)
|
2014-09-10 12:38:12 +00:00
|
|
|
|
2018-05-15 20:50:46 +00:00
|
|
|
#define HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V) \
|
|
|
|
V(AbstractCode) \
|
|
|
|
V(AccessCheckNeeded) \
|
2018-06-12 14:15:04 +00:00
|
|
|
V(AllocationSite) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(ArrayList) \
|
|
|
|
V(BigInt) \
|
|
|
|
V(BigIntWrapper) \
|
2018-07-05 18:34:09 +00:00
|
|
|
V(ObjectBoilerplateDescription) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(Boolean) \
|
|
|
|
V(BooleanWrapper) \
|
|
|
|
V(BreakPoint) \
|
|
|
|
V(BreakPointInfo) \
|
|
|
|
V(ByteArray) \
|
|
|
|
V(BytecodeArray) \
|
|
|
|
V(CallHandlerInfo) \
|
|
|
|
V(Callable) \
|
|
|
|
V(Cell) \
|
|
|
|
V(ClassBoilerplate) \
|
|
|
|
V(Code) \
|
|
|
|
V(CodeDataContainer) \
|
|
|
|
V(CompilationCacheTable) \
|
|
|
|
V(ConsString) \
|
|
|
|
V(Constructor) \
|
|
|
|
V(Context) \
|
|
|
|
V(CoverageInfo) \
|
|
|
|
V(DataHandler) \
|
|
|
|
V(DeoptimizationData) \
|
|
|
|
V(DependentCode) \
|
|
|
|
V(DescriptorArray) \
|
2018-11-19 14:40:05 +00:00
|
|
|
V(EmbedderDataArray) \
|
2018-06-07 05:57:16 +00:00
|
|
|
V(EphemeronHashTable) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(EnumCache) \
|
|
|
|
V(ExternalOneByteString) \
|
|
|
|
V(ExternalString) \
|
|
|
|
V(ExternalTwoByteString) \
|
|
|
|
V(FeedbackCell) \
|
|
|
|
V(FeedbackMetadata) \
|
|
|
|
V(FeedbackVector) \
|
|
|
|
V(Filler) \
|
|
|
|
V(FixedArray) \
|
|
|
|
V(FixedArrayBase) \
|
|
|
|
V(FixedArrayExact) \
|
|
|
|
V(FixedBigInt64Array) \
|
|
|
|
V(FixedBigUint64Array) \
|
|
|
|
V(FixedDoubleArray) \
|
|
|
|
V(FixedFloat32Array) \
|
|
|
|
V(FixedFloat64Array) \
|
|
|
|
V(FixedInt16Array) \
|
|
|
|
V(FixedInt32Array) \
|
|
|
|
V(FixedInt8Array) \
|
|
|
|
V(FixedTypedArrayBase) \
|
|
|
|
V(FixedUint16Array) \
|
|
|
|
V(FixedUint32Array) \
|
|
|
|
V(FixedUint8Array) \
|
|
|
|
V(FixedUint8ClampedArray) \
|
|
|
|
V(Foreign) \
|
|
|
|
V(FrameArray) \
|
|
|
|
V(FreeSpace) \
|
|
|
|
V(Function) \
|
|
|
|
V(GlobalDictionary) \
|
|
|
|
V(HandlerTable) \
|
|
|
|
V(HeapNumber) \
|
|
|
|
V(InternalizedString) \
|
|
|
|
V(JSArgumentsObject) \
|
2018-11-21 15:20:40 +00:00
|
|
|
V(JSArgumentsObjectWithLength) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(JSArray) \
|
|
|
|
V(JSArrayBuffer) \
|
|
|
|
V(JSArrayBufferView) \
|
|
|
|
V(JSArrayIterator) \
|
|
|
|
V(JSAsyncFromSyncIterator) \
|
2018-10-11 08:35:56 +00:00
|
|
|
V(JSAsyncFunctionObject) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(JSAsyncGeneratorObject) \
|
|
|
|
V(JSBoundFunction) \
|
|
|
|
V(JSCollection) \
|
|
|
|
V(JSContextExtensionObject) \
|
|
|
|
V(JSDataView) \
|
|
|
|
V(JSDate) \
|
|
|
|
V(JSError) \
|
|
|
|
V(JSFunction) \
|
|
|
|
V(JSGeneratorObject) \
|
|
|
|
V(JSGlobalObject) \
|
|
|
|
V(JSGlobalProxy) \
|
|
|
|
V(JSMap) \
|
|
|
|
V(JSMapIterator) \
|
|
|
|
V(JSMessageObject) \
|
|
|
|
V(JSModuleNamespace) \
|
|
|
|
V(JSObject) \
|
|
|
|
V(JSPromise) \
|
|
|
|
V(JSProxy) \
|
|
|
|
V(JSReceiver) \
|
|
|
|
V(JSRegExp) \
|
2018-08-13 13:12:03 +00:00
|
|
|
V(JSRegExpResult) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(JSRegExpStringIterator) \
|
|
|
|
V(JSSet) \
|
|
|
|
V(JSSetIterator) \
|
|
|
|
V(JSSloppyArgumentsObject) \
|
|
|
|
V(JSStringIterator) \
|
|
|
|
V(JSTypedArray) \
|
|
|
|
V(JSValue) \
|
2018-10-09 12:08:23 +00:00
|
|
|
V(JSWeakCell) \
|
2018-11-05 14:21:02 +00:00
|
|
|
V(JSWeakRef) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(JSWeakCollection) \
|
2018-10-09 12:08:23 +00:00
|
|
|
V(JSWeakFactory) \
|
|
|
|
V(JSWeakFactoryCleanupIterator) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(JSWeakMap) \
|
|
|
|
V(JSWeakSet) \
|
|
|
|
V(LoadHandler) \
|
|
|
|
V(Map) \
|
|
|
|
V(MapCache) \
|
|
|
|
V(Microtask) \
|
|
|
|
V(ModuleInfo) \
|
|
|
|
V(MutableHeapNumber) \
|
|
|
|
V(Name) \
|
|
|
|
V(NameDictionary) \
|
|
|
|
V(NativeContext) \
|
|
|
|
V(NormalizedMapCache) \
|
|
|
|
V(NumberDictionary) \
|
|
|
|
V(NumberWrapper) \
|
|
|
|
V(ObjectHashSet) \
|
|
|
|
V(ObjectHashTable) \
|
|
|
|
V(Oddball) \
|
|
|
|
V(OrderedHashMap) \
|
|
|
|
V(OrderedHashSet) \
|
2018-11-12 10:31:52 +00:00
|
|
|
V(OrderedNameDictionary) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(PreParsedScopeData) \
|
|
|
|
V(PromiseReactionJobTask) \
|
|
|
|
V(PropertyArray) \
|
|
|
|
V(PropertyCell) \
|
|
|
|
V(PropertyDescriptorObject) \
|
|
|
|
V(RegExpMatchInfo) \
|
|
|
|
V(ScopeInfo) \
|
|
|
|
V(ScriptContextTable) \
|
|
|
|
V(ScriptWrapper) \
|
|
|
|
V(SeqOneByteString) \
|
|
|
|
V(SeqString) \
|
|
|
|
V(SeqTwoByteString) \
|
|
|
|
V(SharedFunctionInfo) \
|
|
|
|
V(SimpleNumberDictionary) \
|
|
|
|
V(SlicedString) \
|
|
|
|
V(SloppyArgumentsElements) \
|
|
|
|
V(SmallOrderedHashMap) \
|
|
|
|
V(SmallOrderedHashSet) \
|
2018-11-12 13:24:48 +00:00
|
|
|
V(SmallOrderedNameDictionary) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(SourcePositionTableWithFrameCache) \
|
|
|
|
V(StoreHandler) \
|
|
|
|
V(String) \
|
|
|
|
V(StringSet) \
|
|
|
|
V(StringTable) \
|
|
|
|
V(StringWrapper) \
|
|
|
|
V(Struct) \
|
|
|
|
V(Symbol) \
|
|
|
|
V(SymbolWrapper) \
|
|
|
|
V(TemplateInfo) \
|
|
|
|
V(TemplateList) \
|
|
|
|
V(TemplateObjectDescription) \
|
|
|
|
V(ThinString) \
|
|
|
|
V(TransitionArray) \
|
2018-07-09 09:34:34 +00:00
|
|
|
V(UncompiledData) \
|
|
|
|
V(UncompiledDataWithPreParsedScope) \
|
|
|
|
V(UncompiledDataWithoutPreParsedScope) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(Undetectable) \
|
|
|
|
V(UniqueName) \
|
2018-09-10 10:28:00 +00:00
|
|
|
V(WasmExceptionObject) \
|
2018-05-15 20:50:46 +00:00
|
|
|
V(WasmGlobalObject) \
|
|
|
|
V(WasmInstanceObject) \
|
|
|
|
V(WasmMemoryObject) \
|
|
|
|
V(WasmModuleObject) \
|
|
|
|
V(WasmTableObject) \
|
|
|
|
V(WeakFixedArray) \
|
2018-04-16 07:28:28 +00:00
|
|
|
V(WeakArrayList)
|
2013-08-02 09:53:11 +00:00
|
|
|
|
2018-05-15 20:50:46 +00:00
|
|
|
#ifdef V8_INTL_SUPPORT
|
|
|
|
#define HEAP_OBJECT_ORDINARY_TYPE_LIST(V) \
|
|
|
|
HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V) \
|
2018-09-05 02:17:38 +00:00
|
|
|
V(JSV8BreakIterator) \
|
2018-08-08 09:23:07 +00:00
|
|
|
V(JSCollator) \
|
2018-08-29 04:40:53 +00:00
|
|
|
V(JSDateTimeFormat) \
|
2018-07-24 21:07:50 +00:00
|
|
|
V(JSListFormat) \
|
2018-07-10 12:52:05 +00:00
|
|
|
V(JSLocale) \
|
2018-09-04 18:32:51 +00:00
|
|
|
V(JSNumberFormat) \
|
2018-08-06 09:31:26 +00:00
|
|
|
V(JSPluralRules) \
|
2018-10-05 01:57:05 +00:00
|
|
|
V(JSRelativeTimeFormat) \
|
2018-10-18 07:59:28 +00:00
|
|
|
V(JSSegmentIterator) \
|
2018-10-05 01:57:05 +00:00
|
|
|
V(JSSegmenter)
|
2018-05-15 20:50:46 +00:00
|
|
|
#else
|
|
|
|
#define HEAP_OBJECT_ORDINARY_TYPE_LIST(V) HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V)
|
|
|
|
#endif // V8_INTL_SUPPORT
|
|
|
|
|
2017-08-03 14:27:11 +00:00
|
|
|
#define HEAP_OBJECT_TEMPLATE_TYPE_LIST(V) \
|
|
|
|
V(Dictionary) \
|
2017-11-19 10:06:32 +00:00
|
|
|
V(HashTable)
|
2017-08-03 14:27:11 +00:00
|
|
|
|
|
|
|
#define HEAP_OBJECT_TYPE_LIST(V) \
|
|
|
|
HEAP_OBJECT_ORDINARY_TYPE_LIST(V) \
|
|
|
|
HEAP_OBJECT_TEMPLATE_TYPE_LIST(V)
|
|
|
|
|
2016-06-14 10:08:44 +00:00
|
|
|
#define ODDBALL_LIST(V) \
|
|
|
|
V(Undefined, undefined_value) \
|
|
|
|
V(Null, null_value) \
|
|
|
|
V(TheHole, the_hole_value) \
|
|
|
|
V(Exception, exception) \
|
|
|
|
V(Uninitialized, uninitialized_value) \
|
|
|
|
V(True, true_value) \
|
|
|
|
V(False, false_value) \
|
|
|
|
V(ArgumentsMarker, arguments_marker) \
|
|
|
|
V(OptimizedOut, optimized_out) \
|
|
|
|
V(StaleRegister, stale_register)
|
2016-02-16 12:57:29 +00:00
|
|
|
|
2015-12-17 08:40:49 +00:00
|
|
|
// The element types selection for CreateListFromArrayLike.
|
|
|
|
enum class ElementTypes { kAll, kStringAndSymbol };
|
|
|
|
|
2018-11-03 00:13:22 +00:00
|
|
|
// TODO(3770): Get rid of this indirection when the migration is complete.
|
2018-11-25 03:47:59 +00:00
|
|
|
typedef AbstractCode AbstractCodeArgType;
|
2018-11-24 08:51:21 +00:00
|
|
|
typedef ByteArray ByteArrayArgType;
|
2018-11-25 02:24:43 +00:00
|
|
|
typedef FixedArray FixedArrayArgType;
|
2018-11-24 02:42:52 +00:00
|
|
|
typedef FixedDoubleArray FixedDoubleArrayArgType;
|
2018-11-03 00:13:22 +00:00
|
|
|
typedef Foreign* ForeignArgType;
|
|
|
|
typedef HeapObject* HeapObjectArgType;
|
2018-12-08 02:59:17 +00:00
|
|
|
typedef JSArray JSArrayArgType;
|
|
|
|
typedef JSAsyncGeneratorObject JSAsyncGeneratorObjectArgType;
|
|
|
|
typedef JSFunction JSFunctionArgType;
|
|
|
|
typedef JSGlobalProxy JSGlobalProxyArgType;
|
|
|
|
typedef JSObject JSObjectArgType;
|
|
|
|
typedef JSPromise JSPromiseArgType;
|
|
|
|
typedef JSProxy JSProxyArgType;
|
2018-11-13 06:16:42 +00:00
|
|
|
typedef Map MapArgType;
|
2018-11-03 00:13:22 +00:00
|
|
|
typedef Object* ObjectArgType;
|
2018-11-24 01:13:39 +00:00
|
|
|
typedef RegExpMatchInfo RegExpMatchInfoArgType;
|
|
|
|
typedef ScriptContextTable ScriptContextTableArgType;
|
2018-11-28 19:57:30 +00:00
|
|
|
typedef SharedFunctionInfo SharedFunctionInfoArgType;
|
2018-11-22 23:55:32 +00:00
|
|
|
typedef SimpleNumberDictionary SimpleNumberDictionaryArgType;
|
2018-11-03 00:13:22 +00:00
|
|
|
typedef Smi SmiArgType;
|
2018-11-27 00:48:42 +00:00
|
|
|
typedef String StringArgType;
|
|
|
|
typedef Symbol SymbolArgType;
|
2018-11-24 01:13:39 +00:00
|
|
|
typedef TemplateList TemplateListArgType;
|
2018-12-08 02:59:17 +00:00
|
|
|
typedef WasmInstanceObject WasmInstanceObjectArgType;
|
|
|
|
typedef WasmMemoryObject WasmMemoryObjectArgType;
|
2018-11-03 00:13:22 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Object is the abstract superclass for all classes in the
|
|
|
|
// object hierarchy.
|
|
|
|
// Object does not use any virtual functions to avoid the
|
|
|
|
// allocation of the C++ vtable.
|
2014-04-30 12:25:18 +00:00
|
|
|
// Since both Smi and HeapObject are subclasses of Object no
|
2008-07-03 15:10:15 +00:00
|
|
|
// data members can be present in Object.
|
2014-04-30 12:25:18 +00:00
|
|
|
class Object {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
// Type testing.
|
2014-06-24 09:47:25 +00:00
|
|
|
bool IsObject() const { return true; }
|
Make the runtime entry for setting/changing accessors "atomic".
Previously, there were 1 or 2 calls to the runtime when accessors were changed
or set. This doesn't really work well with property attributes, leading to some
hacks and complicates things even further when trying to share maps in presence
of accessors. Therefore, the runtime entry now takes the full triple (getter,
setter, attributes), where the getter and/or the setter can be null in case they
shouldn't be changed.
For now, we do basically the same on the native side as we did before on the
JavaScript side, but this will change in future CLs, the current CL is already
large enough.
Note that object literals with a getter and a setter for the same property still
do 2 calls, but this is a little bit more tricky to fix and will be handled in a
separate CL.
Review URL: https://chromiumcodereview.appspot.com/9616016
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10956 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-03-07 13:24:44 +00:00
|
|
|
|
2018-10-24 01:44:19 +00:00
|
|
|
// Syntax compatibility with ObjectPtr, so the same macros can consume
|
|
|
|
// arguments of either type.
|
|
|
|
Address ptr() const { return reinterpret_cast<Address>(this); }
|
|
|
|
|
2018-06-22 11:19:13 +00:00
|
|
|
#define IS_TYPE_FUNCTION_DECL(Type) V8_INLINE bool Is##Type() const;
|
2011-01-19 08:04:48 +00:00
|
|
|
OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
|
|
|
|
HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
|
2016-06-14 10:08:44 +00:00
|
|
|
#undef IS_TYPE_FUNCTION_DECL
|
2017-01-09 13:40:51 +00:00
|
|
|
|
2018-06-22 11:19:13 +00:00
|
|
|
V8_INLINE bool IsExternal(Isolate* isolate) const;
|
2018-06-20 16:32:59 +00:00
|
|
|
|
2018-07-05 09:02:40 +00:00
|
|
|
// Oddball checks are faster when they are raw pointer comparisons, so the
|
|
|
|
// isolate/read-only roots overloads should be preferred where possible.
|
|
|
|
#define IS_TYPE_FUNCTION_DECL(Type, Value) \
|
|
|
|
V8_INLINE bool Is##Type(Isolate* isolate) const; \
|
|
|
|
V8_INLINE bool Is##Type(ReadOnlyRoots roots) const; \
|
|
|
|
V8_INLINE bool Is##Type() const;
|
2016-02-16 12:57:29 +00:00
|
|
|
ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
|
2011-01-19 08:04:48 +00:00
|
|
|
#undef IS_TYPE_FUNCTION_DECL
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2018-06-22 11:19:13 +00:00
|
|
|
V8_INLINE bool IsNullOrUndefined(Isolate* isolate) const;
|
2018-07-05 09:02:40 +00:00
|
|
|
V8_INLINE bool IsNullOrUndefined(ReadOnlyRoots roots) const;
|
2018-06-22 11:19:13 +00:00
|
|
|
V8_INLINE bool IsNullOrUndefined() const;
|
2018-06-12 09:16:35 +00:00
|
|
|
|
2017-10-10 16:00:31 +00:00
|
|
|
enum class Conversion { kToNumber, kToNumeric };
|
|
|
|
|
2015-10-23 09:39:37 +00:00
|
|
|
#define RETURN_FAILURE(isolate, should_throw, call) \
|
|
|
|
do { \
|
2017-10-25 18:07:04 +00:00
|
|
|
if ((should_throw) == kDontThrow) { \
|
2015-10-23 09:39:37 +00:00
|
|
|
return Just(false); \
|
|
|
|
} else { \
|
|
|
|
isolate->Throw(*isolate->factory()->call); \
|
|
|
|
return Nothing<bool>(); \
|
|
|
|
} \
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
#define MAYBE_RETURN(call, value) \
|
|
|
|
do { \
|
|
|
|
if ((call).IsNothing()) return value; \
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
#define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>())
|
|
|
|
|
2018-07-18 13:21:06 +00:00
|
|
|
#define MAYBE_ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call) \
|
|
|
|
do { \
|
|
|
|
Isolate* __isolate__ = (isolate); \
|
|
|
|
if (!(call).To(&dst)) { \
|
|
|
|
DCHECK(__isolate__->has_pending_exception()); \
|
|
|
|
return ReadOnlyRoots(__isolate__).exception(); \
|
|
|
|
} \
|
|
|
|
} while (false)
|
|
|
|
|
2018-06-22 11:19:13 +00:00
|
|
|
#define DECL_STRUCT_PREDICATE(NAME, Name, name) V8_INLINE bool Is##Name() const;
|
2017-06-29 13:14:20 +00:00
|
|
|
STRUCT_LIST(DECL_STRUCT_PREDICATE)
|
|
|
|
#undef DECL_STRUCT_PREDICATE
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-06-06 15:55:33 +00:00
|
|
|
// ES6, #sec-isarray. NOT to be confused with %_IsArray.
|
2018-06-22 11:19:13 +00:00
|
|
|
V8_INLINE
|
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> IsArray(Handle<Object> object);
|
2015-12-03 12:51:15 +00:00
|
|
|
|
2018-06-22 11:19:13 +00:00
|
|
|
V8_INLINE bool IsSmallOrderedHashTable() const;
|
2011-07-21 13:51:04 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Extract the number.
|
2015-09-15 13:14:36 +00:00
|
|
|
inline double Number() const;
|
2018-06-22 11:19:13 +00:00
|
|
|
V8_INLINE bool IsNaN() const;
|
|
|
|
V8_INLINE bool IsMinusZero() const;
|
2017-05-03 09:58:03 +00:00
|
|
|
V8_EXPORT_PRIVATE bool ToInt32(int32_t* value);
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool ToUint32(uint32_t* value) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline Representation OptimalRepresentation();
|
2013-04-26 15:30:41 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline ElementsKind OptimalElementsKind();
|
2015-06-23 11:35:43 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool FitsRepresentation(Representation representation);
|
2013-04-26 15:30:41 +00:00
|
|
|
|
2015-05-20 17:03:21 +00:00
|
|
|
// Checks whether two valid primitive encodings of a property name resolve to
|
|
|
|
// the same logical property. E.g., the smi 1, the string "1" and the double
|
|
|
|
// 1 all refer to the same property, so this helper will return true.
|
|
|
|
inline bool KeyEquals(Object* other);
|
|
|
|
|
2015-12-02 16:30:06 +00:00
|
|
|
inline bool FilterKey(PropertyFilter filter);
|
2015-10-19 13:47:24 +00:00
|
|
|
|
2016-01-26 15:03:40 +00:00
|
|
|
Handle<FieldType> OptimalType(Isolate* isolate,
|
|
|
|
Representation representation);
|
2014-04-15 07:36:47 +00:00
|
|
|
|
2014-04-15 12:11:39 +00:00
|
|
|
inline static Handle<Object> NewStorageFor(Isolate* isolate,
|
|
|
|
Handle<Object> object,
|
|
|
|
Representation representation);
|
2013-05-08 15:02:08 +00:00
|
|
|
|
2014-07-01 15:02:31 +00:00
|
|
|
inline static Handle<Object> WrapForRead(Isolate* isolate,
|
|
|
|
Handle<Object> object,
|
|
|
|
Representation representation);
|
|
|
|
|
2011-06-09 10:03:35 +00:00
|
|
|
// Returns true if the object is of the correct type to be used as a
|
|
|
|
// implementation of a JSObject's elements.
|
|
|
|
inline bool HasValidElements();
|
|
|
|
|
2018-05-25 13:39:45 +00:00
|
|
|
// ECMA-262 9.2.
|
|
|
|
bool BooleanValue(Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-09-18 06:35:36 +00:00
|
|
|
// ES6 section 7.2.11 Abstract Relational Comparison
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<ComparisonResult> Compare(
|
2018-06-20 12:44:39 +00:00
|
|
|
Isolate* isolate, Handle<Object> x, Handle<Object> y);
|
2015-09-18 06:35:36 +00:00
|
|
|
|
2015-09-15 13:14:36 +00:00
|
|
|
// ES6 section 7.2.12 Abstract Equality Comparison
|
2018-06-20 12:44:39 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> Equals(Isolate* isolate,
|
|
|
|
Handle<Object> x,
|
2018-04-09 15:12:07 +00:00
|
|
|
Handle<Object> y);
|
2015-09-15 13:14:36 +00:00
|
|
|
|
2015-08-17 08:01:55 +00:00
|
|
|
// ES6 section 7.2.13 Strict Equality Comparison
|
|
|
|
bool StrictEquals(Object* that);
|
|
|
|
|
2017-04-24 20:53:37 +00:00
|
|
|
// ES6 section 7.1.13 ToObject
|
2008-07-03 15:10:15 +00:00
|
|
|
// Convert to a JSObject if needed.
|
2012-08-17 09:03:08 +00:00
|
|
|
// native_context is used when creating wrapper object.
|
2017-04-24 20:53:37 +00:00
|
|
|
//
|
|
|
|
// Passing a non-null method_name allows us to give a more informative
|
|
|
|
// error message for those cases where ToObject is being called on
|
|
|
|
// the receiver of a built-in method.
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<JSReceiver> ToObject(
|
2017-04-24 20:53:37 +00:00
|
|
|
Isolate* isolate, Handle<Object> object,
|
|
|
|
const char* method_name = nullptr);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> ToObject(
|
2017-04-24 20:53:37 +00:00
|
|
|
Isolate* isolate, Handle<Object> object, Handle<Context> native_context,
|
|
|
|
const char* method_name = nullptr);
|
2015-08-27 12:50:31 +00:00
|
|
|
|
2016-04-29 10:14:42 +00:00
|
|
|
// ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee.
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> ConvertReceiver(
|
2016-04-29 10:14:42 +00:00
|
|
|
Isolate* isolate, Handle<Object> object);
|
|
|
|
|
2015-08-28 09:21:23 +00:00
|
|
|
// ES6 section 7.1.14 ToPropertyKey
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Name> ToName(
|
|
|
|
Isolate* isolate, Handle<Object> input);
|
2015-08-28 09:21:23 +00:00
|
|
|
|
|
|
|
// ES6 section 7.1.1 ToPrimitive
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToPrimitive(
|
2015-08-28 09:21:23 +00:00
|
|
|
Handle<Object> input, ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
|
|
|
|
|
|
|
|
// ES6 section 7.1.3 ToNumber
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToNumber(
|
2018-07-13 09:17:37 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2015-08-28 09:21:23 +00:00
|
|
|
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToNumeric(
|
2018-07-13 09:17:37 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2017-10-10 16:00:31 +00:00
|
|
|
|
2015-09-29 07:41:03 +00:00
|
|
|
// ES6 section 7.1.4 ToInteger
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToInteger(
|
2016-12-16 14:30:05 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2015-09-29 07:41:03 +00:00
|
|
|
|
|
|
|
// ES6 section 7.1.5 ToInt32
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToInt32(
|
2016-12-16 14:30:05 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2015-09-29 07:41:03 +00:00
|
|
|
|
|
|
|
// ES6 section 7.1.6 ToUint32
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT inline static MaybeHandle<Object> ToUint32(
|
2016-12-16 14:30:05 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2015-09-29 07:41:03 +00:00
|
|
|
|
2015-08-28 09:21:23 +00:00
|
|
|
// ES6 section 7.1.12 ToString
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<String> ToString(
|
2016-12-16 14:30:05 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2015-08-28 09:21:23 +00:00
|
|
|
|
2016-08-03 12:20:39 +00:00
|
|
|
static Handle<String> NoSideEffectsToString(Isolate* isolate,
|
|
|
|
Handle<Object> input);
|
|
|
|
|
2016-04-29 10:14:42 +00:00
|
|
|
// ES6 section 7.1.14 ToPropertyKey
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToPropertyKey(
|
2016-04-29 10:14:42 +00:00
|
|
|
Isolate* isolate, Handle<Object> value);
|
|
|
|
|
2015-09-29 07:41:03 +00:00
|
|
|
// ES6 section 7.1.15 ToLength
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToLength(
|
2016-12-20 12:21:00 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2015-09-29 07:41:03 +00:00
|
|
|
|
Reland of Amend DataView, ArrayBuffer, and TypedArray methods to use ToIndex. (patchset #2 id:170001 of https://codereview.chromium.org/2113593002/ )
Reason for revert:
WebGL tests have been updated and rolled (at https://codereview.chromium.org/2227023002), so this should no longer fail outdated tests.
Original issue's description:
> Revert of Amend DataView, ArrayBuffer, and TypedArray methods to use ToIndex. (patchset #8 id:140001 of https://codereview.chromium.org/2090353003/ )
>
> Reason for revert:
> Speculative revert to unblock roll: https://codereview.chromium.org/2107223003/
>
> Original issue's description:
> > Amend DataView, ArrayBuffer, and TypedArray methods to use ToIndex.
> >
> > The spec was modified to relax some requirements which implementors had not been
> > enforcing. Part of this process involved introducing a new abstract operation
> > ToIndex, which had partial overlap with our existing semantics as well as some
> > differences (most notably treating undefined as 0). Test262 tests were introduced to
> > check for the new semantics, some of which we were failing. This patch amends the
> > parts of our implementation corresponding to specification algorithms which use
> > ToIndex to follow its semantics precisely.
> >
> > BUG=v8:4784,v8:5120
> >
> > Committed: https://crrev.com/09720349ea058d178521ec58d0a5676443a5a132
> > Cr-Commit-Position: refs/heads/master@{#37406}
>
> TBR=littledan@chromium.org,adamk@chromium.org,bakkot@google.com
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=v8:4784,v8:5120
>
> Committed: https://crrev.com/b1f7f1f4e41a723d5f997738a07e35a031713b8f
> Cr-Commit-Position: refs/heads/master@{#37417}
TBR=littledan@chromium.org,adamk@chromium.org,hablich@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=v8:4784,v8:5120
Review-Url: https://codereview.chromium.org/2247073004
Cr-Commit-Position: refs/heads/master@{#38689}
2016-08-17 17:38:34 +00:00
|
|
|
// ES6 section 7.1.17 ToIndex
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToIndex(
|
2018-10-11 21:35:34 +00:00
|
|
|
Isolate* isolate, Handle<Object> input, MessageTemplate error_index);
|
Reland of Amend DataView, ArrayBuffer, and TypedArray methods to use ToIndex. (patchset #2 id:170001 of https://codereview.chromium.org/2113593002/ )
Reason for revert:
WebGL tests have been updated and rolled (at https://codereview.chromium.org/2227023002), so this should no longer fail outdated tests.
Original issue's description:
> Revert of Amend DataView, ArrayBuffer, and TypedArray methods to use ToIndex. (patchset #8 id:140001 of https://codereview.chromium.org/2090353003/ )
>
> Reason for revert:
> Speculative revert to unblock roll: https://codereview.chromium.org/2107223003/
>
> Original issue's description:
> > Amend DataView, ArrayBuffer, and TypedArray methods to use ToIndex.
> >
> > The spec was modified to relax some requirements which implementors had not been
> > enforcing. Part of this process involved introducing a new abstract operation
> > ToIndex, which had partial overlap with our existing semantics as well as some
> > differences (most notably treating undefined as 0). Test262 tests were introduced to
> > check for the new semantics, some of which we were failing. This patch amends the
> > parts of our implementation corresponding to specification algorithms which use
> > ToIndex to follow its semantics precisely.
> >
> > BUG=v8:4784,v8:5120
> >
> > Committed: https://crrev.com/09720349ea058d178521ec58d0a5676443a5a132
> > Cr-Commit-Position: refs/heads/master@{#37406}
>
> TBR=littledan@chromium.org,adamk@chromium.org,bakkot@google.com
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=v8:4784,v8:5120
>
> Committed: https://crrev.com/b1f7f1f4e41a723d5f997738a07e35a031713b8f
> Cr-Commit-Position: refs/heads/master@{#37417}
TBR=littledan@chromium.org,adamk@chromium.org,hablich@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=v8:4784,v8:5120
Review-Url: https://codereview.chromium.org/2247073004
Cr-Commit-Position: refs/heads/master@{#38689}
2016-08-17 17:38:34 +00:00
|
|
|
|
2015-08-28 09:21:23 +00:00
|
|
|
// ES6 section 7.3.9 GetMethod
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetMethod(
|
2015-08-28 09:21:23 +00:00
|
|
|
Handle<JSReceiver> receiver, Handle<Name> name);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-12-17 08:40:49 +00:00
|
|
|
// ES6 section 7.3.17 CreateListFromArrayLike
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<FixedArray> CreateListFromArrayLike(
|
2015-12-17 08:40:49 +00:00
|
|
|
Isolate* isolate, Handle<Object> object, ElementTypes element_types);
|
|
|
|
|
2016-05-20 13:19:02 +00:00
|
|
|
// Get length property and apply ToLength.
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetLengthFromArrayLike(
|
2018-08-06 23:02:30 +00:00
|
|
|
Isolate* isolate, Handle<JSReceiver> object);
|
2016-05-20 13:19:02 +00:00
|
|
|
|
2015-09-03 06:01:12 +00:00
|
|
|
// ES6 section 12.5.6 The typeof Operator
|
|
|
|
static Handle<String> TypeOf(Isolate* isolate, Handle<Object> object);
|
|
|
|
|
2015-09-10 13:04:15 +00:00
|
|
|
// ES6 section 12.7 Additive Operators
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> Add(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
2015-09-10 13:04:15 +00:00
|
|
|
|
2015-09-18 06:35:36 +00:00
|
|
|
// ES6 section 12.9 Relational Operators
|
2018-06-20 12:44:39 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline Maybe<bool> GreaterThan(Isolate* isolate,
|
|
|
|
Handle<Object> x,
|
2018-04-09 15:12:07 +00:00
|
|
|
Handle<Object> y);
|
|
|
|
V8_WARN_UNUSED_RESULT static inline Maybe<bool> GreaterThanOrEqual(
|
2018-06-20 12:44:39 +00:00
|
|
|
Isolate* isolate, Handle<Object> x, Handle<Object> y);
|
|
|
|
V8_WARN_UNUSED_RESULT static inline Maybe<bool> LessThan(Isolate* isolate,
|
|
|
|
Handle<Object> x,
|
2018-04-09 15:12:07 +00:00
|
|
|
Handle<Object> y);
|
|
|
|
V8_WARN_UNUSED_RESULT static inline Maybe<bool> LessThanOrEqual(
|
2018-06-20 12:44:39 +00:00
|
|
|
Isolate* isolate, Handle<Object> x, Handle<Object> y);
|
2015-09-18 06:35:36 +00:00
|
|
|
|
2016-05-17 11:23:59 +00:00
|
|
|
// ES6 section 7.3.19 OrdinaryHasInstance (C, O).
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> OrdinaryHasInstance(
|
2016-05-17 11:23:59 +00:00
|
|
|
Isolate* isolate, Handle<Object> callable, Handle<Object> object);
|
|
|
|
|
|
|
|
// ES6 section 12.10.4 Runtime Semantics: InstanceofOperator(O, C)
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> InstanceOf(
|
2016-05-17 11:23:59 +00:00
|
|
|
Isolate* isolate, Handle<Object> object, Handle<Object> callable);
|
|
|
|
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
|
2018-07-05 09:06:51 +00:00
|
|
|
GetProperty(LookupIterator* it,
|
|
|
|
OnNonExistent on_non_existent = OnNonExistent::kReturnUndefined);
|
2014-07-22 08:28:49 +00:00
|
|
|
|
2017-10-25 18:07:04 +00:00
|
|
|
// ES6 [[Set]] (when passed kDontThrow)
|
2015-10-23 09:39:37 +00:00
|
|
|
// Invariants for this and related functions (unless stated otherwise):
|
|
|
|
// 1) When the result is Nothing, an exception is pending.
|
2017-10-25 18:07:04 +00:00
|
|
|
// 2) When passed kThrowOnError, the result is never Just(false).
|
2015-10-23 09:39:37 +00:00
|
|
|
// In some cases, an exception is thrown regardless of the ShouldThrow
|
|
|
|
// argument. These cases are either in accordance with the spec or not
|
|
|
|
// covered by it (eg., concerning API callbacks).
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> SetProperty(
|
|
|
|
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
|
2018-09-10 10:49:08 +00:00
|
|
|
StoreOrigin store_origin);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SetProperty(
|
2018-07-17 08:49:20 +00:00
|
|
|
Isolate* isolate, Handle<Object> object, Handle<Name> name,
|
|
|
|
Handle<Object> value, LanguageMode language_mode,
|
2018-09-10 10:49:08 +00:00
|
|
|
StoreOrigin store_origin = StoreOrigin::kMaybeKeyed);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> SetPropertyOrElement(
|
2018-07-13 09:17:37 +00:00
|
|
|
Isolate* isolate, Handle<Object> object, Handle<Name> name,
|
|
|
|
Handle<Object> value, LanguageMode language_mode,
|
2018-09-10 10:49:08 +00:00
|
|
|
StoreOrigin store_origin = StoreOrigin::kMaybeKeyed);
|
2015-02-19 16:15:25 +00:00
|
|
|
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> SetSuperProperty(
|
2015-02-19 16:15:25 +00:00
|
|
|
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
|
2018-09-10 10:49:08 +00:00
|
|
|
StoreOrigin store_origin);
|
2015-02-19 16:15:25 +00:00
|
|
|
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> CannotCreateProperty(
|
2015-10-09 09:12:28 +00:00
|
|
|
Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
|
2015-10-30 10:45:30 +00:00
|
|
|
Handle<Object> value, ShouldThrow should_throw);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> WriteToReadOnlyProperty(
|
2015-10-30 10:45:30 +00:00
|
|
|
LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> WriteToReadOnlyProperty(
|
2015-06-30 15:24:27 +00:00
|
|
|
Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
|
2015-10-30 10:45:30 +00:00
|
|
|
Handle<Object> value, ShouldThrow should_throw);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> RedefineIncompatibleProperty(
|
2015-02-19 16:15:25 +00:00
|
|
|
Isolate* isolate, Handle<Object> name, Handle<Object> value,
|
2015-10-30 10:45:30 +00:00
|
|
|
ShouldThrow should_throw);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> SetDataProperty(
|
|
|
|
LookupIterator* it, Handle<Object> value);
|
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> AddDataProperty(
|
2015-10-23 09:39:37 +00:00
|
|
|
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
|
2018-09-10 10:49:08 +00:00
|
|
|
ShouldThrow should_throw, StoreOrigin store_origin);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
|
2018-07-13 09:17:37 +00:00
|
|
|
Isolate* isolate, Handle<Object> object, Handle<Name> name);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
|
2016-02-17 10:30:10 +00:00
|
|
|
Handle<Object> receiver, Handle<Name> name, Handle<JSReceiver> holder);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetProperty(
|
2018-07-17 08:49:20 +00:00
|
|
|
Isolate* isolate, Handle<Object> object, Handle<Name> name);
|
2011-10-18 12:19:18 +00:00
|
|
|
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetPropertyWithAccessor(
|
2016-02-17 10:30:10 +00:00
|
|
|
LookupIterator* it);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyWithAccessor(
|
2015-10-30 10:45:30 +00:00
|
|
|
LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
|
2014-05-28 09:29:27 +00:00
|
|
|
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetPropertyWithDefinedGetter(
|
|
|
|
Handle<Object> receiver, Handle<JSReceiver> getter);
|
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyWithDefinedSetter(
|
2015-10-23 09:39:37 +00:00
|
|
|
Handle<Object> receiver, Handle<JSReceiver> setter, Handle<Object> value,
|
|
|
|
ShouldThrow should_throw);
|
2010-10-25 15:22:03 +00:00
|
|
|
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetElement(
|
2016-02-17 10:30:10 +00:00
|
|
|
Isolate* isolate, Handle<Object> object, uint32_t index);
|
2014-03-18 12:34:02 +00:00
|
|
|
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> SetElement(
|
2015-07-10 16:11:00 +00:00
|
|
|
Isolate* isolate, Handle<Object> object, uint32_t index,
|
|
|
|
Handle<Object> value, LanguageMode language_mode);
|
|
|
|
|
2013-11-05 11:47:11 +00:00
|
|
|
// Returns the permanent hash code associated with this object. May return
|
|
|
|
// undefined if not yet created.
|
2018-05-15 00:17:04 +00:00
|
|
|
inline Object* GetHash();
|
2013-11-05 11:47:11 +00:00
|
|
|
|
2011-10-25 14:14:56 +00:00
|
|
|
// Returns the permanent hash code associated with this object depending on
|
2013-11-05 11:47:11 +00:00
|
|
|
// the actual object type. May create and store a hash code if needed and none
|
|
|
|
// exists.
|
2018-11-03 00:13:22 +00:00
|
|
|
Smi GetOrCreateHash(Isolate* isolate);
|
2011-10-25 14:14:56 +00:00
|
|
|
|
|
|
|
// Checks whether this object has the same value as the given one. This
|
|
|
|
// function is implemented according to ES5, section 9.12 and can be used
|
2018-10-12 09:55:44 +00:00
|
|
|
// to implement the Object.is function.
|
2016-10-17 10:01:42 +00:00
|
|
|
V8_EXPORT_PRIVATE bool SameValue(Object* other);
|
2011-10-25 14:14:56 +00:00
|
|
|
|
2014-05-21 08:47:02 +00:00
|
|
|
// Checks whether this object has the same value as the given one.
|
|
|
|
// +0 and -0 are treated equal. Everything else is the same as SameValue.
|
|
|
|
// This function is implemented according to ES6, section 7.2.4 and is used
|
|
|
|
// by ES6 Map and Set.
|
|
|
|
bool SameValueZero(Object* other);
|
|
|
|
|
2016-01-07 02:29:50 +00:00
|
|
|
// ES6 section 9.4.2.3 ArraySpeciesCreate (part of it)
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ArraySpeciesConstructor(
|
2016-01-07 02:29:50 +00:00
|
|
|
Isolate* isolate, Handle<Object> original_array);
|
|
|
|
|
2017-02-28 20:31:02 +00:00
|
|
|
// ES6 section 7.3.20 SpeciesConstructor ( O, defaultConstructor )
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SpeciesConstructor(
|
2017-02-28 20:31:02 +00:00
|
|
|
Isolate* isolate, Handle<JSReceiver> recv,
|
|
|
|
Handle<JSFunction> default_ctor);
|
|
|
|
|
2015-06-02 10:42:16 +00:00
|
|
|
// Tries to convert an object to an array length. Returns true and sets the
|
|
|
|
// output parameter if it succeeds.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool ToArrayLength(uint32_t* index) const;
|
2015-06-02 10:42:16 +00:00
|
|
|
|
|
|
|
// Tries to convert an object to an array index. Returns true and sets the
|
|
|
|
// output parameter if it succeeds. Equivalent to ToArrayLength, but does not
|
|
|
|
// allow kMaxUInt32.
|
2018-10-16 09:56:41 +00:00
|
|
|
V8_WARN_UNUSED_RESULT inline bool ToArrayIndex(uint32_t* index) const;
|
2010-05-27 12:30:45 +00:00
|
|
|
|
2016-12-07 08:34:51 +00:00
|
|
|
// Returns true if the result of iterating over the object is the same
|
|
|
|
// (including observable effects) as simply accessing the properties between 0
|
|
|
|
// and length.
|
|
|
|
bool IterationHasObservableEffects();
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(Object)
|
2012-10-12 11:41:14 +00:00
|
|
|
#ifdef VERIFY_HEAP
|
2008-07-03 15:10:15 +00:00
|
|
|
// Verify a pointer is a valid object pointer.
|
2018-07-17 13:28:38 +00:00
|
|
|
static void VerifyPointer(Isolate* isolate, Object* p);
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif
|
|
|
|
|
2012-09-10 13:38:21 +00:00
|
|
|
inline void VerifyApiCallResultType();
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Prints this object without details.
|
2013-08-30 07:41:24 +00:00
|
|
|
void ShortPrint(FILE* out = stdout);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Prints this object without details to a message accumulator.
|
|
|
|
void ShortPrint(StringStream* accumulator);
|
|
|
|
|
2014-12-08 09:26:04 +00:00
|
|
|
void ShortPrint(std::ostream& os); // NOLINT
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(Object)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Layout description.
|
2008-09-23 11:45:43 +00:00
|
|
|
static const int kHeaderSize = 0; // Object does not take up any space.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-30 12:25:18 +00:00
|
|
|
#ifdef OBJECT_PRINT
|
2014-07-08 08:43:20 +00:00
|
|
|
// For our gdb macros, we should perhaps change these in the future.
|
2018-07-12 10:06:42 +00:00
|
|
|
void Print();
|
2014-07-08 08:43:20 +00:00
|
|
|
|
2014-04-30 12:25:18 +00:00
|
|
|
// Prints this object with details.
|
2018-07-12 10:06:42 +00:00
|
|
|
void Print(std::ostream& os); // NOLINT
|
2014-12-08 09:26:04 +00:00
|
|
|
#else
|
2018-07-12 10:06:42 +00:00
|
|
|
void Print() { ShortPrint(); }
|
|
|
|
void Print(std::ostream& os) { ShortPrint(os); } // NOLINT
|
2014-04-30 12:25:18 +00:00
|
|
|
#endif
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
2014-07-14 10:54:24 +00:00
|
|
|
friend class LookupIterator;
|
2016-02-08 13:49:47 +00:00
|
|
|
friend class StringStream;
|
2014-07-14 07:19:49 +00:00
|
|
|
|
|
|
|
// Return the map of the root of object's prototype chain.
|
2018-11-13 06:16:42 +00:00
|
|
|
Map GetPrototypeChainRootMap(Isolate* isolate) const;
|
2014-07-14 07:19:49 +00:00
|
|
|
|
2018-05-15 00:17:04 +00:00
|
|
|
// Returns a non-SMI for JSReceivers, but returns the hash code for
|
|
|
|
// simple objects. This avoids a double lookup in the cases where
|
|
|
|
// we know we will add the hash to the JSReceiver if it does not
|
|
|
|
// already exist.
|
|
|
|
//
|
|
|
|
// Despite its size, this needs to be inlined for performance
|
|
|
|
// reasons.
|
|
|
|
static inline Object* GetSimpleHash(Object* object);
|
|
|
|
|
2015-02-19 16:15:25 +00:00
|
|
|
// Helper for SetProperty and SetSuperProperty.
|
2015-10-23 09:39:37 +00:00
|
|
|
// Return value is only meaningful if [found] is set to true on return.
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyInternal(
|
2015-02-19 16:15:25 +00:00
|
|
|
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
|
2018-09-10 10:49:08 +00:00
|
|
|
StoreOrigin store_origin, bool* found);
|
2015-02-19 16:15:25 +00:00
|
|
|
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Name> ConvertToName(
|
|
|
|
Isolate* isolate, Handle<Object> input);
|
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToPropertyKey(
|
2016-12-20 12:21:00 +00:00
|
|
|
Isolate* isolate, Handle<Object> value);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ConvertToString(
|
2016-12-16 14:30:05 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToNumberOrNumeric(
|
2017-10-10 16:00:31 +00:00
|
|
|
Isolate* isolate, Handle<Object> input, Conversion mode);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToInteger(
|
2016-12-16 14:30:05 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToInt32(
|
2016-12-16 14:30:05 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToUint32(
|
2016-12-16 14:30:05 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToLength(
|
2016-12-20 12:21:00 +00:00
|
|
|
Isolate* isolate, Handle<Object> input);
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToIndex(
|
2018-10-11 21:35:34 +00:00
|
|
|
Isolate* isolate, Handle<Object> input, MessageTemplate error_index);
|
2016-12-20 12:21:00 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Object);
|
|
|
|
};
|
|
|
|
|
2015-08-14 08:48:11 +00:00
|
|
|
// In objects.h to be usable without objects-inl.h inclusion.
|
2018-10-26 00:23:24 +00:00
|
|
|
bool Object::IsSmi() const { return HAS_SMI_TAG(ptr()); }
|
2017-02-27 09:07:25 +00:00
|
|
|
bool Object::IsHeapObject() const {
|
2018-10-26 00:23:24 +00:00
|
|
|
DCHECK_EQ(!IsSmi(), Internals::HasHeapObjectTag(ptr()));
|
2017-02-27 09:07:25 +00:00
|
|
|
return !IsSmi();
|
|
|
|
}
|
2015-08-14 08:48:11 +00:00
|
|
|
|
2014-07-07 09:57:29 +00:00
|
|
|
struct Brief {
|
2018-08-16 14:23:02 +00:00
|
|
|
V8_EXPORT_PRIVATE explicit Brief(const Object* v);
|
2018-10-26 00:23:24 +00:00
|
|
|
explicit Brief(const MaybeObject v);
|
|
|
|
// {value} is a tagged heap object reference (weak or strong), equivalent to
|
|
|
|
// a MaybeObject's payload. It has a plain Address type to keep #includes
|
|
|
|
// lightweight.
|
|
|
|
const Address value;
|
2018-04-05 09:33:56 +00:00
|
|
|
};
|
|
|
|
|
2016-10-17 10:01:42 +00:00
|
|
|
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const Brief& v);
|
2014-07-07 09:57:29 +00:00
|
|
|
|
2008-07-30 08:49:36 +00:00
|
|
|
// Heap objects typically have a map pointer in their first word. However,
|
2012-01-16 12:38:59 +00:00
|
|
|
// during GC other data (e.g. mark bits, forwarding addresses) is sometimes
|
2008-07-30 08:49:36 +00:00
|
|
|
// encoded in the first word. The class MapWord is an abstraction of the
|
|
|
|
// value in a heap object's first word.
|
2018-09-06 09:08:10 +00:00
|
|
|
class MapWord {
|
2008-07-30 08:49:36 +00:00
|
|
|
public:
|
|
|
|
// Normal state: the map word contains a map pointer.
|
|
|
|
|
|
|
|
// Create a map word from a map pointer.
|
2018-11-13 06:16:42 +00:00
|
|
|
static inline MapWord FromMap(const Map map);
|
2008-07-30 08:49:36 +00:00
|
|
|
|
|
|
|
// View this map word as a map pointer.
|
2018-11-13 06:16:42 +00:00
|
|
|
inline Map ToMap() const;
|
2008-07-30 08:49:36 +00:00
|
|
|
|
|
|
|
// Scavenge collection: the map word of live objects in the from space
|
|
|
|
// contains a forwarding address (a heap object pointer in the to space).
|
|
|
|
|
|
|
|
// True if this map word is a forwarding address for a scavenge
|
|
|
|
// collection. Only valid during a scavenge collection (specifically,
|
2012-01-16 12:38:59 +00:00
|
|
|
// when all map words are heap object pointers, i.e. not during a full GC).
|
2016-06-22 12:21:16 +00:00
|
|
|
inline bool IsForwardingAddress() const;
|
2008-07-30 08:49:36 +00:00
|
|
|
|
|
|
|
// Create a map word from a forwarding address.
|
|
|
|
static inline MapWord FromForwardingAddress(HeapObject* object);
|
|
|
|
|
|
|
|
// View this map word as a forwarding address.
|
|
|
|
inline HeapObject* ToForwardingAddress();
|
|
|
|
|
2011-09-19 18:36:47 +00:00
|
|
|
static inline MapWord FromRawValue(uintptr_t value) {
|
|
|
|
return MapWord(value);
|
|
|
|
}
|
2008-07-30 08:49:36 +00:00
|
|
|
|
2011-09-19 18:36:47 +00:00
|
|
|
inline uintptr_t ToRawValue() {
|
|
|
|
return value_;
|
|
|
|
}
|
2009-07-09 11:13:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// HeapObject calls the private constructor and directly reads the value.
|
|
|
|
friend class HeapObject;
|
2018-11-22 23:55:32 +00:00
|
|
|
friend class HeapObjectPtr;
|
2009-07-09 11:13:08 +00:00
|
|
|
|
2018-11-13 06:16:42 +00:00
|
|
|
explicit MapWord(Address value) : value_(value) {}
|
2009-07-09 11:13:08 +00:00
|
|
|
|
2018-11-13 06:16:42 +00:00
|
|
|
Address value_;
|
2008-07-30 08:49:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// HeapObject is the superclass for all classes describing heap allocated
|
|
|
|
// objects.
|
2013-08-20 10:52:23 +00:00
|
|
|
class HeapObject: public Object {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2008-07-30 08:49:36 +00:00
|
|
|
// [map]: Contains a map which contains the object's reflective
|
|
|
|
// information.
|
2018-11-13 06:16:42 +00:00
|
|
|
inline Map map() const;
|
|
|
|
inline void set_map(Map value);
|
2017-05-05 17:41:44 +00:00
|
|
|
|
2018-12-06 08:07:00 +00:00
|
|
|
inline MapWordSlot map_slot() const;
|
2017-05-05 17:41:44 +00:00
|
|
|
|
2011-12-07 08:43:18 +00:00
|
|
|
// The no-write-barrier version. This is OK if the object is white and in
|
|
|
|
// new space, or if the value is an immortal immutable object, like the maps
|
|
|
|
// of primitive (non-JS) objects like strings, heap numbers etc.
|
2018-11-13 06:16:42 +00:00
|
|
|
inline void set_map_no_write_barrier(Map value);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-03-31 14:29:01 +00:00
|
|
|
// Get the map using acquire load.
|
2018-11-13 06:16:42 +00:00
|
|
|
inline Map synchronized_map() const;
|
2014-06-20 10:31:17 +00:00
|
|
|
inline MapWord synchronized_map_word() const;
|
2014-03-31 14:29:01 +00:00
|
|
|
|
|
|
|
// Set the map using release store
|
2018-11-13 06:16:42 +00:00
|
|
|
inline void synchronized_set_map(Map value);
|
2014-03-31 14:29:01 +00:00
|
|
|
inline void synchronized_set_map_word(MapWord map_word);
|
|
|
|
|
2017-05-18 19:24:22 +00:00
|
|
|
// Initialize the map immediately after the object is allocated.
|
|
|
|
// Do not use this outside Heap.
|
|
|
|
inline void set_map_after_allocation(
|
2018-11-13 06:16:42 +00:00
|
|
|
Map value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
2017-05-18 19:24:22 +00:00
|
|
|
|
2008-07-30 08:49:36 +00:00
|
|
|
// During garbage collection, the map word of a heap object does not
|
|
|
|
// necessarily contain a map pointer.
|
2014-06-20 10:31:17 +00:00
|
|
|
inline MapWord map_word() const;
|
2008-07-30 08:49:36 +00:00
|
|
|
inline void set_map_word(MapWord map_word);
|
|
|
|
|
2018-07-03 08:37:51 +00:00
|
|
|
// TODO(v8:7464): Once RO_SPACE is shared between isolates, this method can be
|
|
|
|
// removed as ReadOnlyRoots will be accessible from a global variable. For now
|
|
|
|
// this method exists to help remove GetIsolate/GetHeap from HeapObject, in a
|
|
|
|
// way that doesn't require passing Isolate/Heap down huge call chains or to
|
|
|
|
// places where it might not be safe to access it.
|
|
|
|
inline ReadOnlyRoots GetReadOnlyRoots() const;
|
|
|
|
|
2018-06-22 11:19:13 +00:00
|
|
|
#define IS_TYPE_FUNCTION_DECL(Type) V8_INLINE bool Is##Type() const;
|
2016-02-16 12:57:29 +00:00
|
|
|
HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
|
2016-06-14 10:08:44 +00:00
|
|
|
#undef IS_TYPE_FUNCTION_DECL
|
|
|
|
|
2018-06-22 11:19:13 +00:00
|
|
|
V8_INLINE bool IsExternal(Isolate* isolate) const;
|
2018-06-20 16:32:59 +00:00
|
|
|
|
2018-07-05 09:02:40 +00:00
|
|
|
// Oddball checks are faster when they are raw pointer comparisons, so the
|
|
|
|
// isolate/read-only roots overloads should be preferred where possible.
|
|
|
|
#define IS_TYPE_FUNCTION_DECL(Type, Value) \
|
|
|
|
V8_INLINE bool Is##Type(Isolate* isolate) const; \
|
|
|
|
V8_INLINE bool Is##Type(ReadOnlyRoots roots) const; \
|
|
|
|
V8_INLINE bool Is##Type() const;
|
2016-02-16 12:57:29 +00:00
|
|
|
ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
|
|
|
|
#undef IS_TYPE_FUNCTION_DECL
|
2016-06-14 10:08:44 +00:00
|
|
|
|
2018-06-22 11:19:13 +00:00
|
|
|
V8_INLINE bool IsNullOrUndefined(Isolate* isolate) const;
|
2018-07-05 09:02:40 +00:00
|
|
|
V8_INLINE bool IsNullOrUndefined(ReadOnlyRoots roots) const;
|
2018-06-22 11:19:13 +00:00
|
|
|
V8_INLINE bool IsNullOrUndefined() const;
|
2018-06-12 09:16:35 +00:00
|
|
|
|
2018-06-22 11:19:13 +00:00
|
|
|
#define DECL_STRUCT_PREDICATE(NAME, Name, name) V8_INLINE bool Is##Name() const;
|
2017-06-29 13:14:20 +00:00
|
|
|
STRUCT_LIST(DECL_STRUCT_PREDICATE)
|
|
|
|
#undef DECL_STRUCT_PREDICATE
|
2016-02-16 12:57:29 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Converts an address to a HeapObject pointer.
|
2015-08-13 11:49:01 +00:00
|
|
|
static inline HeapObject* FromAddress(Address address) {
|
|
|
|
DCHECK_TAG_ALIGNED(address);
|
|
|
|
return reinterpret_cast<HeapObject*>(address + kHeapObjectTag);
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Returns the address of this HeapObject.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline Address address() const {
|
2018-04-13 22:28:05 +00:00
|
|
|
return reinterpret_cast<Address>(this) - kHeapObjectTag;
|
2015-08-13 11:49:01 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-11-13 12:32:08 +00:00
|
|
|
// Iterates over pointers contained in the object (including the Map).
|
|
|
|
// If it's not performance critical iteration use the non-templatized
|
|
|
|
// version.
|
2008-07-03 15:10:15 +00:00
|
|
|
void Iterate(ObjectVisitor* v);
|
|
|
|
|
2015-11-13 12:32:08 +00:00
|
|
|
template <typename ObjectVisitor>
|
|
|
|
inline void IterateFast(ObjectVisitor* v);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Iterates over all pointers contained in the object except the
|
|
|
|
// first map pointer. The object type is given in the first
|
|
|
|
// parameter. This function does not access the map pointer in the
|
|
|
|
// object, and so is safe to call while the map pointer is modified.
|
2015-11-13 12:32:08 +00:00
|
|
|
// If it's not performance critical iteration use the non-templatized
|
|
|
|
// version.
|
|
|
|
void IterateBody(ObjectVisitor* v);
|
2018-11-13 06:16:42 +00:00
|
|
|
void IterateBody(Map map, int object_size, ObjectVisitor* v);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-11-13 12:32:08 +00:00
|
|
|
template <typename ObjectVisitor>
|
|
|
|
inline void IterateBodyFast(ObjectVisitor* v);
|
|
|
|
|
|
|
|
template <typename ObjectVisitor>
|
2018-11-13 06:16:42 +00:00
|
|
|
inline void IterateBodyFast(Map map, int object_size, ObjectVisitor* v);
|
2015-11-13 12:32:08 +00:00
|
|
|
|
|
|
|
// Returns true if the object contains a tagged value at given offset.
|
|
|
|
// It is used for invalid slots filtering. If the offset points outside
|
|
|
|
// of the object or to the map word, the result is UNDEFINED (!!!).
|
2018-11-13 06:16:42 +00:00
|
|
|
bool IsValidSlot(Map map, int offset);
|
2015-11-13 12:32:08 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Returns the heap object's size in bytes
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int Size() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Given a heap object's map pointer, returns the heap size in bytes
|
|
|
|
// Useful when the map pointer field is used for other purposes.
|
|
|
|
// GC internal.
|
2018-11-13 06:16:42 +00:00
|
|
|
inline int SizeFromMap(Map map) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-10-29 10:37:14 +00:00
|
|
|
// Returns the field at offset in obj, as a read/write Object* reference.
|
|
|
|
// Does no checking, and is safe to use during GC, while maps are invalid.
|
2010-05-27 12:30:45 +00:00
|
|
|
// Does not invoke write barrier, so should only be assigned to
|
2008-10-29 10:37:14 +00:00
|
|
|
// during marking GC.
|
2018-10-24 01:44:19 +00:00
|
|
|
inline ObjectSlot RawField(int byte_offset) const;
|
2018-10-23 23:02:20 +00:00
|
|
|
static inline ObjectSlot RawField(const HeapObject* obj, int offset);
|
2018-10-24 01:44:19 +00:00
|
|
|
inline MaybeObjectSlot RawMaybeWeakField(int byte_offset) const;
|
2018-10-23 23:02:20 +00:00
|
|
|
static inline MaybeObjectSlot RawMaybeWeakField(HeapObject* obj, int offset);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(HeapObject)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-01-29 11:46:55 +00:00
|
|
|
// Return the write barrier mode for this. Callers of this function
|
2013-06-10 16:31:55 +00:00
|
|
|
// must be able to present a reference to an DisallowHeapAllocation
|
2010-01-29 11:46:55 +00:00
|
|
|
// object as a sign that they are not going to use this function
|
|
|
|
// from code that allocates and thus invalidates the returned write
|
|
|
|
// barrier mode.
|
2013-06-03 15:32:22 +00:00
|
|
|
inline WriteBarrierMode GetWriteBarrierMode(
|
|
|
|
const DisallowHeapAllocation& promise);
|
2008-10-23 08:46:32 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Dispatched behavior.
|
2014-09-30 10:29:32 +00:00
|
|
|
void HeapObjectShortPrint(std::ostream& os); // NOLINT
|
2010-12-20 10:38:19 +00:00
|
|
|
#ifdef OBJECT_PRINT
|
2014-09-30 10:29:32 +00:00
|
|
|
void PrintHeader(std::ostream& os, const char* id); // NOLINT
|
2010-12-20 10:38:19 +00:00
|
|
|
#endif
|
2018-07-12 10:06:42 +00:00
|
|
|
DECL_PRINTER(HeapObject)
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(HeapObject)
|
2012-10-12 11:41:14 +00:00
|
|
|
#ifdef VERIFY_HEAP
|
2018-07-17 13:28:38 +00:00
|
|
|
inline void VerifyObjectField(Isolate* isolate, int offset);
|
2010-05-27 12:30:45 +00:00
|
|
|
inline void VerifySmiField(int offset);
|
2018-07-17 13:28:38 +00:00
|
|
|
inline void VerifyMaybeObjectField(Isolate* isolate, int offset);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Verify a pointer is a valid HeapObject pointer that points to object
|
|
|
|
// areas in the heap.
|
2018-07-17 13:28:38 +00:00
|
|
|
static void VerifyHeapPointer(Isolate* isolate, Object* p);
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif
|
|
|
|
|
2018-11-13 06:16:42 +00:00
|
|
|
static inline AllocationAlignment RequiredAlignment(Map map);
|
2014-11-27 09:22:10 +00:00
|
|
|
|
2017-11-07 06:50:22 +00:00
|
|
|
// Whether the object needs rehashing. That is the case if the object's
|
|
|
|
// content depends on FLAG_hash_seed. When the object is deserialized into
|
|
|
|
// a heap with a different hash seed, these objects need to adapt.
|
|
|
|
inline bool NeedsRehashing() const;
|
|
|
|
|
|
|
|
// Rehashing support is not implemented for all objects that need rehashing.
|
|
|
|
// With objects that need rehashing but cannot be rehashed, rehashing has to
|
|
|
|
// be disabled.
|
|
|
|
bool CanBeRehashed() const;
|
|
|
|
|
|
|
|
// Rehash the object based on the layout inferred from its map.
|
2018-07-12 11:04:18 +00:00
|
|
|
void RehashBasedOnMap(Isolate* isolate);
|
2017-11-07 06:50:22 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Layout description.
|
|
|
|
// First field in a heap object is map.
|
2008-09-23 11:45:43 +00:00
|
|
|
static const int kMapOffset = Object::kHeaderSize;
|
|
|
|
static const int kHeaderSize = kMapOffset + kPointerSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-05-27 13:43:29 +00:00
|
|
|
STATIC_ASSERT(kMapOffset == Internals::kHeapObjectMapOffset);
|
2009-08-26 10:33:11 +00:00
|
|
|
|
2018-07-16 13:28:49 +00:00
|
|
|
inline Address GetFieldAddress(int field_offset) const;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject);
|
|
|
|
};
|
|
|
|
|
2018-06-19 10:11:40 +00:00
|
|
|
// Mixin class for objects that can never be in RO space.
|
|
|
|
// TODO(leszeks): Add checks in the factory that we never allocate these objects
|
|
|
|
// in RO space.
|
|
|
|
class NeverReadOnlySpaceObject {
|
|
|
|
public:
|
|
|
|
// The Heap the object was allocated in. Used also to access Isolate.
|
|
|
|
inline Heap* GetHeap() const;
|
|
|
|
|
|
|
|
// Convenience method to get current isolate.
|
|
|
|
inline Isolate* GetIsolate() const;
|
|
|
|
};
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-11-05 14:02:35 +00:00
|
|
|
template <int start_offset, int end_offset, int size>
|
2015-11-13 12:32:08 +00:00
|
|
|
class FixedBodyDescriptor;
|
2010-08-11 14:30:14 +00:00
|
|
|
|
2015-11-05 14:02:35 +00:00
|
|
|
template <int start_offset>
|
2015-11-13 12:32:08 +00:00
|
|
|
class FlexibleBodyDescriptor;
|
2015-11-05 14:02:35 +00:00
|
|
|
|
2018-11-26 15:40:55 +00:00
|
|
|
template <int start_offset>
|
|
|
|
class FlexibleWeakBodyDescriptor;
|
|
|
|
|
[sfi] Remove SFI function identifier field
Remove the function identifier field from SharedFunctionInfo. This field
would store one of a) the function's inferred name, b) the "builtin
function id", or c) debug info. We remove these in turn:
a) The function's inferred name is available on the ScopeInfo, so like
the start/end position we read it off either the ScopeInfo (for
compiled functions) or the UncompiledData (for uncompiled functions).
As a side-effect, now both UncompiledData and its subclass,
UncompiledDataWithPreparsedScope, contain a pointer field. To keep
BodyDescriptors manageable, we introduce a SubclassBodyDescriptor
which effectively appends two BodyDescriptors together.
b) The builtin function id is < 255, so we can steal a byte from
expected no. of properies (also <255) and store these together.
Eventually we want to get rid of this field and use the builtin ID,
but this is pending JS builtin removal.
As a side-effect, BuiltinFunctionId becomes an enum class (for better
storage size guarantees).
c) The debug info can hang off anything (since it stores the field it
replaces), so we can attach it to the script field instead.
This saves a word on compiled function (uncompiled functions
unfortunately still have to store it in UncompiledData).
Bug: chromium:818642
Change-Id: I8b4b3a070f0fe328aafcaeac58842d144d12d996
Reviewed-on: https://chromium-review.googlesource.com/1138328
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54543}
2018-07-18 15:11:31 +00:00
|
|
|
template <class ParentBodyDescriptor, class ChildBodyDescriptor>
|
|
|
|
class SubclassBodyDescriptor;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// The HeapNumber class describes heap allocated numbers that cannot be
|
2018-06-26 11:01:19 +00:00
|
|
|
// represented in a Smi (small integer). MutableHeapNumber is the same, but its
|
|
|
|
// number value can change over time (it is used only as property storage).
|
|
|
|
// HeapNumberBase merely exists to avoid code duplication.
|
|
|
|
class HeapNumberBase : public HeapObject {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
// [value]: number value.
|
2014-06-24 09:47:25 +00:00
|
|
|
inline double value() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void set_value(double value);
|
|
|
|
|
2017-01-23 18:18:48 +00:00
|
|
|
inline uint64_t value_as_bits() const;
|
|
|
|
inline void set_value_as_bits(uint64_t bits);
|
|
|
|
|
2010-03-18 13:00:57 +00:00
|
|
|
inline int get_exponent();
|
|
|
|
inline int get_sign();
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Layout description.
|
2008-09-23 11:45:43 +00:00
|
|
|
static const int kValueOffset = HeapObject::kHeaderSize;
|
2009-06-10 10:20:37 +00:00
|
|
|
// IEEE doubles are two 32 bit words. The first is just mantissa, the second
|
2014-04-15 16:39:21 +00:00
|
|
|
// is a mixture of sign, exponent and mantissa. The offsets of two 32 bit
|
|
|
|
// words within double numbers are endian dependent and they are set
|
|
|
|
// accordingly.
|
|
|
|
#if defined(V8_TARGET_LITTLE_ENDIAN)
|
2009-06-10 10:20:37 +00:00
|
|
|
static const int kMantissaOffset = kValueOffset;
|
|
|
|
static const int kExponentOffset = kValueOffset + 4;
|
2014-04-15 16:39:21 +00:00
|
|
|
#elif defined(V8_TARGET_BIG_ENDIAN)
|
|
|
|
static const int kMantissaOffset = kValueOffset + 4;
|
|
|
|
static const int kExponentOffset = kValueOffset;
|
|
|
|
#else
|
|
|
|
#error Unknown byte ordering
|
|
|
|
#endif
|
2011-04-11 09:04:30 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kSize = kValueOffset + kDoubleSize;
|
2009-06-10 10:20:37 +00:00
|
|
|
static const uint32_t kSignMask = 0x80000000u;
|
|
|
|
static const uint32_t kExponentMask = 0x7ff00000u;
|
|
|
|
static const uint32_t kMantissaMask = 0xfffffu;
|
2010-05-03 10:43:49 +00:00
|
|
|
static const int kMantissaBits = 52;
|
2010-06-14 11:20:36 +00:00
|
|
|
static const int kExponentBits = 11;
|
2009-06-10 10:20:37 +00:00
|
|
|
static const int kExponentBias = 1023;
|
|
|
|
static const int kExponentShift = 20;
|
2013-04-09 08:42:57 +00:00
|
|
|
static const int kInfinityOrNanExponent =
|
|
|
|
(kExponentMask >> kExponentShift) - kExponentBias;
|
2009-06-10 10:20:37 +00:00
|
|
|
static const int kMantissaBitsInTopWord = 20;
|
|
|
|
static const int kNonMantissaBitsInTopWord = 12;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
2018-12-11 14:20:29 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumberBase);
|
2018-06-26 11:01:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class HeapNumber : public HeapNumberBase {
|
|
|
|
public:
|
|
|
|
DECL_CAST(HeapNumber)
|
|
|
|
V8_EXPORT_PRIVATE void HeapNumberPrint(std::ostream& os);
|
|
|
|
|
|
|
|
private:
|
2018-12-11 14:20:29 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber);
|
2018-06-26 11:01:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MutableHeapNumber : public HeapNumberBase {
|
|
|
|
public:
|
|
|
|
DECL_CAST(MutableHeapNumber)
|
|
|
|
V8_EXPORT_PRIVATE void MutableHeapNumberPrint(std::ostream& os);
|
|
|
|
|
|
|
|
private:
|
2018-12-11 14:20:29 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(MutableHeapNumber);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2011-12-09 08:50:19 +00:00
|
|
|
enum EnsureElementsMode {
|
|
|
|
DONT_ALLOW_DOUBLE_ELEMENTS,
|
|
|
|
ALLOW_COPIED_DOUBLE_ELEMENTS,
|
|
|
|
ALLOW_CONVERTED_DOUBLE_ELEMENTS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-03-05 12:11:28 +00:00
|
|
|
// Indicator for one component of an AccessorPair.
|
|
|
|
enum AccessorComponent {
|
|
|
|
ACCESSOR_GETTER,
|
|
|
|
ACCESSOR_SETTER
|
|
|
|
};
|
|
|
|
|
2018-02-12 12:50:50 +00:00
|
|
|
enum class GetKeysConversion {
|
|
|
|
kKeepNumbers = static_cast<int>(v8::KeyConversionMode::kKeepNumbers),
|
|
|
|
kConvertToString = static_cast<int>(v8::KeyConversionMode::kConvertToString)
|
|
|
|
};
|
2012-03-05 12:11:28 +00:00
|
|
|
|
2016-05-30 15:52:56 +00:00
|
|
|
enum class KeyCollectionMode {
|
|
|
|
kOwnOnly = static_cast<int>(v8::KeyCollectionMode::kOwnOnly),
|
|
|
|
kIncludePrototypes =
|
|
|
|
static_cast<int>(v8::KeyCollectionMode::kIncludePrototypes)
|
|
|
|
};
|
2015-10-19 13:47:24 +00:00
|
|
|
|
2015-01-27 14:56:51 +00:00
|
|
|
// FreeSpace are fixed-size free memory blocks used by the heap and GC.
|
|
|
|
// They look like heap objects (are heap object tagged and have a map) so that
|
|
|
|
// the heap remains iterable. They have a size and a next pointer.
|
|
|
|
// The next pointer is the raw address of the next FreeSpace object (or NULL)
|
|
|
|
// in the free list.
|
2013-08-20 10:52:23 +00:00
|
|
|
class FreeSpace: public HeapObject {
|
2011-09-19 18:36:47 +00:00
|
|
|
public:
|
|
|
|
// [size]: size of the free space including the header.
|
2014-06-20 10:31:17 +00:00
|
|
|
inline int size() const;
|
2011-09-19 18:36:47 +00:00
|
|
|
inline void set_size(int value);
|
|
|
|
|
2017-05-30 07:44:37 +00:00
|
|
|
inline int relaxed_read_size() const;
|
|
|
|
inline void relaxed_write_size(int value);
|
2014-04-08 16:31:57 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline int Size();
|
2011-09-19 18:36:47 +00:00
|
|
|
|
2015-01-27 14:56:51 +00:00
|
|
|
// Accessors for the next field.
|
|
|
|
inline FreeSpace* next();
|
|
|
|
inline void set_next(FreeSpace* next);
|
|
|
|
|
|
|
|
inline static FreeSpace* cast(HeapObject* obj);
|
2011-09-19 18:36:47 +00:00
|
|
|
|
2012-12-13 10:17:37 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(FreeSpace)
|
|
|
|
DECL_VERIFIER(FreeSpace)
|
2011-09-19 18:36:47 +00:00
|
|
|
|
|
|
|
// Layout description.
|
|
|
|
// Size is smi tagged when it is stored.
|
|
|
|
static const int kSizeOffset = HeapObject::kHeaderSize;
|
2015-01-27 14:56:51 +00:00
|
|
|
static const int kNextOffset = POINTER_SIZE_ALIGN(kSizeOffset + kPointerSize);
|
2016-09-06 11:02:21 +00:00
|
|
|
static const int kSize = kNextOffset + kPointerSize;
|
2011-09-19 18:36:47 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(FreeSpace);
|
|
|
|
};
|
|
|
|
|
2015-04-27 12:59:55 +00:00
|
|
|
class PrototypeInfo;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// An abstract superclass, a marker class really, for simple structure classes.
|
2011-05-13 10:58:25 +00:00
|
|
|
// It doesn't carry much functionality but allows struct classes to be
|
2008-07-03 15:10:15 +00:00
|
|
|
// identified in the type system.
|
|
|
|
class Struct: public HeapObject {
|
|
|
|
public:
|
|
|
|
inline void InitializeBody(int object_size);
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(Struct)
|
2017-08-24 13:53:20 +00:00
|
|
|
void BriefPrintDetails(std::ostream& os);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2017-10-23 08:23:37 +00:00
|
|
|
class Tuple2 : public Struct {
|
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(value1, Object)
|
|
|
|
DECL_ACCESSORS(value2, Object)
|
|
|
|
|
|
|
|
DECL_CAST(Tuple2)
|
|
|
|
|
|
|
|
// Dispatched behavior.
|
|
|
|
DECL_PRINTER(Tuple2)
|
|
|
|
DECL_VERIFIER(Tuple2)
|
|
|
|
void BriefPrintDetails(std::ostream& os);
|
|
|
|
|
|
|
|
static const int kValue1Offset = HeapObject::kHeaderSize;
|
|
|
|
static const int kValue2Offset = kValue1Offset + kPointerSize;
|
|
|
|
static const int kSize = kValue2Offset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Tuple2);
|
|
|
|
};
|
|
|
|
|
|
|
|
class Tuple3 : public Tuple2 {
|
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(value3, Object)
|
|
|
|
|
|
|
|
DECL_CAST(Tuple3)
|
|
|
|
|
|
|
|
// Dispatched behavior.
|
|
|
|
DECL_PRINTER(Tuple3)
|
|
|
|
DECL_VERIFIER(Tuple3)
|
|
|
|
void BriefPrintDetails(std::ostream& os);
|
|
|
|
|
|
|
|
static const int kValue3Offset = Tuple2::kSize;
|
|
|
|
static const int kSize = kValue3Offset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Tuple3);
|
|
|
|
};
|
|
|
|
|
2009-09-30 12:25:46 +00:00
|
|
|
// Utility superclass for stack-allocated objects that must be updated
|
|
|
|
// on gc. It provides two ways for the gc to update instances, either
|
|
|
|
// iterating or updating after gc.
|
2018-09-06 09:08:10 +00:00
|
|
|
class Relocatable {
|
2009-10-01 06:27:29 +00:00
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
explicit inline Relocatable(Isolate* isolate);
|
|
|
|
inline virtual ~Relocatable();
|
2017-04-25 13:32:18 +00:00
|
|
|
virtual void IterateInstance(RootVisitor* v) {}
|
2009-09-30 12:25:46 +00:00
|
|
|
virtual void PostGarbageCollection() { }
|
|
|
|
|
2013-09-04 10:34:42 +00:00
|
|
|
static void PostGarbageCollectionProcessing(Isolate* isolate);
|
2013-09-04 11:09:55 +00:00
|
|
|
static int ArchiveSpacePerThread();
|
2011-05-05 18:55:31 +00:00
|
|
|
static char* ArchiveState(Isolate* isolate, char* to);
|
|
|
|
static char* RestoreState(Isolate* isolate, char* from);
|
2017-04-25 13:32:18 +00:00
|
|
|
static void Iterate(Isolate* isolate, RootVisitor* v);
|
|
|
|
static void Iterate(RootVisitor* v, Relocatable* top);
|
|
|
|
static char* Iterate(RootVisitor* v, char* t);
|
2013-09-04 10:34:42 +00:00
|
|
|
|
2009-10-01 06:27:29 +00:00
|
|
|
private:
|
2011-03-18 20:35:07 +00:00
|
|
|
Isolate* isolate_;
|
2009-09-30 12:25:46 +00:00
|
|
|
Relocatable* prev_;
|
|
|
|
};
|
|
|
|
|
2008-10-09 08:08:04 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// The Oddball describes objects null, undefined, true, and false.
|
2013-08-20 10:52:23 +00:00
|
|
|
class Oddball: public HeapObject {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2016-04-25 09:16:57 +00:00
|
|
|
// [to_number_raw]: Cached raw to_number computed at startup.
|
|
|
|
inline double to_number_raw() const;
|
|
|
|
inline void set_to_number_raw(double value);
|
2017-04-12 10:10:48 +00:00
|
|
|
inline void set_to_number_raw_as_bits(uint64_t bits);
|
2016-04-25 09:16:57 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// [to_string]: Cached to_string computed at startup.
|
2018-11-27 00:48:42 +00:00
|
|
|
DECL_ACCESSORS2(to_string, String)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// [to_number]: Cached to_number computed at startup.
|
|
|
|
DECL_ACCESSORS(to_number, Object)
|
|
|
|
|
2015-08-11 10:47:24 +00:00
|
|
|
// [typeof]: Cached type_of computed at startup.
|
2018-11-27 00:48:42 +00:00
|
|
|
DECL_ACCESSORS2(type_of, String)
|
2015-08-11 10:47:24 +00:00
|
|
|
|
2014-06-24 09:47:25 +00:00
|
|
|
inline byte kind() const;
|
2011-03-18 20:35:07 +00:00
|
|
|
inline void set_kind(byte kind);
|
|
|
|
|
2015-09-15 13:14:36 +00:00
|
|
|
// ES6 section 7.1.3 ToNumber for Boolean, Null, Undefined.
|
2018-04-09 15:12:07 +00:00
|
|
|
V8_WARN_UNUSED_RESULT static inline Handle<Object> ToNumber(
|
2018-07-11 11:49:07 +00:00
|
|
|
Isolate* isolate, Handle<Oddball> input);
|
2015-09-15 13:14:36 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(Oddball)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(Oddball)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Initialize the fields.
|
2015-08-11 10:47:24 +00:00
|
|
|
static void Initialize(Isolate* isolate, Handle<Oddball> oddball,
|
|
|
|
const char* to_string, Handle<Object> to_number,
|
2016-07-19 06:13:34 +00:00
|
|
|
const char* type_of, byte kind);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Layout description.
|
2016-04-25 09:16:57 +00:00
|
|
|
static const int kToNumberRawOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kToStringOffset = kToNumberRawOffset + kDoubleSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kToNumberOffset = kToStringOffset + kPointerSize;
|
2016-07-19 06:13:34 +00:00
|
|
|
static const int kTypeOfOffset = kToNumberOffset + kPointerSize;
|
2015-08-11 10:47:24 +00:00
|
|
|
static const int kKindOffset = kTypeOfOffset + kPointerSize;
|
2011-03-18 20:35:07 +00:00
|
|
|
static const int kSize = kKindOffset + kPointerSize;
|
|
|
|
|
|
|
|
static const byte kFalse = 0;
|
|
|
|
static const byte kTrue = 1;
|
2017-03-17 15:18:18 +00:00
|
|
|
static const byte kNotBooleanMask = static_cast<byte>(~1);
|
2011-03-18 20:35:07 +00:00
|
|
|
static const byte kTheHole = 2;
|
|
|
|
static const byte kNull = 3;
|
2016-02-16 12:57:29 +00:00
|
|
|
static const byte kArgumentsMarker = 4;
|
2011-03-18 20:35:07 +00:00
|
|
|
static const byte kUndefined = 5;
|
2013-06-06 14:21:35 +00:00
|
|
|
static const byte kUninitialized = 6;
|
|
|
|
static const byte kOther = 7;
|
2014-04-22 07:33:20 +00:00
|
|
|
static const byte kException = 8;
|
2016-03-16 14:30:15 +00:00
|
|
|
static const byte kOptimizedOut = 9;
|
2016-04-28 14:54:39 +00:00
|
|
|
static const byte kStaleRegister = 10;
|
2018-05-02 11:54:25 +00:00
|
|
|
static const byte kSelfReferenceMarker = 10;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-08-11 10:47:24 +00:00
|
|
|
typedef FixedBodyDescriptor<kToStringOffset, kTypeOfOffset + kPointerSize,
|
2010-08-11 14:30:14 +00:00
|
|
|
kSize> BodyDescriptor;
|
|
|
|
|
2016-04-25 09:16:57 +00:00
|
|
|
STATIC_ASSERT(kToNumberRawOffset == HeapNumber::kValueOffset);
|
2014-05-27 13:43:29 +00:00
|
|
|
STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset);
|
|
|
|
STATIC_ASSERT(kNull == Internals::kNullOddballKind);
|
|
|
|
STATIC_ASSERT(kUndefined == Internals::kUndefinedOddballKind);
|
2012-04-18 15:51:34 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class Cell: public HeapObject {
|
2009-06-30 10:05:36 +00:00
|
|
|
public:
|
2015-03-18 11:43:51 +00:00
|
|
|
// [value]: value of the cell.
|
2009-06-30 10:05:36 +00:00
|
|
|
DECL_ACCESSORS(value, Object)
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(Cell)
|
2009-06-30 10:05:36 +00:00
|
|
|
|
2013-06-12 15:03:44 +00:00
|
|
|
static inline Cell* FromValueAddress(Address value) {
|
|
|
|
Object* result = FromAddress(value - kValueOffset);
|
|
|
|
return static_cast<Cell*>(result);
|
2012-07-31 09:25:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline Address ValueAddress() {
|
|
|
|
return address() + kValueOffset;
|
|
|
|
}
|
|
|
|
|
2012-12-13 10:17:37 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(Cell)
|
|
|
|
DECL_VERIFIER(Cell)
|
2012-10-12 11:41:14 +00:00
|
|
|
|
2009-06-30 10:05:36 +00:00
|
|
|
// Layout description.
|
|
|
|
static const int kValueOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kSize = kValueOffset + kPointerSize;
|
|
|
|
|
2010-08-11 14:30:14 +00:00
|
|
|
typedef FixedBodyDescriptor<kValueOffset,
|
|
|
|
kValueOffset + kPointerSize,
|
|
|
|
kSize> BodyDescriptor;
|
|
|
|
|
2009-06-30 10:05:36 +00:00
|
|
|
private:
|
2013-06-12 15:03:44 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Cell);
|
|
|
|
};
|
|
|
|
|
2018-02-22 12:04:01 +00:00
|
|
|
// This is a special cell used to maintain both the link between a
|
|
|
|
// closure and it's feedback vector, as well as a way to count the
|
|
|
|
// number of closures created for a certain function per native
|
|
|
|
// context. There's at most one FeedbackCell for each function in
|
|
|
|
// a native context.
|
|
|
|
class FeedbackCell : public Struct {
|
|
|
|
public:
|
|
|
|
// [value]: value of the cell.
|
|
|
|
DECL_ACCESSORS(value, HeapObject)
|
|
|
|
|
|
|
|
DECL_CAST(FeedbackCell)
|
|
|
|
|
|
|
|
// Dispatched behavior.
|
2018-07-12 10:06:42 +00:00
|
|
|
DECL_PRINTER(FeedbackCell)
|
2018-02-22 12:04:01 +00:00
|
|
|
DECL_VERIFIER(FeedbackCell)
|
|
|
|
|
|
|
|
static const int kValueOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kSize = kValueOffset + kPointerSize;
|
|
|
|
|
|
|
|
typedef FixedBodyDescriptor<kValueOffset, kValueOffset + kPointerSize, kSize>
|
|
|
|
BodyDescriptor;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(FeedbackCell);
|
|
|
|
};
|
2013-06-12 15:03:44 +00:00
|
|
|
|
2011-05-19 11:47:34 +00:00
|
|
|
// Foreign describes objects pointing from JavaScript to C structures.
|
2013-08-20 10:52:23 +00:00
|
|
|
class Foreign: public HeapObject {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2011-05-19 11:47:34 +00:00
|
|
|
// [address]: field containing the address.
|
2011-10-28 12:37:29 +00:00
|
|
|
inline Address foreign_address();
|
2017-12-08 13:54:55 +00:00
|
|
|
|
|
|
|
static inline bool IsNormalized(Object* object);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(Foreign)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-12-13 10:17:37 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(Foreign)
|
|
|
|
DECL_VERIFIER(Foreign)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Layout description.
|
|
|
|
|
2011-10-28 12:37:29 +00:00
|
|
|
static const int kForeignAddressOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kSize = kForeignAddressOffset + kPointerSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-05-27 13:43:29 +00:00
|
|
|
STATIC_ASSERT(kForeignAddressOffset == Internals::kForeignAddressOffset);
|
2009-08-26 10:33:11 +00:00
|
|
|
|
2015-11-13 12:32:08 +00:00
|
|
|
class BodyDescriptor;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
2018-04-09 19:11:22 +00:00
|
|
|
friend class Factory;
|
2017-12-08 13:54:55 +00:00
|
|
|
friend class SerializerDeserializer;
|
|
|
|
friend class StartupSerializer;
|
|
|
|
|
|
|
|
inline void set_foreign_address(Address value);
|
|
|
|
|
2011-05-19 11:47:34 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Foreign);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2012-01-10 16:11:33 +00:00
|
|
|
// Support for JavaScript accessors: A pair of a getter and a setter. Each
|
|
|
|
// accessor can either be
|
2017-08-25 10:40:07 +00:00
|
|
|
// * a JavaScript function or proxy: a real accessor
|
|
|
|
// * a FunctionTemplateInfo: a real (lazy) accessor
|
2012-01-10 16:11:33 +00:00
|
|
|
// * undefined: considered an accessor by the spec, too, strangely enough
|
2017-08-25 10:40:07 +00:00
|
|
|
// * null: an accessor which has not been set
|
2013-08-20 10:52:23 +00:00
|
|
|
class AccessorPair: public Struct {
|
2012-01-10 16:11:33 +00:00
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(getter, Object)
|
|
|
|
DECL_ACCESSORS(setter, Object)
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(AccessorPair)
|
2012-01-10 16:11:33 +00:00
|
|
|
|
2018-07-13 09:32:35 +00:00
|
|
|
static Handle<AccessorPair> Copy(Isolate* isolate, Handle<AccessorPair> pair);
|
2012-02-13 14:15:43 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline Object* get(AccessorComponent component);
|
|
|
|
inline void set(AccessorComponent component, Object* value);
|
2012-05-24 10:40:24 +00:00
|
|
|
|
2017-08-25 10:40:07 +00:00
|
|
|
// Note: Returns undefined if the component is not set.
|
2018-07-13 09:32:35 +00:00
|
|
|
static Handle<Object> GetComponent(Isolate* isolate,
|
|
|
|
Handle<AccessorPair> accessor_pair,
|
2016-02-09 16:28:02 +00:00
|
|
|
AccessorComponent component);
|
2012-03-05 12:11:28 +00:00
|
|
|
|
2012-03-23 09:51:56 +00:00
|
|
|
// Set both components, skipping arguments which are a JavaScript null.
|
2015-08-13 11:49:01 +00:00
|
|
|
inline void SetComponents(Object* getter, Object* setter);
|
2012-02-22 10:52:57 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool Equals(AccessorPair* pair);
|
|
|
|
inline bool Equals(Object* getter_value, Object* setter_value);
|
2015-02-16 15:25:33 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool ContainsAccessor();
|
2012-03-02 14:03:59 +00:00
|
|
|
|
2012-12-13 10:17:37 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(AccessorPair)
|
|
|
|
DECL_VERIFIER(AccessorPair)
|
2012-01-10 16:11:33 +00:00
|
|
|
|
|
|
|
static const int kGetterOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kSetterOffset = kGetterOffset + kPointerSize;
|
2014-06-23 09:02:16 +00:00
|
|
|
static const int kSize = kSetterOffset + kPointerSize;
|
2012-01-10 16:11:33 +00:00
|
|
|
|
|
|
|
private:
|
2012-03-02 14:03:59 +00:00
|
|
|
// Strangely enough, in addition to functions and harmony proxies, the spec
|
|
|
|
// requires us to consider undefined as a kind of accessor, too:
|
|
|
|
// var obj = {};
|
|
|
|
// Object.defineProperty(obj, "foo", {get: undefined});
|
|
|
|
// assertTrue("foo" in obj);
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool IsJSAccessor(Object* obj);
|
2012-03-02 14:03:59 +00:00
|
|
|
|
2012-01-10 16:11:33 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair);
|
|
|
|
};
|
|
|
|
|
2015-09-28 13:10:13 +00:00
|
|
|
// BooleanBit is a helper class for setting and getting a bit in an integer.
|
2013-08-20 10:52:23 +00:00
|
|
|
class BooleanBit : public AllStatic {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
static inline bool get(int value, int bit_position) {
|
|
|
|
return (value & (1 << bit_position)) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int set(int value, int bit_position, bool v) {
|
|
|
|
if (v) {
|
|
|
|
value |= (1 << bit_position);
|
|
|
|
} else {
|
|
|
|
value &= ~(1 << bit_position);
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-09-17 12:52:37 +00:00
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // NOLINT, false-positive due to second-order macros.
|
|
|
|
} // NOLINT, false-positive due to second-order macros.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-12-20 14:08:21 +00:00
|
|
|
#include "src/objects/object-macros-undef.h"
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif // V8_OBJECTS_H_
|