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-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
|
2019-01-07 14:09:18 +00:00
|
|
|
// - PreparseData
|
2018-07-09 09:34:34 +00:00
|
|
|
// - UncompiledData
|
2019-01-07 14:09:18 +00:00
|
|
|
// - UncompiledDataWithoutPreparseData
|
|
|
|
// - UncompiledDataWithPreparseData
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2018-12-25 00:19:47 +00:00
|
|
|
// Formats of Object::ptr_:
|
2008-07-03 15:10:15 +00:00
|
|
|
// 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;
|
2018-12-17 15:14:22 +00:00
|
|
|
class FreeSpace;
|
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;
|
2018-12-17 17:01:48 +00:00
|
|
|
class MutableHeapNumber;
|
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;
|
2019-01-07 14:09:18 +00:00
|
|
|
class PreparseData;
|
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-12-13 23:35:14 +00:00
|
|
|
class PrototypeInfo;
|
2018-12-25 00:19:47 +00:00
|
|
|
class ReadOnlyRoots;
|
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) \
|
2019-01-07 14:09:18 +00:00
|
|
|
V(PreparseData) \
|
2018-05-15 20:50:46 +00:00
|
|
|
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) \
|
2019-01-07 14:09:18 +00:00
|
|
|
V(UncompiledDataWithPreparseData) \
|
|
|
|
V(UncompiledDataWithoutPreparseData) \
|
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-12-17 19:33:18 +00:00
|
|
|
typedef Foreign ForeignArgType;
|
2018-12-20 15:47:47 +00:00
|
|
|
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-12-25 00:19:47 +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.
|
2018-12-25 00:19:47 +00:00
|
|
|
// There must only be a single data member in Object: the Address ptr,
|
|
|
|
// containing the tagged heap pointer that this Object instance refers to.
|
|
|
|
// For a design overview, see https://goo.gl/Ph4CGz.
|
2014-04-30 12:25:18 +00:00
|
|
|
class Object {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2018-12-25 00:19:47 +00:00
|
|
|
constexpr Object() : ptr_(kNullAddress) {}
|
|
|
|
explicit constexpr Object(Address ptr) : ptr_(ptr) {}
|
|
|
|
|
|
|
|
// Make clang on Linux catch what MSVC complains about on Windows:
|
|
|
|
operator bool() const = delete;
|
|
|
|
|
|
|
|
bool operator==(const Object that) const { return this->ptr() == that.ptr(); }
|
|
|
|
bool operator!=(const Object that) const { return this->ptr() != that.ptr(); }
|
|
|
|
// Usage in std::set requires operator<.
|
|
|
|
bool operator<(const Object that) const { return this->ptr() < that.ptr(); }
|
|
|
|
|
|
|
|
// Returns the tagged "(heap) object pointer" representation of this object.
|
|
|
|
constexpr Address ptr() const { return ptr_; }
|
|
|
|
|
|
|
|
// These operator->() overloads are required for handlified code.
|
|
|
|
Object* operator->() { return this; }
|
|
|
|
const Object* operator->() const { return this; }
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// 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-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-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-12-25 00:19:47 +00:00
|
|
|
V8_INLINE bool IsHashTableBase() const;
|
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.
|
2018-12-25 00:19:47 +00:00
|
|
|
inline bool KeyEquals(Object other);
|
2015-05-20 17:03:21 +00:00
|
|
|
|
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
|
2018-12-25 00:19:47 +00:00
|
|
|
bool StrictEquals(Object that);
|
2015-08-17 08:01:55 +00:00
|
|
|
|
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-12-25 00:19:47 +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.
|
2018-12-25 00:19:47 +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.
|
2018-12-25 00:19:47 +00:00
|
|
|
bool SameValueZero(Object other);
|
2014-05-21 08:47:02 +00:00
|
|
|
|
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();
|
|
|
|
|
2018-12-25 00:19:47 +00:00
|
|
|
//
|
|
|
|
// The following GetHeapObjectXX methods mimic corresponding functionality
|
|
|
|
// in MaybeObject. Having them here allows us to unify code that processes
|
|
|
|
// ObjectSlots and MaybeObjectSlots.
|
|
|
|
//
|
|
|
|
|
|
|
|
// If this Object is a strong pointer to a HeapObject, returns true and
|
|
|
|
// sets *result. Otherwise returns false.
|
|
|
|
inline bool GetHeapObjectIfStrong(HeapObject* result) const;
|
|
|
|
|
|
|
|
// If this Object is a strong pointer to a HeapObject (weak pointers are not
|
|
|
|
// expected), returns true and sets *result. Otherwise returns false.
|
|
|
|
inline bool GetHeapObject(HeapObject* result) const;
|
|
|
|
|
|
|
|
// DCHECKs that this Object is a strong pointer to a HeapObject and returns
|
|
|
|
// the HeapObject.
|
|
|
|
inline HeapObject GetHeapObject() const;
|
|
|
|
|
|
|
|
// Always returns false because Object is not expected to be a weak pointer
|
|
|
|
// to a HeapObject.
|
|
|
|
inline bool GetHeapObjectIfWeak(HeapObject* result) const {
|
|
|
|
DCHECK(!HasWeakHeapObjectTag(ptr()));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Always returns false because Object is not expected to be a weak pointer
|
|
|
|
// to a HeapObject.
|
|
|
|
inline bool IsCleared() const { return false; }
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(Object)
|
2018-12-25 00:19:47 +00:00
|
|
|
|
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-12-25 00:19:47 +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.
|
2018-12-25 00:19:47 +00:00
|
|
|
void ShortPrint(FILE* out = stdout) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Prints this object without details to a message accumulator.
|
2018-12-25 00:19:47 +00:00
|
|
|
void ShortPrint(StringStream* accumulator) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2018-12-25 00:19:47 +00:00
|
|
|
void ShortPrint(std::ostream& os) const; // NOLINT
|
2014-12-08 09:26:04 +00:00
|
|
|
|
2018-12-25 00:19:47 +00:00
|
|
|
DECL_CAST2(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-12-25 00:19:47 +00:00
|
|
|
void Print() const;
|
2014-07-08 08:43:20 +00:00
|
|
|
|
2014-04-30 12:25:18 +00:00
|
|
|
// Prints this object with details.
|
2018-12-25 00:19:47 +00:00
|
|
|
void Print(std::ostream& os) const; // NOLINT
|
2014-12-08 09:26:04 +00:00
|
|
|
#else
|
2018-12-25 00:19:47 +00:00
|
|
|
void Print() const { ShortPrint(); }
|
|
|
|
void Print(std::ostream& os) const { ShortPrint(os); } // NOLINT
|
2014-04-30 12:25:18 +00:00
|
|
|
#endif
|
|
|
|
|
2018-12-25 00:19:47 +00:00
|
|
|
// For use with std::unordered_set.
|
|
|
|
struct Hasher {
|
|
|
|
size_t operator()(const Object o) const {
|
|
|
|
return std::hash<v8::internal::Address>{}(o.ptr());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// For use with std::map.
|
|
|
|
struct Comparer {
|
|
|
|
bool operator()(const Object a, const Object b) const {
|
|
|
|
return a.ptr() < b.ptr();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
2018-12-25 00:19:47 +00:00
|
|
|
friend class CompressedObjectSlot;
|
|
|
|
friend class FullObjectSlot;
|
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.
|
2018-12-25 00:19:47 +00:00
|
|
|
static inline Object GetSimpleHash(Object object);
|
2018-05-15 00:17:04 +00:00
|
|
|
|
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
|
|
|
|
2018-12-25 00:19:47 +00:00
|
|
|
Address ptr_;
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2018-12-25 00:19:47 +00:00
|
|
|
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
|
|
|
|
const ObjectPtr& obj);
|
|
|
|
|
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-12-25 00:19:47 +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
|
|
|
|
2018-12-25 00:19:47 +00:00
|
|
|
// Objects should never have the weak tag; this variant is for overzealous
|
|
|
|
// checking.
|
|
|
|
V8_INLINE static bool HasWeakHeapObjectTag(const Object value) {
|
|
|
|
return ((value->ptr() & kHeapObjectTagMask) == kWeakHeapObjectTag);
|
|
|
|
}
|
|
|
|
|
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.
|
2018-12-20 15:47:47 +00:00
|
|
|
static inline MapWord FromForwardingAddress(HeapObject object);
|
2008-07-30 08:49:36 +00:00
|
|
|
|
|
|
|
// View this map word as a forwarding address.
|
2018-12-20 15:47:47 +00:00
|
|
|
inline HeapObject ToForwardingAddress();
|
2008-07-30 08:49:36 +00:00
|
|
|
|
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-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
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
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_;
|
|
|
|
};
|
|
|
|
|
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_
|