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
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/assert-scope.h"
|
2014-09-24 07:08:27 +00:00
|
|
|
#include "src/bailout-reason.h"
|
2014-09-02 13:36:35 +00:00
|
|
|
#include "src/base/bits.h"
|
2015-11-25 13:46:09 +00:00
|
|
|
#include "src/base/flags.h"
|
2017-03-29 09:56:08 +00:00
|
|
|
#include "src/builtins/builtins-definitions.h"
|
2014-06-30 13:25:46 +00:00
|
|
|
#include "src/checks.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"
|
|
|
|
#include "src/list.h"
|
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
|
|
|
#include "src/messages.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/property-details.h"
|
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
Review-Url: https://codereview.chromium.org/2113593002
Cr-Commit-Position: refs/heads/master@{#37417}
2016-06-30 07:36:43 +00:00
|
|
|
#include "src/unicode-decoder.h"
|
2016-07-14 06:26:03 +00:00
|
|
|
#include "src/unicode.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-06-20 08:40:11 +00:00
|
|
|
#if V8_TARGET_ARCH_ARM
|
|
|
|
#include "src/arm/constants-arm.h" // NOLINT
|
|
|
|
#elif V8_TARGET_ARCH_ARM64
|
|
|
|
#include "src/arm64/constants-arm64.h" // NOLINT
|
|
|
|
#elif V8_TARGET_ARCH_MIPS
|
|
|
|
#include "src/mips/constants-mips.h" // NOLINT
|
2014-07-09 11:08:26 +00:00
|
|
|
#elif V8_TARGET_ARCH_MIPS64
|
|
|
|
#include "src/mips64/constants-mips64.h" // NOLINT
|
2015-01-16 07:42:00 +00:00
|
|
|
#elif V8_TARGET_ARCH_PPC
|
|
|
|
#include "src/ppc/constants-ppc.h" // NOLINT
|
2016-03-10 14:02:50 +00:00
|
|
|
#elif V8_TARGET_ARCH_S390
|
|
|
|
#include "src/s390/constants-s390.h" // NOLINT
|
2014-06-20 08:40:11 +00:00
|
|
|
#endif
|
|
|
|
|
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
|
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
|
|
|
|
// - DescriptorArray
|
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
|
|
|
|
// - CodeCacheHashTable
|
|
|
|
// - MapCache
|
|
|
|
// - OrderedHashTable
|
|
|
|
// - OrderedHashSet
|
|
|
|
// - OrderedHashMap
|
|
|
|
// - Context
|
2017-02-07 14:05:02 +00:00
|
|
|
// - FeedbackMetadata
|
|
|
|
// - FeedbackVector
|
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-12-15 19:57:37 +00:00
|
|
|
// - WeakFixedArray
|
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
|
|
|
|
// - HeapNumber
|
|
|
|
// - Cell
|
2015-03-18 12:54:02 +00:00
|
|
|
// - PropertyCell
|
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
|
2016-10-12 22:18:54 +00:00
|
|
|
// - PromiseResolveThenableJobInfo
|
2016-10-12 20:45:28 +00:00
|
|
|
// - PromiseReactionJobInfo
|
2014-04-30 12:25:18 +00:00
|
|
|
// - AccessorPair
|
|
|
|
// - AccessCheckInfo
|
|
|
|
// - InterceptorInfo
|
|
|
|
// - CallHandlerInfo
|
|
|
|
// - TemplateInfo
|
|
|
|
// - FunctionTemplateInfo
|
|
|
|
// - ObjectTemplateInfo
|
|
|
|
// - Script
|
|
|
|
// - DebugInfo
|
|
|
|
// - 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
|
2016-09-16 16:47:07 +00:00
|
|
|
// - Module
|
2016-11-04 09:37:22 +00:00
|
|
|
// - ModuleInfoEntry
|
2017-06-30 10:38:38 +00:00
|
|
|
// - PreParsedScopeData
|
2014-10-14 14:43:45 +00:00
|
|
|
// - WeakCell
|
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;
|
|
|
|
|
2013-03-06 21:51:07 +00:00
|
|
|
enum KeyedAccessStoreMode {
|
|
|
|
STANDARD_STORE,
|
2015-08-20 14:40:11 +00:00
|
|
|
STORE_TRANSITION_TO_OBJECT,
|
|
|
|
STORE_TRANSITION_TO_DOUBLE,
|
2013-03-06 21:51:07 +00:00
|
|
|
STORE_AND_GROW_NO_TRANSITION,
|
2015-08-20 14:40:11 +00:00
|
|
|
STORE_AND_GROW_TRANSITION_TO_OBJECT,
|
|
|
|
STORE_AND_GROW_TRANSITION_TO_DOUBLE,
|
2013-03-06 21:51:07 +00:00
|
|
|
STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS,
|
|
|
|
STORE_NO_TRANSITION_HANDLE_COW
|
2012-02-10 12:36:05 +00:00
|
|
|
};
|
|
|
|
|
2014-07-01 15:02:31 +00:00
|
|
|
enum MutableMode {
|
|
|
|
MUTABLE,
|
|
|
|
IMMUTABLE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-03-06 21:51:07 +00:00
|
|
|
static inline bool IsTransitionStoreMode(KeyedAccessStoreMode store_mode) {
|
2015-08-20 14:40:11 +00:00
|
|
|
return store_mode == STORE_TRANSITION_TO_OBJECT ||
|
|
|
|
store_mode == STORE_TRANSITION_TO_DOUBLE ||
|
|
|
|
store_mode == STORE_AND_GROW_TRANSITION_TO_OBJECT ||
|
|
|
|
store_mode == STORE_AND_GROW_TRANSITION_TO_DOUBLE;
|
2013-03-06 21:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline KeyedAccessStoreMode GetNonTransitioningStoreMode(
|
|
|
|
KeyedAccessStoreMode store_mode) {
|
|
|
|
if (store_mode >= STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) {
|
|
|
|
return store_mode;
|
|
|
|
}
|
|
|
|
if (store_mode >= STORE_AND_GROW_NO_TRANSITION) {
|
|
|
|
return STORE_AND_GROW_NO_TRANSITION;
|
|
|
|
}
|
|
|
|
return STANDARD_STORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline bool IsGrowStoreMode(KeyedAccessStoreMode store_mode) {
|
|
|
|
return store_mode >= STORE_AND_GROW_NO_TRANSITION &&
|
2015-08-20 14:40:11 +00:00
|
|
|
store_mode <= STORE_AND_GROW_TRANSITION_TO_DOUBLE;
|
2013-03-06 21:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-10 13:27:52 +00:00
|
|
|
enum IcCheckType { ELEMENT, PROPERTY };
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
SPECIAL_TRANSITION
|
|
|
|
};
|
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
|
|
|
|
};
|
|
|
|
|
2013-11-28 15:32:55 +00:00
|
|
|
// ICs store extra state in a Code object. The default extra state is
|
|
|
|
// kNoExtraICState.
|
|
|
|
typedef int ExtraICState;
|
|
|
|
static const ExtraICState kNoExtraICState = 0;
|
|
|
|
|
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
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// All Maps have a field instance_type containing a InstanceType.
|
|
|
|
// It describes the type of the instances.
|
|
|
|
//
|
|
|
|
// As an example, a JavaScript object is a heap object and its map
|
|
|
|
// instance_type is JS_OBJECT_TYPE.
|
|
|
|
//
|
|
|
|
// The names of the string instance types are intended to systematically
|
2009-12-22 13:34:02 +00:00
|
|
|
// mirror their encoding in the instance_type field of the map. The default
|
2014-09-10 12:38:12 +00:00
|
|
|
// encoding is considered TWO_BYTE. It is not mentioned in the name. ONE_BYTE
|
2009-12-22 13:34:02 +00:00
|
|
|
// encoding is mentioned explicitly in the name. Likewise, the default
|
|
|
|
// representation is considered sequential. It is not mentioned in the
|
2012-01-16 12:38:59 +00:00
|
|
|
// name. The other representations (e.g. CONS, EXTERNAL) are explicitly
|
2013-02-28 17:03:34 +00:00
|
|
|
// mentioned. Finally, the string is either a STRING_TYPE (if it is a normal
|
|
|
|
// string) or a INTERNALIZED_STRING_TYPE (if it is a internalized string).
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
|
|
|
// NOTE: The following things are some that depend on the string types having
|
|
|
|
// instance_types that are less than those of all other types:
|
|
|
|
// HeapObject::Size, HeapObject::IterateBody, the typeof operator, and
|
|
|
|
// Object::IsString.
|
|
|
|
//
|
2008-09-02 23:52:50 +00:00
|
|
|
// NOTE: Everything following JS_VALUE_TYPE is considered a
|
2008-07-03 15:10:15 +00:00
|
|
|
// JSObject for GC purposes. The first four entries here have typeof
|
|
|
|
// 'object', whereas JS_FUNCTION_TYPE has typeof 'function'.
|
2017-04-18 12:46:39 +00:00
|
|
|
#define INSTANCE_TYPE_LIST(V) \
|
|
|
|
V(INTERNALIZED_STRING_TYPE) \
|
|
|
|
V(EXTERNAL_INTERNALIZED_STRING_TYPE) \
|
|
|
|
V(ONE_BYTE_INTERNALIZED_STRING_TYPE) \
|
|
|
|
V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE) \
|
|
|
|
V(EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \
|
|
|
|
V(SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE) \
|
|
|
|
V(SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE) \
|
|
|
|
V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \
|
|
|
|
V(STRING_TYPE) \
|
|
|
|
V(CONS_STRING_TYPE) \
|
|
|
|
V(EXTERNAL_STRING_TYPE) \
|
|
|
|
V(SLICED_STRING_TYPE) \
|
|
|
|
V(THIN_STRING_TYPE) \
|
|
|
|
V(ONE_BYTE_STRING_TYPE) \
|
|
|
|
V(CONS_ONE_BYTE_STRING_TYPE) \
|
|
|
|
V(EXTERNAL_ONE_BYTE_STRING_TYPE) \
|
|
|
|
V(SLICED_ONE_BYTE_STRING_TYPE) \
|
|
|
|
V(THIN_ONE_BYTE_STRING_TYPE) \
|
|
|
|
V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \
|
|
|
|
V(SHORT_EXTERNAL_STRING_TYPE) \
|
|
|
|
V(SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE) \
|
|
|
|
V(SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \
|
|
|
|
\
|
|
|
|
V(SYMBOL_TYPE) \
|
|
|
|
V(HEAP_NUMBER_TYPE) \
|
|
|
|
V(ODDBALL_TYPE) \
|
|
|
|
\
|
|
|
|
V(MAP_TYPE) \
|
|
|
|
V(CODE_TYPE) \
|
|
|
|
V(MUTABLE_HEAP_NUMBER_TYPE) \
|
|
|
|
V(FOREIGN_TYPE) \
|
|
|
|
V(BYTE_ARRAY_TYPE) \
|
|
|
|
V(BYTECODE_ARRAY_TYPE) \
|
|
|
|
V(FREE_SPACE_TYPE) \
|
|
|
|
\
|
|
|
|
V(FIXED_INT8_ARRAY_TYPE) \
|
|
|
|
V(FIXED_UINT8_ARRAY_TYPE) \
|
|
|
|
V(FIXED_INT16_ARRAY_TYPE) \
|
|
|
|
V(FIXED_UINT16_ARRAY_TYPE) \
|
|
|
|
V(FIXED_INT32_ARRAY_TYPE) \
|
|
|
|
V(FIXED_UINT32_ARRAY_TYPE) \
|
|
|
|
V(FIXED_FLOAT32_ARRAY_TYPE) \
|
|
|
|
V(FIXED_FLOAT64_ARRAY_TYPE) \
|
|
|
|
V(FIXED_UINT8_CLAMPED_ARRAY_TYPE) \
|
|
|
|
\
|
|
|
|
V(FIXED_DOUBLE_ARRAY_TYPE) \
|
|
|
|
V(FILLER_TYPE) \
|
|
|
|
\
|
|
|
|
V(ACCESSOR_INFO_TYPE) \
|
|
|
|
V(ACCESSOR_PAIR_TYPE) \
|
|
|
|
V(ACCESS_CHECK_INFO_TYPE) \
|
|
|
|
V(INTERCEPTOR_INFO_TYPE) \
|
|
|
|
V(FUNCTION_TEMPLATE_INFO_TYPE) \
|
|
|
|
V(OBJECT_TEMPLATE_INFO_TYPE) \
|
|
|
|
V(ALLOCATION_SITE_TYPE) \
|
|
|
|
V(ALLOCATION_MEMENTO_TYPE) \
|
|
|
|
V(SCRIPT_TYPE) \
|
|
|
|
V(ALIASED_ARGUMENTS_ENTRY_TYPE) \
|
|
|
|
V(PROMISE_RESOLVE_THENABLE_JOB_INFO_TYPE) \
|
|
|
|
V(PROMISE_REACTION_JOB_INFO_TYPE) \
|
|
|
|
V(DEBUG_INFO_TYPE) \
|
|
|
|
V(STACK_FRAME_INFO_TYPE) \
|
|
|
|
V(PROTOTYPE_INFO_TYPE) \
|
|
|
|
V(TUPLE2_TYPE) \
|
|
|
|
V(TUPLE3_TYPE) \
|
|
|
|
V(CONTEXT_EXTENSION_TYPE) \
|
|
|
|
V(MODULE_TYPE) \
|
|
|
|
V(MODULE_INFO_ENTRY_TYPE) \
|
|
|
|
V(ASYNC_GENERATOR_REQUEST_TYPE) \
|
2017-06-30 10:38:38 +00:00
|
|
|
V(PREPARSED_SCOPE_DATA_TYPE) \
|
2017-04-18 12:46:39 +00:00
|
|
|
V(FIXED_ARRAY_TYPE) \
|
|
|
|
V(TRANSITION_ARRAY_TYPE) \
|
|
|
|
V(SHARED_FUNCTION_INFO_TYPE) \
|
|
|
|
V(CELL_TYPE) \
|
|
|
|
V(WEAK_CELL_TYPE) \
|
|
|
|
V(PROPERTY_CELL_TYPE) \
|
2017-06-19 23:19:16 +00:00
|
|
|
V(SMALL_ORDERED_HASH_MAP_TYPE) \
|
2017-05-29 09:29:19 +00:00
|
|
|
V(SMALL_ORDERED_HASH_SET_TYPE) \
|
2017-04-18 12:46:39 +00:00
|
|
|
/* TODO(yangguo): these padding types are for ABI stability. Remove after*/ \
|
|
|
|
/* version 6.0 branch, or replace them when there is demand for new types.*/ \
|
|
|
|
V(PADDING_TYPE_1) \
|
|
|
|
V(PADDING_TYPE_2) \
|
|
|
|
V(PADDING_TYPE_3) \
|
|
|
|
\
|
|
|
|
V(JS_PROXY_TYPE) \
|
|
|
|
V(JS_GLOBAL_OBJECT_TYPE) \
|
|
|
|
V(JS_GLOBAL_PROXY_TYPE) \
|
|
|
|
V(JS_SPECIAL_API_OBJECT_TYPE) \
|
|
|
|
V(JS_VALUE_TYPE) \
|
|
|
|
V(JS_MESSAGE_OBJECT_TYPE) \
|
|
|
|
V(JS_DATE_TYPE) \
|
|
|
|
V(JS_API_OBJECT_TYPE) \
|
|
|
|
V(JS_OBJECT_TYPE) \
|
|
|
|
V(JS_ARGUMENTS_TYPE) \
|
|
|
|
V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \
|
|
|
|
V(JS_GENERATOR_OBJECT_TYPE) \
|
|
|
|
V(JS_ASYNC_GENERATOR_OBJECT_TYPE) \
|
|
|
|
V(JS_MODULE_NAMESPACE_TYPE) \
|
|
|
|
V(JS_ARRAY_TYPE) \
|
|
|
|
V(JS_ARRAY_BUFFER_TYPE) \
|
|
|
|
V(JS_TYPED_ARRAY_TYPE) \
|
|
|
|
V(JS_DATA_VIEW_TYPE) \
|
|
|
|
V(JS_SET_TYPE) \
|
|
|
|
V(JS_MAP_TYPE) \
|
|
|
|
V(JS_SET_ITERATOR_TYPE) \
|
|
|
|
V(JS_MAP_ITERATOR_TYPE) \
|
|
|
|
V(JS_WEAK_MAP_TYPE) \
|
|
|
|
V(JS_WEAK_SET_TYPE) \
|
|
|
|
V(JS_PROMISE_CAPABILITY_TYPE) \
|
|
|
|
V(JS_PROMISE_TYPE) \
|
|
|
|
V(JS_REGEXP_TYPE) \
|
|
|
|
V(JS_ERROR_TYPE) \
|
|
|
|
V(JS_ASYNC_FROM_SYNC_ITERATOR_TYPE) \
|
|
|
|
V(JS_STRING_ITERATOR_TYPE) \
|
|
|
|
\
|
|
|
|
V(JS_TYPED_ARRAY_KEY_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_ARRAY_KEY_ITERATOR_TYPE) \
|
|
|
|
V(JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE) \
|
|
|
|
\
|
|
|
|
V(JS_UINT8_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_INT8_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_UINT16_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_INT16_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_UINT32_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_INT32_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FLOAT32_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FLOAT64_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_UINT8_CLAMPED_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
\
|
|
|
|
V(JS_FAST_SMI_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_HOLEY_SMI_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_HOLEY_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_DOUBLE_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_HOLEY_DOUBLE_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_GENERIC_ARRAY_KEY_VALUE_ITERATOR_TYPE) \
|
|
|
|
\
|
|
|
|
V(JS_UINT8_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_INT8_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_UINT16_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_INT16_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_UINT32_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_INT32_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FLOAT32_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FLOAT64_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_UINT8_CLAMPED_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
\
|
|
|
|
V(JS_FAST_SMI_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_HOLEY_SMI_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_HOLEY_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_DOUBLE_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_FAST_HOLEY_DOUBLE_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
V(JS_GENERIC_ARRAY_VALUE_ITERATOR_TYPE) \
|
|
|
|
\
|
|
|
|
V(JS_BOUND_FUNCTION_TYPE) \
|
2016-12-19 12:50:30 +00:00
|
|
|
V(JS_FUNCTION_TYPE)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Since string types are not consecutive, this macro is used to
|
|
|
|
// iterate over them.
|
2014-09-10 12:38:12 +00:00
|
|
|
#define STRING_TYPE_LIST(V) \
|
|
|
|
V(STRING_TYPE, kVariableSizeSentinel, string, String) \
|
|
|
|
V(ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, one_byte_string, \
|
|
|
|
OneByteString) \
|
|
|
|
V(CONS_STRING_TYPE, ConsString::kSize, cons_string, ConsString) \
|
|
|
|
V(CONS_ONE_BYTE_STRING_TYPE, ConsString::kSize, cons_one_byte_string, \
|
|
|
|
ConsOneByteString) \
|
|
|
|
V(SLICED_STRING_TYPE, SlicedString::kSize, sliced_string, SlicedString) \
|
|
|
|
V(SLICED_ONE_BYTE_STRING_TYPE, SlicedString::kSize, sliced_one_byte_string, \
|
|
|
|
SlicedOneByteString) \
|
|
|
|
V(EXTERNAL_STRING_TYPE, ExternalTwoByteString::kSize, external_string, \
|
|
|
|
ExternalString) \
|
|
|
|
V(EXTERNAL_ONE_BYTE_STRING_TYPE, ExternalOneByteString::kSize, \
|
|
|
|
external_one_byte_string, ExternalOneByteString) \
|
|
|
|
V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE, ExternalTwoByteString::kSize, \
|
|
|
|
external_string_with_one_byte_data, ExternalStringWithOneByteData) \
|
|
|
|
V(SHORT_EXTERNAL_STRING_TYPE, ExternalTwoByteString::kShortSize, \
|
|
|
|
short_external_string, ShortExternalString) \
|
|
|
|
V(SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE, ExternalOneByteString::kShortSize, \
|
|
|
|
short_external_one_byte_string, ShortExternalOneByteString) \
|
|
|
|
V(SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE, \
|
|
|
|
ExternalTwoByteString::kShortSize, \
|
|
|
|
short_external_string_with_one_byte_data, \
|
|
|
|
ShortExternalStringWithOneByteData) \
|
|
|
|
\
|
|
|
|
V(INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, internalized_string, \
|
|
|
|
InternalizedString) \
|
|
|
|
V(ONE_BYTE_INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, \
|
|
|
|
one_byte_internalized_string, OneByteInternalizedString) \
|
|
|
|
V(EXTERNAL_INTERNALIZED_STRING_TYPE, ExternalTwoByteString::kSize, \
|
|
|
|
external_internalized_string, ExternalInternalizedString) \
|
|
|
|
V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, ExternalOneByteString::kSize, \
|
|
|
|
external_one_byte_internalized_string, ExternalOneByteInternalizedString) \
|
|
|
|
V(EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE, \
|
|
|
|
ExternalTwoByteString::kSize, \
|
|
|
|
external_internalized_string_with_one_byte_data, \
|
|
|
|
ExternalInternalizedStringWithOneByteData) \
|
|
|
|
V(SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE, \
|
|
|
|
ExternalTwoByteString::kShortSize, short_external_internalized_string, \
|
|
|
|
ShortExternalInternalizedString) \
|
|
|
|
V(SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, \
|
|
|
|
ExternalOneByteString::kShortSize, \
|
|
|
|
short_external_one_byte_internalized_string, \
|
|
|
|
ShortExternalOneByteInternalizedString) \
|
|
|
|
V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE, \
|
|
|
|
ExternalTwoByteString::kShortSize, \
|
|
|
|
short_external_internalized_string_with_one_byte_data, \
|
2017-01-19 13:27:59 +00:00
|
|
|
ShortExternalInternalizedStringWithOneByteData) \
|
|
|
|
V(THIN_STRING_TYPE, ThinString::kSize, thin_string, ThinString) \
|
|
|
|
V(THIN_ONE_BYTE_STRING_TYPE, ThinString::kSize, thin_one_byte_string, \
|
|
|
|
ThinOneByteString)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// A struct is a simple object a set of object-valued fields. Including an
|
|
|
|
// object type in this causes the compiler to generate most of the boilerplate
|
|
|
|
// code for the class including allocation and garbage collection routines,
|
|
|
|
// casts and predicates. All you need to define is the class, methods and
|
|
|
|
// object verification routines. Easy, no?
|
|
|
|
//
|
|
|
|
// Note that for subtle reasons related to the ordering or numerical values of
|
|
|
|
// type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST
|
|
|
|
// manually.
|
2015-04-07 10:42:45 +00:00
|
|
|
#define STRUCT_LIST(V) \
|
2016-01-18 15:08:36 +00:00
|
|
|
V(ACCESSOR_INFO, AccessorInfo, accessor_info) \
|
2015-04-07 10:42:45 +00:00
|
|
|
V(ACCESSOR_PAIR, AccessorPair, accessor_pair) \
|
|
|
|
V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \
|
|
|
|
V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \
|
|
|
|
V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \
|
|
|
|
V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \
|
|
|
|
V(ALLOCATION_SITE, AllocationSite, allocation_site) \
|
|
|
|
V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \
|
2016-12-19 12:50:30 +00:00
|
|
|
V(SCRIPT, Script, script) \
|
2015-04-07 10:42:45 +00:00
|
|
|
V(ALIASED_ARGUMENTS_ENTRY, AliasedArgumentsEntry, aliased_arguments_entry) \
|
2016-12-19 12:50:30 +00:00
|
|
|
V(PROMISE_RESOLVE_THENABLE_JOB_INFO, PromiseResolveThenableJobInfo, \
|
|
|
|
promise_resolve_thenable_job_info) \
|
|
|
|
V(PROMISE_REACTION_JOB_INFO, PromiseReactionJobInfo, \
|
|
|
|
promise_reaction_job_info) \
|
2015-04-07 10:42:45 +00:00
|
|
|
V(DEBUG_INFO, DebugInfo, debug_info) \
|
2017-04-03 14:58:49 +00:00
|
|
|
V(STACK_FRAME_INFO, StackFrameInfo, stack_frame_info) \
|
[es6] Parameter scopes for sloppy eval
This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,
let x = 1;
function f(g = () => x) {
var y
eval("var x = 2")
return g() + x // f() = 3
}
we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:
- Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.
- When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).
- While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.
- Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.
- Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.
- In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.
- In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.
- ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.
- Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.
- While at it, refactor and unify some respective code in the debugger.
Sorry, this CL is large. I could try to split it up, but everything is rather entangled.
@mstarzinger: Please review the changes to contexts.
@yangguo: Please have a look at the debugger stuff.
R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
BUG=v8:811,v8:2160
LOG=N
Review URL: https://codereview.chromium.org/1292753007
Cr-Commit-Position: refs/heads/master@{#30295}
2015-08-21 10:58:35 +00:00
|
|
|
V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) \
|
2016-12-02 10:03:18 +00:00
|
|
|
V(TUPLE2, Tuple2, tuple2) \
|
2016-10-13 16:18:53 +00:00
|
|
|
V(TUPLE3, Tuple3, tuple3) \
|
2016-12-16 10:57:06 +00:00
|
|
|
V(CONTEXT_EXTENSION, ContextExtension, context_extension) \
|
2016-12-19 12:50:30 +00:00
|
|
|
V(MODULE, Module, module) \
|
[async-iteration] implement AsyncGenerator
- Introduce new struct AsyncGeneratorRequest, which holds
information pertinent to resuming execution of an
AsyncGenerator, such as the Promise associated with the async
generator request. It is intended to be used as a singly
linked list, and holds a pointer to the next item in te queue.
- Introduce JSAsyncGeneratorObject (subclass of
JSGeneratorObject), which includes several new internal fields
(`queue` which contains a singly linked list of
AsyncGeneratorRequest objects, and `await_input` which
contains the sent value from an Await expression (This is
necessary to prevent function.sent (used by yield*) from
having the sent value observably overwritten during
execution).
- Modify SuspendGenerator to accept a set of Flags, which
indicate whether the suspend is for a Yield or Await, and
whether it takes place on an async generator or ES6
generator.
- Introduce interpreter intrinsics and TF intrinsic lowering for
accessing the await input of an async generator
- Modify the JSGeneratorStore operator to understand whether or
not it's suspending for a normal yield, or an AsyncGenerator
Await. This ensures appropriate registers are stored.
- Add versions of ResumeGeneratorTrampoline which store the
input value in a different field depending on wether it's an
AsyncGenerator Await resume, or an ordinary resume. Also modifies
whether debug code will assert that the generator object is a
JSGeneratorObject or a JSAsyncGeneratorObject depending on the
resume type.
BUG=v8:5855
R=bmeurer@chromium.org, rmcilroy@chromium.org, jgruber@chromium.org,
littledan@chromium.org, neis@chromium.org
TBR=marja@chromium.org
Change-Id: I9d58df1d344465fc937fe7eed322424204497187
Reviewed-on: https://chromium-review.googlesource.com/446961
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44240}
2017-03-29 13:41:45 +00:00
|
|
|
V(MODULE_INFO_ENTRY, ModuleInfoEntry, module_info_entry) \
|
2017-06-30 10:38:38 +00:00
|
|
|
V(ASYNC_GENERATOR_REQUEST, AsyncGeneratorRequest, async_generator_request) \
|
|
|
|
V(PREPARSED_SCOPE_DATA, PreParsedScopeData, preparsed_scope_data)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// We use the full 8 bits of the instance_type field to encode heap object
|
|
|
|
// instance types. The high-order bit (bit 7) is set if the object is not a
|
|
|
|
// string, and cleared if it is a string.
|
|
|
|
const uint32_t kIsNotStringMask = 0x80;
|
|
|
|
const uint32_t kStringTag = 0x0;
|
|
|
|
const uint32_t kNotStringTag = 0x80;
|
|
|
|
|
2013-02-28 17:03:34 +00:00
|
|
|
// Bit 6 indicates that the object is an internalized string (if set) or not.
|
2013-06-27 13:39:44 +00:00
|
|
|
// Bit 7 has to be clear as well.
|
2013-07-19 11:29:11 +00:00
|
|
|
const uint32_t kIsNotInternalizedMask = 0x40;
|
|
|
|
const uint32_t kNotInternalizedTag = 0x40;
|
|
|
|
const uint32_t kInternalizedTag = 0x0;
|
2008-10-27 12:39:34 +00:00
|
|
|
|
2017-01-19 13:27:59 +00:00
|
|
|
// If bit 7 is clear then bit 3 indicates whether the string consists of
|
2008-10-27 12:39:34 +00:00
|
|
|
// two-byte characters or one-byte characters.
|
2017-01-19 13:27:59 +00:00
|
|
|
const uint32_t kStringEncodingMask = 0x8;
|
2008-07-03 15:10:15 +00:00
|
|
|
const uint32_t kTwoByteStringTag = 0x0;
|
2017-01-19 13:27:59 +00:00
|
|
|
const uint32_t kOneByteStringTag = 0x8;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-01-19 13:27:59 +00:00
|
|
|
// If bit 7 is clear, the low-order 3 bits indicate the representation
|
2008-07-03 15:10:15 +00:00
|
|
|
// of the string.
|
2017-01-19 13:27:59 +00:00
|
|
|
const uint32_t kStringRepresentationMask = 0x07;
|
2008-07-03 15:10:15 +00:00
|
|
|
enum StringRepresentationTag {
|
|
|
|
kSeqStringTag = 0x0,
|
|
|
|
kConsStringTag = 0x1,
|
2011-08-26 13:03:30 +00:00
|
|
|
kExternalStringTag = 0x2,
|
2017-01-19 13:27:59 +00:00
|
|
|
kSlicedStringTag = 0x3,
|
|
|
|
kThinStringTag = 0x5
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
2011-08-26 13:03:30 +00:00
|
|
|
const uint32_t kIsIndirectStringMask = 0x1;
|
|
|
|
const uint32_t kIsIndirectStringTag = 0x1;
|
2014-06-03 15:45:38 +00:00
|
|
|
STATIC_ASSERT((kSeqStringTag & kIsIndirectStringMask) == 0); // NOLINT
|
|
|
|
STATIC_ASSERT((kExternalStringTag & kIsIndirectStringMask) == 0); // NOLINT
|
|
|
|
STATIC_ASSERT((kConsStringTag &
|
|
|
|
kIsIndirectStringMask) == kIsIndirectStringTag); // NOLINT
|
|
|
|
STATIC_ASSERT((kSlicedStringTag &
|
|
|
|
kIsIndirectStringMask) == kIsIndirectStringTag); // NOLINT
|
2017-01-19 13:27:59 +00:00
|
|
|
STATIC_ASSERT((kThinStringTag & kIsIndirectStringMask) == kIsIndirectStringTag);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-01-19 13:27:59 +00:00
|
|
|
// If bit 7 is clear, then bit 4 indicates whether this two-byte
|
2013-04-26 11:34:44 +00:00
|
|
|
// string actually contains one byte data.
|
2017-01-19 13:27:59 +00:00
|
|
|
const uint32_t kOneByteDataHintMask = 0x10;
|
|
|
|
const uint32_t kOneByteDataHintTag = 0x10;
|
2010-06-17 16:19:28 +00:00
|
|
|
|
2011-11-23 13:08:28 +00:00
|
|
|
// If bit 7 is clear and string representation indicates an external string,
|
2017-01-19 13:27:59 +00:00
|
|
|
// then bit 5 indicates whether the data pointer is cached.
|
|
|
|
const uint32_t kShortExternalStringMask = 0x20;
|
|
|
|
const uint32_t kShortExternalStringTag = 0x20;
|
2009-04-14 12:00:56 +00:00
|
|
|
|
|
|
|
// A ConsString with an empty string as the right side is a candidate
|
2014-07-15 09:19:22 +00:00
|
|
|
// for being shortcut by the garbage collector. We don't allocate any
|
|
|
|
// non-flat internalized strings, so we do not shortcut them thereby
|
|
|
|
// avoiding turning internalized strings into strings. The bit-masks
|
|
|
|
// below contain the internalized bit as additional safety.
|
|
|
|
// See heap.cc, mark-compact.cc and objects-visiting.cc.
|
2009-04-14 12:00:56 +00:00
|
|
|
const uint32_t kShortcutTypeMask =
|
|
|
|
kIsNotStringMask |
|
2013-07-19 11:29:11 +00:00
|
|
|
kIsNotInternalizedMask |
|
2009-04-14 12:00:56 +00:00
|
|
|
kStringRepresentationMask;
|
2013-07-19 11:29:11 +00:00
|
|
|
const uint32_t kShortcutTypeTag = kConsStringTag | kNotInternalizedTag;
|
2009-04-14 12:00:56 +00:00
|
|
|
|
2014-07-15 09:19:22 +00:00
|
|
|
static inline bool IsShortcutCandidate(int type) {
|
|
|
|
return ((type & kShortcutTypeMask) == kShortcutTypeTag);
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
enum InstanceType {
|
2009-12-22 13:34:02 +00:00
|
|
|
// String types.
|
2015-08-11 19:36:04 +00:00
|
|
|
INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kSeqStringTag |
|
|
|
|
kInternalizedTag, // FIRST_PRIMITIVE_TYPE
|
2014-09-10 12:38:12 +00:00
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE =
|
|
|
|
kOneByteStringTag | kSeqStringTag | kInternalizedTag,
|
|
|
|
EXTERNAL_INTERNALIZED_STRING_TYPE =
|
|
|
|
kTwoByteStringTag | kExternalStringTag | kInternalizedTag,
|
|
|
|
EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE =
|
|
|
|
kOneByteStringTag | kExternalStringTag | kInternalizedTag,
|
2013-04-26 11:34:44 +00:00
|
|
|
EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE =
|
2014-09-10 12:38:12 +00:00
|
|
|
EXTERNAL_INTERNALIZED_STRING_TYPE | kOneByteDataHintTag |
|
|
|
|
kInternalizedTag,
|
|
|
|
SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE = EXTERNAL_INTERNALIZED_STRING_TYPE |
|
|
|
|
kShortExternalStringTag |
|
|
|
|
kInternalizedTag,
|
|
|
|
SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE =
|
|
|
|
EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE | kShortExternalStringTag |
|
|
|
|
kInternalizedTag,
|
2013-04-26 11:34:44 +00:00
|
|
|
SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE =
|
2014-09-10 12:38:12 +00:00
|
|
|
EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
|
|
|
|
kShortExternalStringTag | kInternalizedTag,
|
2013-07-19 11:29:11 +00:00
|
|
|
STRING_TYPE = INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
|
2014-09-10 12:38:12 +00:00
|
|
|
ONE_BYTE_STRING_TYPE =
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
|
2014-04-01 11:30:31 +00:00
|
|
|
CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag | kNotInternalizedTag,
|
2014-09-10 12:38:12 +00:00
|
|
|
CONS_ONE_BYTE_STRING_TYPE =
|
2014-04-01 11:30:31 +00:00
|
|
|
kOneByteStringTag | kConsStringTag | kNotInternalizedTag,
|
2013-07-19 11:29:11 +00:00
|
|
|
SLICED_STRING_TYPE =
|
|
|
|
kTwoByteStringTag | kSlicedStringTag | kNotInternalizedTag,
|
2014-09-10 12:38:12 +00:00
|
|
|
SLICED_ONE_BYTE_STRING_TYPE =
|
2013-07-19 11:29:11 +00:00
|
|
|
kOneByteStringTag | kSlicedStringTag | kNotInternalizedTag,
|
|
|
|
EXTERNAL_STRING_TYPE =
|
2014-09-10 12:38:12 +00:00
|
|
|
EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
|
|
|
|
EXTERNAL_ONE_BYTE_STRING_TYPE =
|
|
|
|
EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
|
2013-07-19 11:29:11 +00:00
|
|
|
EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE =
|
2014-09-10 12:38:12 +00:00
|
|
|
EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
|
|
|
|
kNotInternalizedTag,
|
2013-07-19 11:29:11 +00:00
|
|
|
SHORT_EXTERNAL_STRING_TYPE =
|
|
|
|
SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
|
2014-09-10 12:38:12 +00:00
|
|
|
SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE =
|
|
|
|
SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
|
2013-07-19 11:29:11 +00:00
|
|
|
SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE =
|
2014-09-10 12:38:12 +00:00
|
|
|
SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
|
|
|
|
kNotInternalizedTag,
|
2017-01-19 13:27:59 +00:00
|
|
|
THIN_STRING_TYPE = kTwoByteStringTag | kThinStringTag | kNotInternalizedTag,
|
|
|
|
THIN_ONE_BYTE_STRING_TYPE =
|
|
|
|
kOneByteStringTag | kThinStringTag | kNotInternalizedTag,
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-03-01 10:34:31 +00:00
|
|
|
// Non-string names
|
Provide private symbols through internal APIs
Adds a notion of private symbols, mainly intended for internal use, especially, self-hosting of built-in types that would otherwise require new C++ classes.
On the JS side (i.e., in built-ins), private properties can be created and accessed through a set of macros:
NEW_PRIVATE(print_name)
HAS_PRIVATE(obj, sym)
GET_PRIVATE(obj, sym)
SET_PRIVATE(obj, sym, val)
DELETE_PRIVATE(obj, sym)
In the V8 API, they are accessible via a new class Private, and respective HasPrivate/Get/Private/SetPrivate/DeletePrivate methods on calss Object.
These APIs are designed and restricted such that their implementation can later be replaced by whatever ES7+ will officially provide.
R=yangguo@chromium.org
BUG=
Review URL: https://codereview.chromium.org/48923002
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17683 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2013-11-13 10:34:06 +00:00
|
|
|
SYMBOL_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE, LAST_NAME_TYPE
|
2013-03-01 10:34:31 +00:00
|
|
|
|
2015-08-11 19:36:04 +00:00
|
|
|
// Other primitives (cannot contain non-map-word pointers to heap objects).
|
|
|
|
HEAP_NUMBER_TYPE,
|
|
|
|
ODDBALL_TYPE, // LAST_PRIMITIVE_TYPE
|
|
|
|
|
2009-12-22 13:34:02 +00:00
|
|
|
// Objects allocated in their own spaces (never in new space).
|
2013-03-01 10:34:31 +00:00
|
|
|
MAP_TYPE,
|
2008-07-03 15:10:15 +00:00
|
|
|
CODE_TYPE,
|
2009-12-22 13:34:02 +00:00
|
|
|
|
|
|
|
// "Data", objects that cannot contain non-map-word pointers to heap
|
|
|
|
// objects.
|
2014-07-01 15:02:31 +00:00
|
|
|
MUTABLE_HEAP_NUMBER_TYPE,
|
2011-05-19 11:47:34 +00:00
|
|
|
FOREIGN_TYPE,
|
2008-07-03 15:10:15 +00:00
|
|
|
BYTE_ARRAY_TYPE,
|
2015-07-24 12:02:41 +00:00
|
|
|
BYTECODE_ARRAY_TYPE,
|
2011-09-19 18:36:47 +00:00
|
|
|
FREE_SPACE_TYPE,
|
2015-08-03 13:02:39 +00:00
|
|
|
FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE
|
2014-01-16 17:08:45 +00:00
|
|
|
FIXED_UINT8_ARRAY_TYPE,
|
|
|
|
FIXED_INT16_ARRAY_TYPE,
|
|
|
|
FIXED_UINT16_ARRAY_TYPE,
|
|
|
|
FIXED_INT32_ARRAY_TYPE,
|
|
|
|
FIXED_UINT32_ARRAY_TYPE,
|
|
|
|
FIXED_FLOAT32_ARRAY_TYPE,
|
|
|
|
FIXED_FLOAT64_ARRAY_TYPE,
|
|
|
|
FIXED_UINT8_CLAMPED_ARRAY_TYPE, // LAST_FIXED_TYPED_ARRAY_TYPE
|
2011-06-09 10:03:35 +00:00
|
|
|
FIXED_DOUBLE_ARRAY_TYPE,
|
2009-12-22 13:34:02 +00:00
|
|
|
FILLER_TYPE, // LAST_DATA_TYPE
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-12-22 13:34:02 +00:00
|
|
|
// Structs.
|
2016-01-18 15:08:36 +00:00
|
|
|
ACCESSOR_INFO_TYPE,
|
2012-01-10 16:11:33 +00:00
|
|
|
ACCESSOR_PAIR_TYPE,
|
2008-07-03 15:10:15 +00:00
|
|
|
ACCESS_CHECK_INFO_TYPE,
|
|
|
|
INTERCEPTOR_INFO_TYPE,
|
|
|
|
FUNCTION_TEMPLATE_INFO_TYPE,
|
|
|
|
OBJECT_TEMPLATE_INFO_TYPE,
|
2013-07-08 10:02:16 +00:00
|
|
|
ALLOCATION_SITE_TYPE,
|
2013-07-19 13:30:49 +00:00
|
|
|
ALLOCATION_MEMENTO_TYPE,
|
2009-12-22 13:34:02 +00:00
|
|
|
SCRIPT_TYPE,
|
2012-02-24 14:34:01 +00:00
|
|
|
ALIASED_ARGUMENTS_ENTRY_TYPE,
|
2016-10-12 22:18:54 +00:00
|
|
|
PROMISE_RESOLVE_THENABLE_JOB_INFO_TYPE,
|
2016-10-12 20:45:28 +00:00
|
|
|
PROMISE_REACTION_JOB_INFO_TYPE,
|
2008-07-03 15:10:15 +00:00
|
|
|
DEBUG_INFO_TYPE,
|
2017-04-03 14:58:49 +00:00
|
|
|
STACK_FRAME_INFO_TYPE,
|
2015-04-07 10:42:45 +00:00
|
|
|
PROTOTYPE_INFO_TYPE,
|
2016-12-02 10:03:18 +00:00
|
|
|
TUPLE2_TYPE,
|
2016-10-13 16:18:53 +00:00
|
|
|
TUPLE3_TYPE,
|
2016-09-01 15:03:44 +00:00
|
|
|
CONTEXT_EXTENSION_TYPE,
|
2016-09-16 16:47:07 +00:00
|
|
|
MODULE_TYPE,
|
2016-11-04 09:37:22 +00:00
|
|
|
MODULE_INFO_ENTRY_TYPE,
|
[async-iteration] implement AsyncGenerator
- Introduce new struct AsyncGeneratorRequest, which holds
information pertinent to resuming execution of an
AsyncGenerator, such as the Promise associated with the async
generator request. It is intended to be used as a singly
linked list, and holds a pointer to the next item in te queue.
- Introduce JSAsyncGeneratorObject (subclass of
JSGeneratorObject), which includes several new internal fields
(`queue` which contains a singly linked list of
AsyncGeneratorRequest objects, and `await_input` which
contains the sent value from an Await expression (This is
necessary to prevent function.sent (used by yield*) from
having the sent value observably overwritten during
execution).
- Modify SuspendGenerator to accept a set of Flags, which
indicate whether the suspend is for a Yield or Await, and
whether it takes place on an async generator or ES6
generator.
- Introduce interpreter intrinsics and TF intrinsic lowering for
accessing the await input of an async generator
- Modify the JSGeneratorStore operator to understand whether or
not it's suspending for a normal yield, or an AsyncGenerator
Await. This ensures appropriate registers are stored.
- Add versions of ResumeGeneratorTrampoline which store the
input value in a different field depending on wether it's an
AsyncGenerator Await resume, or an ordinary resume. Also modifies
whether debug code will assert that the generator object is a
JSGeneratorObject or a JSAsyncGeneratorObject depending on the
resume type.
BUG=v8:5855
R=bmeurer@chromium.org, rmcilroy@chromium.org, jgruber@chromium.org,
littledan@chromium.org, neis@chromium.org
TBR=marja@chromium.org
Change-Id: I9d58df1d344465fc937fe7eed322424204497187
Reviewed-on: https://chromium-review.googlesource.com/446961
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44240}
2017-03-29 13:41:45 +00:00
|
|
|
ASYNC_GENERATOR_REQUEST_TYPE,
|
2017-06-30 10:38:38 +00:00
|
|
|
PREPARSED_SCOPE_DATA_TYPE,
|
2016-12-19 12:50:30 +00:00
|
|
|
FIXED_ARRAY_TYPE,
|
|
|
|
TRANSITION_ARRAY_TYPE,
|
|
|
|
SHARED_FUNCTION_INFO_TYPE,
|
|
|
|
CELL_TYPE,
|
|
|
|
WEAK_CELL_TYPE,
|
|
|
|
PROPERTY_CELL_TYPE,
|
2017-06-19 23:19:16 +00:00
|
|
|
SMALL_ORDERED_HASH_MAP_TYPE,
|
2017-05-29 09:29:19 +00:00
|
|
|
SMALL_ORDERED_HASH_SET_TYPE,
|
2009-12-22 13:34:02 +00:00
|
|
|
|
2017-05-23 13:01:29 +00:00
|
|
|
// TODO(yangguo): these padding types are for ABI stability. Remove after
|
|
|
|
// version 6.0 branch, or replace them when there is demand for new types.
|
2017-04-18 12:46:39 +00:00
|
|
|
PADDING_TYPE_1,
|
|
|
|
PADDING_TYPE_2,
|
|
|
|
PADDING_TYPE_3,
|
|
|
|
|
2011-09-21 14:46:54 +00:00
|
|
|
// All the following types are subtypes of JSReceiver, which corresponds to
|
|
|
|
// objects in the JS sense. The first and the last type in this range are
|
|
|
|
// the two forms of function. This organization enables using the same
|
2015-11-30 09:49:19 +00:00
|
|
|
// compares for checking the JS_RECEIVER and the NONCALLABLE_JS_OBJECT range.
|
2016-03-04 11:51:55 +00:00
|
|
|
JS_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE
|
|
|
|
JS_GLOBAL_OBJECT_TYPE, // FIRST_JS_OBJECT_TYPE
|
|
|
|
JS_GLOBAL_PROXY_TYPE,
|
2016-04-12 10:31:38 +00:00
|
|
|
// Like JS_API_OBJECT_TYPE, but requires access checks and/or has
|
|
|
|
// interceptors.
|
2016-03-04 11:51:55 +00:00
|
|
|
JS_SPECIAL_API_OBJECT_TYPE, // LAST_SPECIAL_RECEIVER_TYPE
|
2016-03-21 14:14:39 +00:00
|
|
|
JS_VALUE_TYPE, // LAST_CUSTOM_ELEMENTS_RECEIVER
|
2014-04-28 13:42:03 +00:00
|
|
|
JS_MESSAGE_OBJECT_TYPE,
|
2012-03-09 11:11:55 +00:00
|
|
|
JS_DATE_TYPE,
|
2016-04-12 10:31:38 +00:00
|
|
|
// Like JS_OBJECT_TYPE, but created from API function.
|
|
|
|
JS_API_OBJECT_TYPE,
|
2008-07-03 15:10:15 +00:00
|
|
|
JS_OBJECT_TYPE,
|
2016-06-23 14:39:30 +00:00
|
|
|
JS_ARGUMENTS_TYPE,
|
2009-01-14 12:13:26 +00:00
|
|
|
JS_CONTEXT_EXTENSION_OBJECT_TYPE,
|
2013-04-15 12:29:44 +00:00
|
|
|
JS_GENERATOR_OBJECT_TYPE,
|
[async-iteration] implement AsyncGenerator
- Introduce new struct AsyncGeneratorRequest, which holds
information pertinent to resuming execution of an
AsyncGenerator, such as the Promise associated with the async
generator request. It is intended to be used as a singly
linked list, and holds a pointer to the next item in te queue.
- Introduce JSAsyncGeneratorObject (subclass of
JSGeneratorObject), which includes several new internal fields
(`queue` which contains a singly linked list of
AsyncGeneratorRequest objects, and `await_input` which
contains the sent value from an Await expression (This is
necessary to prevent function.sent (used by yield*) from
having the sent value observably overwritten during
execution).
- Modify SuspendGenerator to accept a set of Flags, which
indicate whether the suspend is for a Yield or Await, and
whether it takes place on an async generator or ES6
generator.
- Introduce interpreter intrinsics and TF intrinsic lowering for
accessing the await input of an async generator
- Modify the JSGeneratorStore operator to understand whether or
not it's suspending for a normal yield, or an AsyncGenerator
Await. This ensures appropriate registers are stored.
- Add versions of ResumeGeneratorTrampoline which store the
input value in a different field depending on wether it's an
AsyncGenerator Await resume, or an ordinary resume. Also modifies
whether debug code will assert that the generator object is a
JSGeneratorObject or a JSAsyncGeneratorObject depending on the
resume type.
BUG=v8:5855
R=bmeurer@chromium.org, rmcilroy@chromium.org, jgruber@chromium.org,
littledan@chromium.org, neis@chromium.org
TBR=marja@chromium.org
Change-Id: I9d58df1d344465fc937fe7eed322424204497187
Reviewed-on: https://chromium-review.googlesource.com/446961
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44240}
2017-03-29 13:41:45 +00:00
|
|
|
JS_ASYNC_GENERATOR_OBJECT_TYPE,
|
2016-10-07 19:37:04 +00:00
|
|
|
JS_MODULE_NAMESPACE_TYPE,
|
2008-07-03 15:10:15 +00:00
|
|
|
JS_ARRAY_TYPE,
|
2013-03-28 12:50:18 +00:00
|
|
|
JS_ARRAY_BUFFER_TYPE,
|
2013-04-16 14:16:30 +00:00
|
|
|
JS_TYPED_ARRAY_TYPE,
|
2013-06-21 13:02:38 +00:00
|
|
|
JS_DATA_VIEW_TYPE,
|
2011-10-25 14:14:56 +00:00
|
|
|
JS_SET_TYPE,
|
|
|
|
JS_MAP_TYPE,
|
2014-04-17 17:45:32 +00:00
|
|
|
JS_SET_ITERATOR_TYPE,
|
|
|
|
JS_MAP_ITERATOR_TYPE,
|
2011-08-03 11:55:13 +00:00
|
|
|
JS_WEAK_MAP_TYPE,
|
2013-07-22 08:32:24 +00:00
|
|
|
JS_WEAK_SET_TYPE,
|
2017-01-02 17:22:30 +00:00
|
|
|
JS_PROMISE_CAPABILITY_TYPE,
|
2015-11-19 16:11:00 +00:00
|
|
|
JS_PROMISE_TYPE,
|
2011-09-21 14:46:54 +00:00
|
|
|
JS_REGEXP_TYPE,
|
2016-06-23 14:39:30 +00:00
|
|
|
JS_ERROR_TYPE,
|
2017-02-24 17:48:49 +00:00
|
|
|
JS_ASYNC_FROM_SYNC_ITERATOR_TYPE,
|
2016-09-21 14:17:42 +00:00
|
|
|
JS_STRING_ITERATOR_TYPE,
|
2016-10-18 02:42:42 +00:00
|
|
|
|
|
|
|
JS_TYPED_ARRAY_KEY_ITERATOR_TYPE,
|
|
|
|
JS_FAST_ARRAY_KEY_ITERATOR_TYPE,
|
|
|
|
JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE,
|
|
|
|
|
|
|
|
JS_UINT8_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_INT8_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_UINT16_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_INT16_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_UINT32_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_INT32_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FLOAT32_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FLOAT64_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_UINT8_CLAMPED_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
|
|
|
|
JS_FAST_SMI_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FAST_HOLEY_SMI_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FAST_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FAST_HOLEY_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FAST_DOUBLE_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FAST_HOLEY_DOUBLE_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_GENERIC_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
|
|
|
|
JS_UINT8_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_INT8_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_UINT16_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_INT16_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_UINT32_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_INT32_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FLOAT32_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FLOAT64_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_UINT8_CLAMPED_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
|
|
|
|
JS_FAST_SMI_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FAST_HOLEY_SMI_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FAST_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FAST_HOLEY_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FAST_DOUBLE_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_FAST_HOLEY_DOUBLE_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
JS_GENERIC_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
|
2015-12-27 06:30:53 +00:00
|
|
|
JS_BOUND_FUNCTION_TYPE,
|
2011-09-21 14:46:54 +00:00
|
|
|
JS_FUNCTION_TYPE, // LAST_JS_OBJECT_TYPE, LAST_JS_RECEIVER_TYPE
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Pseudo-types
|
|
|
|
FIRST_TYPE = 0x0,
|
2011-09-21 14:46:54 +00:00
|
|
|
LAST_TYPE = JS_FUNCTION_TYPE,
|
2013-03-01 13:28:55 +00:00
|
|
|
FIRST_NAME_TYPE = FIRST_TYPE,
|
2013-03-01 10:34:31 +00:00
|
|
|
LAST_NAME_TYPE = SYMBOL_TYPE,
|
2013-03-01 13:28:55 +00:00
|
|
|
FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE,
|
|
|
|
LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE,
|
2013-03-01 10:34:31 +00:00
|
|
|
FIRST_NONSTRING_TYPE = SYMBOL_TYPE,
|
2015-08-11 19:36:04 +00:00
|
|
|
FIRST_PRIMITIVE_TYPE = FIRST_NAME_TYPE,
|
|
|
|
LAST_PRIMITIVE_TYPE = ODDBALL_TYPE,
|
2015-12-27 06:30:53 +00:00
|
|
|
FIRST_FUNCTION_TYPE = JS_BOUND_FUNCTION_TYPE,
|
|
|
|
LAST_FUNCTION_TYPE = JS_FUNCTION_TYPE,
|
2014-01-16 17:08:45 +00:00
|
|
|
// Boundaries for testing for a fixed typed array.
|
|
|
|
FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE,
|
|
|
|
LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE,
|
2015-04-07 11:31:57 +00:00
|
|
|
// Boundary for promotion to old space.
|
2009-12-22 13:34:02 +00:00
|
|
|
LAST_DATA_TYPE = FILLER_TYPE,
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
// Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy).
|
|
|
|
// Note that there is no range for JSObject or JSProxy, since their subtypes
|
|
|
|
// are not continuous in this enum! The enum ranges instead reflect the
|
|
|
|
// external class names, where proxies are treated as either ordinary objects,
|
|
|
|
// or functions.
|
2015-12-04 13:49:08 +00:00
|
|
|
FIRST_JS_RECEIVER_TYPE = JS_PROXY_TYPE,
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
LAST_JS_RECEIVER_TYPE = LAST_TYPE,
|
2011-09-21 14:46:54 +00:00
|
|
|
// Boundaries for testing the types represented as JSObject
|
2016-03-04 11:51:55 +00:00
|
|
|
FIRST_JS_OBJECT_TYPE = JS_GLOBAL_OBJECT_TYPE,
|
2011-09-21 14:46:54 +00:00
|
|
|
LAST_JS_OBJECT_TYPE = LAST_TYPE,
|
2016-03-04 11:51:55 +00:00
|
|
|
// Boundary for testing JSReceivers that need special property lookup handling
|
|
|
|
LAST_SPECIAL_RECEIVER_TYPE = JS_SPECIAL_API_OBJECT_TYPE,
|
2016-03-21 14:14:39 +00:00
|
|
|
// Boundary case for testing JSReceivers that may have elements while having
|
|
|
|
// an empty fixed array as elements backing store. This is true for string
|
|
|
|
// wrappers.
|
|
|
|
LAST_CUSTOM_ELEMENTS_RECEIVER = JS_VALUE_TYPE,
|
2016-10-18 02:42:42 +00:00
|
|
|
|
|
|
|
FIRST_ARRAY_KEY_ITERATOR_TYPE = JS_TYPED_ARRAY_KEY_ITERATOR_TYPE,
|
|
|
|
LAST_ARRAY_KEY_ITERATOR_TYPE = JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE,
|
|
|
|
|
|
|
|
FIRST_ARRAY_KEY_VALUE_ITERATOR_TYPE = JS_UINT8_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
LAST_ARRAY_KEY_VALUE_ITERATOR_TYPE = JS_GENERIC_ARRAY_KEY_VALUE_ITERATOR_TYPE,
|
|
|
|
|
|
|
|
FIRST_ARRAY_VALUE_ITERATOR_TYPE = JS_UINT8_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
LAST_ARRAY_VALUE_ITERATOR_TYPE = JS_GENERIC_ARRAY_VALUE_ITERATOR_TYPE,
|
|
|
|
|
|
|
|
FIRST_ARRAY_ITERATOR_TYPE = FIRST_ARRAY_KEY_ITERATOR_TYPE,
|
|
|
|
LAST_ARRAY_ITERATOR_TYPE = LAST_ARRAY_VALUE_ITERATOR_TYPE,
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2014-05-27 13:43:29 +00:00
|
|
|
STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType);
|
2016-04-12 10:31:38 +00:00
|
|
|
STATIC_ASSERT(JS_API_OBJECT_TYPE == Internals::kJSApiObjectType);
|
2014-05-27 13:43:29 +00:00
|
|
|
STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType);
|
|
|
|
STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType);
|
|
|
|
STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType);
|
2010-06-18 10:52:59 +00:00
|
|
|
|
2016-10-14 08:55:40 +00:00
|
|
|
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
|
|
|
|
InstanceType instance_type);
|
2015-12-03 10:02:46 +00:00
|
|
|
|
2016-07-28 17:16:33 +00:00
|
|
|
#define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V) \
|
2016-07-28 20:18:41 +00:00
|
|
|
V(BYTECODE_ARRAY_CONSTANT_POOL_SUB_TYPE) \
|
|
|
|
V(BYTECODE_ARRAY_HANDLER_TABLE_SUB_TYPE) \
|
2016-07-28 17:16:33 +00:00
|
|
|
V(CODE_STUBS_TABLE_SUB_TYPE) \
|
2016-08-16 19:26:18 +00:00
|
|
|
V(COMPILATION_CACHE_TABLE_SUB_TYPE) \
|
2016-07-28 17:16:33 +00:00
|
|
|
V(CONTEXT_SUB_TYPE) \
|
|
|
|
V(COPY_ON_WRITE_SUB_TYPE) \
|
|
|
|
V(DEOPTIMIZATION_DATA_SUB_TYPE) \
|
|
|
|
V(DESCRIPTOR_ARRAY_SUB_TYPE) \
|
|
|
|
V(EMBEDDED_OBJECT_SUB_TYPE) \
|
|
|
|
V(ENUM_CACHE_SUB_TYPE) \
|
|
|
|
V(ENUM_INDICES_CACHE_SUB_TYPE) \
|
|
|
|
V(DEPENDENT_CODE_SUB_TYPE) \
|
|
|
|
V(DICTIONARY_ELEMENTS_SUB_TYPE) \
|
|
|
|
V(DICTIONARY_PROPERTIES_SUB_TYPE) \
|
|
|
|
V(EMPTY_PROPERTIES_DICTIONARY_SUB_TYPE) \
|
2017-06-30 11:26:14 +00:00
|
|
|
V(PACKED_ELEMENTS_SUB_TYPE) \
|
2016-07-28 17:16:33 +00:00
|
|
|
V(FAST_PROPERTIES_SUB_TYPE) \
|
|
|
|
V(FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE) \
|
|
|
|
V(HANDLER_TABLE_SUB_TYPE) \
|
|
|
|
V(JS_COLLECTION_SUB_TYPE) \
|
|
|
|
V(JS_WEAK_COLLECTION_SUB_TYPE) \
|
|
|
|
V(MAP_CODE_CACHE_SUB_TYPE) \
|
|
|
|
V(NOSCRIPT_SHARED_FUNCTION_INFOS_SUB_TYPE) \
|
|
|
|
V(NUMBER_STRING_CACHE_SUB_TYPE) \
|
|
|
|
V(OBJECT_TO_CODE_SUB_TYPE) \
|
2016-08-16 19:26:18 +00:00
|
|
|
V(OPTIMIZED_CODE_LITERALS_SUB_TYPE) \
|
2016-07-28 17:16:33 +00:00
|
|
|
V(OPTIMIZED_CODE_MAP_SUB_TYPE) \
|
|
|
|
V(PROTOTYPE_USERS_SUB_TYPE) \
|
|
|
|
V(REGEXP_MULTIPLE_CACHE_SUB_TYPE) \
|
|
|
|
V(RETAINED_MAPS_SUB_TYPE) \
|
|
|
|
V(SCOPE_INFO_SUB_TYPE) \
|
|
|
|
V(SCRIPT_LIST_SUB_TYPE) \
|
|
|
|
V(SERIALIZED_TEMPLATES_SUB_TYPE) \
|
|
|
|
V(SHARED_FUNCTION_INFOS_SUB_TYPE) \
|
|
|
|
V(SINGLE_CHARACTER_STRING_CACHE_SUB_TYPE) \
|
|
|
|
V(SLOW_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE) \
|
|
|
|
V(STRING_SPLIT_CACHE_SUB_TYPE) \
|
|
|
|
V(STRING_TABLE_SUB_TYPE) \
|
2016-08-16 19:26:18 +00:00
|
|
|
V(TEMPLATE_INFO_SUB_TYPE) \
|
2017-02-07 14:05:02 +00:00
|
|
|
V(FEEDBACK_VECTOR_SUB_TYPE) \
|
|
|
|
V(FEEDBACK_METADATA_SUB_TYPE) \
|
2016-07-14 14:41:03 +00:00
|
|
|
V(WEAK_NEW_SPACE_OBJECT_TO_CODE_SUB_TYPE)
|
2012-07-20 14:06:24 +00:00
|
|
|
|
|
|
|
enum FixedArraySubInstanceType {
|
|
|
|
#define DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE(name) name,
|
|
|
|
FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE)
|
|
|
|
#undef DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE
|
2016-07-14 14:41:03 +00:00
|
|
|
LAST_FIXED_ARRAY_SUB_TYPE = WEAK_NEW_SPACE_OBJECT_TO_CODE_SUB_TYPE
|
2012-07-20 14:06:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-09-18 06:35:36 +00:00
|
|
|
// TODO(bmeurer): Remove this in favor of the ComparisonResult below.
|
2008-07-03 15:10:15 +00:00
|
|
|
enum CompareResult {
|
|
|
|
LESS = -1,
|
|
|
|
EQUAL = 0,
|
|
|
|
GREATER = 1,
|
|
|
|
|
|
|
|
NOT_EQUAL = GREATER
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-08-24 08:48:34 +00:00
|
|
|
class AbstractCode;
|
2012-05-24 10:40:24 +00:00
|
|
|
class AccessorPair;
|
2013-10-16 08:10:36 +00:00
|
|
|
class AllocationSite;
|
2015-06-25 12:19:55 +00:00
|
|
|
class Cell;
|
2014-11-26 11:53:27 +00:00
|
|
|
class ConsString;
|
2011-08-03 11:12:46 +00:00
|
|
|
class ElementsAccessor;
|
2017-02-14 15:19:03 +00:00
|
|
|
class FindAndReplacePattern;
|
2011-08-12 13:54:27 +00:00
|
|
|
class FixedArrayBase;
|
2015-02-12 13:21:06 +00:00
|
|
|
class FunctionLiteral;
|
2015-11-02 14:57:59 +00:00
|
|
|
class JSGlobalObject;
|
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-08-31 14:25:28 +00:00
|
|
|
class ModuleDescriptor;
|
2016-09-12 12:54:47 +00:00
|
|
|
class ModuleInfoEntry;
|
2016-08-31 14:25:28 +00:00
|
|
|
class ModuleInfo;
|
2015-06-25 12:19:55 +00:00
|
|
|
class ObjectHashTable;
|
2014-11-11 10:24:52 +00:00
|
|
|
class ObjectVisitor;
|
2015-06-25 12:19:55 +00:00
|
|
|
class PropertyCell;
|
2015-10-13 14:38:16 +00:00
|
|
|
class PropertyDescriptor;
|
2017-04-25 13:32:18 +00:00
|
|
|
class RootVisitor;
|
2015-06-25 12:19:55 +00:00
|
|
|
class SafepointEntry;
|
|
|
|
class SharedFunctionInfo;
|
2011-08-12 13:54:27 +00:00
|
|
|
class StringStream;
|
2015-06-25 12:19:55 +00:00
|
|
|
class TypeFeedbackInfo;
|
2017-02-07 14:05:02 +00:00
|
|
|
class FeedbackMetadata;
|
|
|
|
class FeedbackVector;
|
2014-10-15 10:11:08 +00:00
|
|
|
class WeakCell;
|
2015-12-03 13:18:19 +00:00
|
|
|
class TransitionArray;
|
2016-08-01 14:28:06 +00:00
|
|
|
class TemplateList;
|
2017-06-28 12:56:11 +00:00
|
|
|
template <typename T>
|
|
|
|
class ZoneForwardList;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// A template-ized version of the IsXXX functions.
|
2013-05-14 11:02:20 +00:00
|
|
|
template <class C> inline bool Is(Object* obj);
|
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) \
|
2014-09-10 12:38:12 +00:00
|
|
|
V(Number)
|
|
|
|
|
2017-04-18 12:46:39 +00:00
|
|
|
#define HEAP_OBJECT_TYPE_LIST(V) \
|
|
|
|
V(AbstractCode) \
|
|
|
|
V(AccessCheckNeeded) \
|
|
|
|
V(ArrayList) \
|
|
|
|
V(BoilerplateDescription) \
|
|
|
|
V(Boolean) \
|
|
|
|
V(BreakPointInfo) \
|
|
|
|
V(ByteArray) \
|
|
|
|
V(BytecodeArray) \
|
|
|
|
V(Callable) \
|
|
|
|
V(CallHandlerInfo) \
|
|
|
|
V(Cell) \
|
|
|
|
V(Code) \
|
|
|
|
V(CodeCacheHashTable) \
|
|
|
|
V(CompilationCacheTable) \
|
|
|
|
V(ConsString) \
|
|
|
|
V(ConstantElementsPair) \
|
|
|
|
V(Constructor) \
|
|
|
|
V(Context) \
|
2017-06-06 15:44:55 +00:00
|
|
|
V(CoverageInfo) \
|
2017-04-18 12:46:39 +00:00
|
|
|
V(DeoptimizationInputData) \
|
|
|
|
V(DependentCode) \
|
|
|
|
V(DescriptorArray) \
|
|
|
|
V(Dictionary) \
|
|
|
|
V(External) \
|
|
|
|
V(ExternalOneByteString) \
|
|
|
|
V(ExternalString) \
|
|
|
|
V(ExternalTwoByteString) \
|
|
|
|
V(FeedbackMetadata) \
|
|
|
|
V(FeedbackVector) \
|
|
|
|
V(Filler) \
|
|
|
|
V(FixedArray) \
|
|
|
|
V(FixedArrayBase) \
|
|
|
|
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(HandlerTable) \
|
|
|
|
V(HashTable) \
|
|
|
|
V(HeapNumber) \
|
|
|
|
V(InternalizedString) \
|
|
|
|
V(JSArgumentsObject) \
|
|
|
|
V(JSArray) \
|
|
|
|
V(JSArrayBuffer) \
|
|
|
|
V(JSArrayBufferView) \
|
|
|
|
V(JSArrayIterator) \
|
|
|
|
V(JSAsyncFromSyncIterator) \
|
|
|
|
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(JSPromiseCapability) \
|
|
|
|
V(JSProxy) \
|
|
|
|
V(JSReceiver) \
|
|
|
|
V(JSRegExp) \
|
|
|
|
V(JSSet) \
|
|
|
|
V(JSSetIterator) \
|
2017-04-18 14:57:53 +00:00
|
|
|
V(JSSloppyArgumentsObject) \
|
2017-04-18 12:46:39 +00:00
|
|
|
V(JSStringIterator) \
|
|
|
|
V(JSTypedArray) \
|
|
|
|
V(JSValue) \
|
|
|
|
V(JSWeakCollection) \
|
|
|
|
V(JSWeakMap) \
|
|
|
|
V(JSWeakSet) \
|
|
|
|
V(Map) \
|
|
|
|
V(MapCache) \
|
|
|
|
V(ModuleInfo) \
|
|
|
|
V(MutableHeapNumber) \
|
|
|
|
V(Name) \
|
|
|
|
V(NativeContext) \
|
|
|
|
V(NormalizedMapCache) \
|
|
|
|
V(ObjectHashSet) \
|
|
|
|
V(ObjectHashTable) \
|
|
|
|
V(Oddball) \
|
|
|
|
V(OrderedHashTable) \
|
|
|
|
V(PropertyCell) \
|
|
|
|
V(RegExpMatchInfo) \
|
|
|
|
V(ScopeInfo) \
|
|
|
|
V(ScriptContextTable) \
|
|
|
|
V(SeqOneByteString) \
|
|
|
|
V(SeqString) \
|
|
|
|
V(SeqTwoByteString) \
|
|
|
|
V(SharedFunctionInfo) \
|
|
|
|
V(SlicedString) \
|
|
|
|
V(SloppyArgumentsElements) \
|
2017-06-19 23:19:16 +00:00
|
|
|
V(SmallOrderedHashMap) \
|
2017-05-29 09:29:19 +00:00
|
|
|
V(SmallOrderedHashSet) \
|
2017-04-18 12:46:39 +00:00
|
|
|
V(SourcePositionTableWithFrameCache) \
|
|
|
|
V(String) \
|
|
|
|
V(StringSet) \
|
|
|
|
V(StringTable) \
|
|
|
|
V(StringWrapper) \
|
|
|
|
V(Struct) \
|
|
|
|
V(Symbol) \
|
|
|
|
V(TemplateInfo) \
|
|
|
|
V(TemplateList) \
|
|
|
|
V(ThinString) \
|
|
|
|
V(TransitionArray) \
|
|
|
|
V(TypeFeedbackInfo) \
|
|
|
|
V(Undetectable) \
|
|
|
|
V(UniqueName) \
|
|
|
|
V(UnseededNumberDictionary) \
|
|
|
|
V(WeakCell) \
|
|
|
|
V(WeakFixedArray) \
|
|
|
|
V(WeakHashTable)
|
2013-08-02 09:53:11 +00:00
|
|
|
|
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 };
|
|
|
|
|
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
|
|
|
|
2016-06-14 10:08:44 +00:00
|
|
|
#define IS_TYPE_FUNCTION_DECL(Type) 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
|
|
|
|
2016-06-14 10:08:44 +00:00
|
|
|
#define IS_TYPE_FUNCTION_DECL(Type, Value) \
|
|
|
|
INLINE(bool Is##Type(Isolate* isolate) 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
|
|
|
|
2017-01-09 13:40:51 +00:00
|
|
|
INLINE(bool IsNullOrUndefined(Isolate* isolate) const);
|
|
|
|
|
2014-07-18 13:47:25 +00:00
|
|
|
// A non-keyed store is of the form a.x = foo or a["x"] = foo whereas
|
|
|
|
// a keyed store is of the form a[expression] = foo.
|
|
|
|
enum StoreFromKeyed {
|
|
|
|
MAY_BE_STORE_FROM_KEYED,
|
|
|
|
CERTAINLY_NOT_STORE_FROM_KEYED
|
|
|
|
};
|
|
|
|
|
2015-10-23 09:39:37 +00:00
|
|
|
enum ShouldThrow { THROW_ON_ERROR, DONT_THROW };
|
|
|
|
|
|
|
|
#define RETURN_FAILURE(isolate, should_throw, call) \
|
|
|
|
do { \
|
|
|
|
if ((should_throw) == DONT_THROW) { \
|
|
|
|
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>())
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
#define DECL_STRUCT_PREDICATE(NAME, Name, name) INLINE(bool Is##Name() const);
|
|
|
|
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.
|
|
|
|
INLINE(MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object));
|
2015-12-03 12:51:15 +00:00
|
|
|
|
2014-06-24 09:47:25 +00:00
|
|
|
INLINE(bool IsNameDictionary() const);
|
2015-06-01 15:43:24 +00:00
|
|
|
INLINE(bool IsGlobalDictionary() const);
|
2014-06-24 09:47:25 +00:00
|
|
|
INLINE(bool IsSeededNumberDictionary() const);
|
|
|
|
INLINE(bool IsOrderedHashSet() const);
|
|
|
|
INLINE(bool IsOrderedHashMap() const);
|
2017-06-19 23:19:16 +00:00
|
|
|
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;
|
2014-06-24 09:47:25 +00:00
|
|
|
INLINE(bool IsNaN() const);
|
2014-07-30 13:54:45 +00:00
|
|
|
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();
|
|
|
|
|
2008-10-23 08:25:23 +00:00
|
|
|
inline bool HasSpecificClassOf(String* name);
|
|
|
|
|
2013-09-04 07:05:11 +00:00
|
|
|
bool BooleanValue(); // ECMA-262 9.2.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-09-18 06:35:36 +00:00
|
|
|
// ES6 section 7.2.11 Abstract Relational Comparison
|
2016-02-16 13:54:51 +00:00
|
|
|
MUST_USE_RESULT static Maybe<ComparisonResult> Compare(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
|
|
|
|
MUST_USE_RESULT static Maybe<bool> Equals(Handle<Object> x, Handle<Object> y);
|
|
|
|
|
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.
|
2016-01-15 12:59:40 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<JSReceiver> ToObject(
|
2017-04-24 20:53:37 +00:00
|
|
|
Isolate* isolate, Handle<Object> object,
|
|
|
|
const char* method_name = nullptr);
|
2015-08-27 12:50:31 +00:00
|
|
|
MUST_USE_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.
|
|
|
|
MUST_USE_RESULT static MaybeHandle<JSReceiver> ConvertReceiver(
|
|
|
|
Isolate* isolate, Handle<Object> object);
|
|
|
|
|
2015-08-28 09:21:23 +00:00
|
|
|
// ES6 section 7.1.14 ToPropertyKey
|
2016-02-29 13:18:59 +00:00
|
|
|
MUST_USE_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
|
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> ToPrimitive(
|
|
|
|
Handle<Object> input, ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
|
|
|
|
|
|
|
|
// ES6 section 7.1.3 ToNumber
|
2016-12-16 14:30:05 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> ToNumber(
|
|
|
|
Handle<Object> input);
|
2015-08-28 09:21:23 +00:00
|
|
|
|
2015-09-29 07:41:03 +00:00
|
|
|
// ES6 section 7.1.4 ToInteger
|
2016-12-16 14:30:05 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> ToInteger(
|
|
|
|
Isolate* isolate, Handle<Object> input);
|
2015-09-29 07:41:03 +00:00
|
|
|
|
|
|
|
// ES6 section 7.1.5 ToInt32
|
2016-12-16 14:30:05 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> ToInt32(
|
|
|
|
Isolate* isolate, Handle<Object> input);
|
2015-09-29 07:41:03 +00:00
|
|
|
|
|
|
|
// ES6 section 7.1.6 ToUint32
|
2016-12-16 14:30:05 +00:00
|
|
|
MUST_USE_RESULT inline static MaybeHandle<Object> ToUint32(
|
|
|
|
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
|
2016-12-16 14:30:05 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<String> ToString(
|
|
|
|
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
|
2016-12-20 12:21:00 +00:00
|
|
|
MUST_USE_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
|
2016-12-20 12:21:00 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> ToLength(
|
|
|
|
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
|
2016-12-20 12:21:00 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> ToIndex(
|
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
|
|
|
Isolate* isolate, Handle<Object> input,
|
|
|
|
MessageTemplate::Template error_index);
|
|
|
|
|
2015-08-28 09:21:23 +00:00
|
|
|
// ES6 section 7.3.9 GetMethod
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> GetMethod(
|
|
|
|
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
|
|
|
|
MUST_USE_RESULT static MaybeHandle<FixedArray> CreateListFromArrayLike(
|
|
|
|
Isolate* isolate, Handle<Object> object, ElementTypes element_types);
|
|
|
|
|
2016-05-20 13:19:02 +00:00
|
|
|
// Get length property and apply ToLength.
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> GetLengthFromArrayLike(
|
|
|
|
Isolate* isolate, Handle<Object> object);
|
|
|
|
|
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.6 Multiplicative Operators
|
2016-02-16 13:54:51 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> Multiply(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> Divide(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> Modulus(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
2015-09-10 13:04:15 +00:00
|
|
|
|
|
|
|
// ES6 section 12.7 Additive Operators
|
2016-02-16 13:54:51 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> Add(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> Subtract(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
2015-09-10 13:04:15 +00:00
|
|
|
|
|
|
|
// ES6 section 12.8 Bitwise Shift Operators
|
2016-02-16 13:54:51 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ShiftLeft(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ShiftRight(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
2015-09-10 13:04:15 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ShiftRightLogical(
|
2016-02-16 13:54:51 +00:00
|
|
|
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
|
2016-02-16 13:54:51 +00:00
|
|
|
MUST_USE_RESULT static inline Maybe<bool> GreaterThan(Handle<Object> x,
|
|
|
|
Handle<Object> y);
|
2015-09-18 06:35:36 +00:00
|
|
|
MUST_USE_RESULT static inline Maybe<bool> GreaterThanOrEqual(
|
2016-02-16 13:54:51 +00:00
|
|
|
Handle<Object> x, Handle<Object> y);
|
|
|
|
MUST_USE_RESULT static inline Maybe<bool> LessThan(Handle<Object> x,
|
|
|
|
Handle<Object> y);
|
|
|
|
MUST_USE_RESULT static inline Maybe<bool> LessThanOrEqual(Handle<Object> x,
|
|
|
|
Handle<Object> y);
|
2015-09-18 06:35:36 +00:00
|
|
|
|
2015-09-10 13:04:15 +00:00
|
|
|
// ES6 section 12.11 Binary Bitwise Operators
|
2016-02-16 13:54:51 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> BitwiseAnd(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> BitwiseOr(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> BitwiseXor(Isolate* isolate,
|
|
|
|
Handle<Object> lhs,
|
|
|
|
Handle<Object> rhs);
|
2015-09-10 13:04:15 +00:00
|
|
|
|
2016-05-17 11:23:59 +00:00
|
|
|
// ES6 section 7.3.19 OrdinaryHasInstance (C, O).
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> OrdinaryHasInstance(
|
|
|
|
Isolate* isolate, Handle<Object> callable, Handle<Object> object);
|
|
|
|
|
|
|
|
// ES6 section 12.10.4 Runtime Semantics: InstanceofOperator(O, C)
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> InstanceOf(
|
|
|
|
Isolate* isolate, Handle<Object> object, Handle<Object> callable);
|
|
|
|
|
2016-09-26 07:40:24 +00:00
|
|
|
V8_EXPORT_PRIVATE MUST_USE_RESULT static MaybeHandle<Object> GetProperty(
|
|
|
|
LookupIterator* it);
|
2014-07-22 08:28:49 +00:00
|
|
|
|
2015-10-23 09:39:37 +00:00
|
|
|
// ES6 [[Set]] (when passed DONT_THROW)
|
|
|
|
// Invariants for this and related functions (unless stated otherwise):
|
|
|
|
// 1) When the result is Nothing, an exception is pending.
|
|
|
|
// 2) When passed THROW_ON_ERROR, the result is never Just(false).
|
|
|
|
// 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).
|
|
|
|
MUST_USE_RESULT static Maybe<bool> SetProperty(LookupIterator* it,
|
|
|
|
Handle<Object> value,
|
|
|
|
LanguageMode language_mode,
|
|
|
|
StoreFromKeyed store_mode);
|
2014-07-22 08:28:49 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
|
2015-06-02 11:10:50 +00:00
|
|
|
Handle<Object> object, Handle<Name> name, Handle<Object> value,
|
2015-02-04 09:34:05 +00:00
|
|
|
LanguageMode language_mode,
|
2014-07-22 08:28:49 +00:00
|
|
|
StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
|
2016-04-21 09:48:58 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> SetPropertyOrElement(
|
|
|
|
Handle<Object> object, Handle<Name> name, Handle<Object> value,
|
|
|
|
LanguageMode language_mode,
|
|
|
|
StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
|
2015-02-19 16:15:25 +00:00
|
|
|
|
2015-10-30 10:45:30 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> SetSuperProperty(
|
2015-02-19 16:15:25 +00:00
|
|
|
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
|
|
|
|
StoreFromKeyed store_mode);
|
|
|
|
|
2015-10-23 09:39:37 +00:00
|
|
|
MUST_USE_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);
|
2015-10-23 09:39:37 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> WriteToReadOnlyProperty(
|
2015-10-30 10:45:30 +00:00
|
|
|
LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
|
2015-10-23 09:39:37 +00:00
|
|
|
MUST_USE_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);
|
2015-11-03 08:04:00 +00:00
|
|
|
MUST_USE_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);
|
2015-10-23 09:39:37 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> SetDataProperty(LookupIterator* it,
|
2015-11-03 14:52:59 +00:00
|
|
|
Handle<Object> value);
|
2015-10-23 09:39:37 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> AddDataProperty(
|
|
|
|
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
|
2015-10-30 10:45:30 +00:00
|
|
|
ShouldThrow should_throw, StoreFromKeyed store_mode);
|
2014-04-11 12:47:34 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
|
2016-02-17 10:30:10 +00:00
|
|
|
Handle<Object> object, Handle<Name> name);
|
2015-10-08 14:23:03 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
|
2016-02-17 10:30:10 +00:00
|
|
|
Handle<Object> receiver, Handle<Name> name, Handle<JSReceiver> holder);
|
2014-04-11 12:47:34 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty(
|
2016-02-17 10:30:10 +00:00
|
|
|
Handle<Object> object, Handle<Name> name);
|
2011-10-18 12:19:18 +00:00
|
|
|
|
2014-06-11 09:59:14 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithAccessor(
|
2016-02-17 10:30:10 +00:00
|
|
|
LookupIterator* it);
|
2015-10-23 09:39:37 +00:00
|
|
|
MUST_USE_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
|
|
|
|
2014-04-10 09:20:11 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithDefinedGetter(
|
|
|
|
Handle<Object> receiver,
|
|
|
|
Handle<JSReceiver> getter);
|
2015-10-23 09:39:37 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> SetPropertyWithDefinedSetter(
|
|
|
|
Handle<Object> receiver, Handle<JSReceiver> setter, Handle<Object> value,
|
|
|
|
ShouldThrow should_throw);
|
2010-10-25 15:22:03 +00:00
|
|
|
|
2014-04-10 09:20:11 +00:00
|
|
|
MUST_USE_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
|
|
|
|
2015-07-10 16:11:00 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> SetElement(
|
|
|
|
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.
|
|
|
|
Object* GetHash();
|
|
|
|
|
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.
|
2016-06-07 13:51:11 +00:00
|
|
|
static Smi* GetOrCreateHash(Isolate* isolate, Handle<Object> object);
|
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
|
|
|
|
// to implement the Harmony "egal" 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)
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ArraySpeciesConstructor(
|
|
|
|
Isolate* isolate, Handle<Object> original_array);
|
|
|
|
|
2017-02-28 20:31:02 +00:00
|
|
|
// ES6 section 7.3.20 SpeciesConstructor ( O, defaultConstructor )
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> SpeciesConstructor(
|
|
|
|
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.
|
2017-07-03 13:29:23 +00:00
|
|
|
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.
|
|
|
|
static void VerifyPointer(Object* p);
|
|
|
|
#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.
|
|
|
|
void Print();
|
|
|
|
|
2014-04-30 12:25:18 +00:00
|
|
|
// Prints this object with details.
|
2014-09-30 10:29:32 +00:00
|
|
|
void Print(std::ostream& os); // NOLINT
|
2014-12-08 09:26:04 +00:00
|
|
|
#else
|
|
|
|
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.
|
2017-07-03 13:29:23 +00:00
|
|
|
Map* GetPrototypeChainRootMap(Isolate* isolate) const;
|
2014-07-14 07:19:49 +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.
|
|
|
|
MUST_USE_RESULT static Maybe<bool> SetPropertyInternal(
|
2015-02-19 16:15:25 +00:00
|
|
|
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
|
2015-10-30 10:45:30 +00:00
|
|
|
StoreFromKeyed store_mode, bool* found);
|
2015-02-19 16:15:25 +00:00
|
|
|
|
2016-02-29 13:18:59 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Name> ConvertToName(Isolate* isolate,
|
|
|
|
Handle<Object> input);
|
2016-12-20 12:21:00 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ConvertToPropertyKey(
|
|
|
|
Isolate* isolate, Handle<Object> value);
|
2016-12-16 14:30:05 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<String> ConvertToString(
|
|
|
|
Isolate* isolate, Handle<Object> input);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ConvertToNumber(
|
|
|
|
Isolate* isolate, Handle<Object> input);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ConvertToInteger(
|
|
|
|
Isolate* isolate, Handle<Object> input);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ConvertToInt32(
|
|
|
|
Isolate* isolate, Handle<Object> input);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ConvertToUint32(
|
|
|
|
Isolate* isolate, Handle<Object> input);
|
2016-12-20 12:21:00 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ConvertToLength(
|
|
|
|
Isolate* isolate, Handle<Object> input);
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ConvertToIndex(
|
|
|
|
Isolate* isolate, Handle<Object> input,
|
|
|
|
MessageTemplate::Template error_index);
|
|
|
|
|
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.
|
|
|
|
bool Object::IsSmi() const { return HAS_SMI_TAG(this); }
|
2017-02-27 09:07:25 +00:00
|
|
|
bool Object::IsHeapObject() const {
|
|
|
|
DCHECK_EQ(!IsSmi(), Internals::HasHeapObjectTag(this));
|
|
|
|
return !IsSmi();
|
|
|
|
}
|
2015-08-14 08:48:11 +00:00
|
|
|
|
2014-07-07 09:57:29 +00:00
|
|
|
struct Brief {
|
|
|
|
explicit Brief(const Object* const v) : value(v) {}
|
|
|
|
const Object* value;
|
|
|
|
};
|
|
|
|
|
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-03 15:10:15 +00:00
|
|
|
// Smi represents integer Numbers that can be stored in 31 bits.
|
|
|
|
// Smis are immediate which means they are NOT allocated in the heap.
|
2009-09-15 11:35:23 +00:00
|
|
|
// The this pointer has the following format: [31 bit signed int] 0
|
2009-10-08 12:36:12 +00:00
|
|
|
// For long smis it has the following format:
|
|
|
|
// [32 bit signed int] [31 bits zero padding] 0
|
|
|
|
// Smi stands for small integer.
|
2013-08-20 10:52:23 +00:00
|
|
|
class Smi: public Object {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
// Returns the integer value.
|
2015-08-13 11:49:01 +00:00
|
|
|
inline int value() const { return Internals::SmiValue(this); }
|
2016-12-16 14:30:05 +00:00
|
|
|
inline Smi* ToUint32Smi() {
|
|
|
|
if (value() <= 0) return Smi::kZero;
|
|
|
|
return Smi::FromInt(static_cast<uint32_t>(value()));
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Convert a value to a Smi object.
|
2015-08-13 11:49:01 +00:00
|
|
|
static inline Smi* FromInt(int value) {
|
|
|
|
DCHECK(Smi::IsValid(value));
|
|
|
|
return reinterpret_cast<Smi*>(Internals::IntToSmi(value));
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
static inline Smi* FromIntptr(intptr_t value) {
|
|
|
|
DCHECK(Smi::IsValid(value));
|
|
|
|
int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
|
|
|
|
return reinterpret_cast<Smi*>((value << smi_shift_bits) | kSmiTag);
|
|
|
|
}
|
2009-05-06 07:53:08 +00:00
|
|
|
|
2017-06-15 14:53:38 +00:00
|
|
|
template <typename E,
|
|
|
|
typename = typename std::enable_if<std::is_enum<E>::value>::type>
|
|
|
|
static inline Smi* FromEnum(E value) {
|
|
|
|
STATIC_ASSERT(sizeof(E) <= sizeof(int));
|
|
|
|
return FromInt(static_cast<int>(value));
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Returns whether value can be represented in a Smi.
|
2015-08-13 11:49:01 +00:00
|
|
|
static inline bool IsValid(intptr_t value) {
|
|
|
|
bool result = Internals::IsValidSmi(value);
|
|
|
|
DCHECK_EQ(result, value >= kMinValue && value <= kMaxValue);
|
|
|
|
return result;
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(Smi)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2016-10-14 08:55:40 +00:00
|
|
|
V8_EXPORT_PRIVATE void SmiPrint(std::ostream& os) const; // NOLINT
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(Smi)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-12-02 10:05:41 +00:00
|
|
|
static constexpr Smi* const kZero = nullptr;
|
2012-02-20 13:22:02 +00:00
|
|
|
static const int kMinValue =
|
2012-02-20 12:36:35 +00:00
|
|
|
(static_cast<unsigned int>(-1)) << (kSmiValueSize - 1);
|
2009-10-08 12:36:12 +00:00
|
|
|
static const int kMaxValue = -(kMinValue + 1);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Smi);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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.
|
2013-08-20 10:52:23 +00:00
|
|
|
class MapWord BASE_EMBEDDED {
|
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.
|
2014-06-20 10:31:17 +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.
|
2017-07-03 13:29:23 +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;
|
|
|
|
|
|
|
|
explicit MapWord(uintptr_t value) : value_(value) {}
|
|
|
|
|
|
|
|
uintptr_t 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.
|
2014-06-20 10:31:17 +00:00
|
|
|
inline Map* map() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void set_map(Map* value);
|
2017-05-05 17:41:44 +00:00
|
|
|
|
|
|
|
inline HeapObject** map_slot();
|
|
|
|
|
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.
|
|
|
|
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.
|
2017-07-03 13:29:23 +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
|
|
|
|
inline void synchronized_set_map(Map* value);
|
|
|
|
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(
|
|
|
|
Map* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
|
|
|
|
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);
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
// The Heap the object was allocated in. Used also to access Isolate.
|
2014-06-20 10:31:17 +00:00
|
|
|
inline Heap* GetHeap() const;
|
2011-09-19 18:36:47 +00:00
|
|
|
|
2013-09-05 11:27:22 +00:00
|
|
|
// Convenience method to get current isolate.
|
2014-06-24 09:47:25 +00:00
|
|
|
inline Isolate* GetIsolate() const;
|
2011-03-18 20:35:07 +00:00
|
|
|
|
2016-06-14 10:08:44 +00:00
|
|
|
#define IS_TYPE_FUNCTION_DECL(Type) 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
|
|
|
|
|
|
|
|
#define IS_TYPE_FUNCTION_DECL(Type, Value) \
|
|
|
|
INLINE(bool Is##Type(Isolate* isolate) 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
|
|
|
|
2017-01-09 13:40:51 +00:00
|
|
|
INLINE(bool IsNullOrUndefined(Isolate* isolate) const);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
#define DECL_STRUCT_PREDICATE(NAME, Name, name) INLINE(bool Is##Name() const);
|
|
|
|
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 {
|
|
|
|
return reinterpret_cast<Address>(const_cast<HeapObject*>(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);
|
2008-07-03 15:10:15 +00:00
|
|
|
void IterateBody(InstanceType type, int object_size, ObjectVisitor* v);
|
|
|
|
|
2015-11-13 12:32:08 +00:00
|
|
|
template <typename ObjectVisitor>
|
|
|
|
inline void IterateBodyFast(ObjectVisitor* v);
|
|
|
|
|
|
|
|
template <typename ObjectVisitor>
|
|
|
|
inline void IterateBodyFast(InstanceType type, int object_size,
|
|
|
|
ObjectVisitor* v);
|
|
|
|
|
|
|
|
// 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 (!!!).
|
|
|
|
bool IsValidSlot(int offset);
|
|
|
|
|
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.
|
2017-07-03 13:29:23 +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.
|
|
|
|
static inline Object** RawField(HeapObject* obj, int offset);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-09-12 22:04:04 +00:00
|
|
|
// Adds the |code| object related to |name| to the code cache of this map. If
|
|
|
|
// this map is a dictionary map that is shared, the map copied and installed
|
|
|
|
// onto the object.
|
|
|
|
static void UpdateMapCodeCache(Handle<HeapObject> object,
|
|
|
|
Handle<Name> name,
|
|
|
|
Handle<Code> code);
|
|
|
|
|
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
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(HeapObject)
|
|
|
|
DECL_VERIFIER(HeapObject)
|
2012-10-12 11:41:14 +00:00
|
|
|
#ifdef VERIFY_HEAP
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void VerifyObjectField(int offset);
|
2010-05-27 12:30:45 +00:00
|
|
|
inline void VerifySmiField(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.
|
|
|
|
static void VerifyHeapPointer(Object* p);
|
|
|
|
#endif
|
|
|
|
|
2017-07-03 13:29:23 +00:00
|
|
|
inline AllocationAlignment RequiredAlignment() const;
|
2014-11-27 09:22:10 +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
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// The HeapNumber class describes heap allocated numbers that cannot be
|
|
|
|
// represented in a Smi (small integer)
|
2013-08-20 10:52:23 +00:00
|
|
|
class HeapNumber: 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);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(HeapNumber)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2013-03-07 16:22:19 +00:00
|
|
|
bool HeapNumberBooleanValue();
|
|
|
|
|
2016-10-14 08:55:40 +00:00
|
|
|
V8_EXPORT_PRIVATE void HeapNumberPrint(std::ostream& os); // NOLINT
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(HeapNumber)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
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:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber);
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2016-05-30 15:52:56 +00:00
|
|
|
enum class GetKeysConversion { kKeepNumbers, 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
|
|
|
|
2016-08-25 11:39:27 +00:00
|
|
|
enum class AllocationSiteUpdateMode { kUpdate, kCheckOnly };
|
|
|
|
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
// JSReceiver includes types on which properties can be defined, i.e.,
|
|
|
|
// JSObject and JSProxy.
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSReceiver: public HeapObject {
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
public:
|
2016-01-12 15:43:41 +00:00
|
|
|
// [properties]: Backing storage for properties.
|
|
|
|
// properties is a FixedArray in the fast case and a Dictionary in the
|
|
|
|
// slow case.
|
|
|
|
DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties.
|
|
|
|
inline void initialize_properties();
|
|
|
|
inline bool HasFastProperties();
|
|
|
|
// Gets slow properties for non-global objects.
|
|
|
|
inline NameDictionary* property_dictionary();
|
|
|
|
|
2016-01-18 12:41:09 +00:00
|
|
|
// Deletes an existing named property in a normalized object.
|
2017-06-22 08:07:08 +00:00
|
|
|
static void DeleteNormalizedProperty(Handle<JSReceiver> object, int entry);
|
2016-01-18 12:41:09 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSReceiver)
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
|
2015-08-28 09:21:23 +00:00
|
|
|
// ES6 section 7.1.1 ToPrimitive
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive(
|
|
|
|
Handle<JSReceiver> receiver,
|
|
|
|
ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
|
2016-07-14 10:25:45 +00:00
|
|
|
|
|
|
|
// ES6 section 7.1.1.1 OrdinaryToPrimitive
|
2015-08-28 09:21:23 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> OrdinaryToPrimitive(
|
2015-08-31 12:52:59 +00:00
|
|
|
Handle<JSReceiver> receiver, OrdinaryToPrimitiveHint hint);
|
2015-08-28 09:21:23 +00:00
|
|
|
|
2015-11-27 12:16:32 +00:00
|
|
|
static MaybeHandle<Context> GetFunctionRealm(Handle<JSReceiver> receiver);
|
|
|
|
|
2016-02-08 13:49:47 +00:00
|
|
|
// Get the first non-hidden prototype.
|
|
|
|
static inline MaybeHandle<Object> GetPrototype(Isolate* isolate,
|
|
|
|
Handle<JSReceiver> receiver);
|
|
|
|
|
|
|
|
MUST_USE_RESULT static Maybe<bool> HasInPrototypeChain(
|
|
|
|
Isolate* isolate, Handle<JSReceiver> object, Handle<Object> proto);
|
|
|
|
|
2017-01-18 01:05:17 +00:00
|
|
|
// Reads all enumerable own properties of source and adds them to
|
|
|
|
// target, using either Set or CreateDataProperty depending on the
|
|
|
|
// use_set argument. This only copies values not present in the
|
|
|
|
// maybe_excluded_properties list.
|
2017-01-05 23:44:25 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> SetOrCopyDataProperties(
|
|
|
|
Isolate* isolate, Handle<JSReceiver> target, Handle<Object> source,
|
2017-01-21 01:09:47 +00:00
|
|
|
const ScopedVector<Handle<Object>>* excluded_properties = nullptr,
|
2017-01-18 01:05:17 +00:00
|
|
|
bool use_set = true);
|
2017-01-05 23:44:25 +00:00
|
|
|
|
2013-09-17 11:34:20 +00:00
|
|
|
// Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6.
|
2015-11-04 10:17:06 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> HasProperty(LookupIterator* it);
|
2014-07-25 18:32:11 +00:00
|
|
|
MUST_USE_RESULT static inline Maybe<bool> HasProperty(
|
|
|
|
Handle<JSReceiver> object, Handle<Name> name);
|
|
|
|
MUST_USE_RESULT static inline Maybe<bool> HasElement(
|
|
|
|
Handle<JSReceiver> object, uint32_t index);
|
2015-12-17 12:12:02 +00:00
|
|
|
|
|
|
|
MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty(
|
|
|
|
Handle<JSReceiver> object, Handle<Name> name);
|
2016-06-22 10:18:42 +00:00
|
|
|
MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty(
|
|
|
|
Handle<JSReceiver> object, uint32_t index);
|
2013-09-17 11:34:20 +00:00
|
|
|
|
2016-03-08 17:29:05 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty(
|
|
|
|
Isolate* isolate, Handle<JSReceiver> receiver, const char* key);
|
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty(
|
|
|
|
Handle<JSReceiver> receiver, Handle<Name> name);
|
|
|
|
MUST_USE_RESULT static inline MaybeHandle<Object> GetElement(
|
|
|
|
Isolate* isolate, Handle<JSReceiver> receiver, uint32_t index);
|
|
|
|
|
2015-11-26 09:34:11 +00:00
|
|
|
// Implementation of ES6 [[Delete]]
|
|
|
|
MUST_USE_RESULT static Maybe<bool> DeletePropertyOrElement(
|
2015-07-02 13:29:48 +00:00
|
|
|
Handle<JSReceiver> object, Handle<Name> name,
|
|
|
|
LanguageMode language_mode = SLOPPY);
|
2015-11-26 09:34:11 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> DeleteProperty(
|
2015-01-20 13:41:17 +00:00
|
|
|
Handle<JSReceiver> object, Handle<Name> name,
|
2015-02-04 09:34:05 +00:00
|
|
|
LanguageMode language_mode = SLOPPY);
|
2015-11-26 09:34:11 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> DeleteProperty(LookupIterator* it,
|
|
|
|
LanguageMode language_mode);
|
|
|
|
MUST_USE_RESULT static Maybe<bool> DeleteElement(
|
2015-01-20 13:41:17 +00:00
|
|
|
Handle<JSReceiver> object, uint32_t index,
|
2015-02-04 09:34:05 +00:00
|
|
|
LanguageMode language_mode = SLOPPY);
|
2011-09-22 10:45:37 +00:00
|
|
|
|
2015-10-13 14:38:16 +00:00
|
|
|
MUST_USE_RESULT static Object* DefineProperty(Isolate* isolate,
|
|
|
|
Handle<Object> object,
|
|
|
|
Handle<Object> name,
|
|
|
|
Handle<Object> attributes);
|
2015-12-30 14:16:04 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> DefineProperties(
|
|
|
|
Isolate* isolate, Handle<Object> object, Handle<Object> properties);
|
2015-10-13 14:38:16 +00:00
|
|
|
|
|
|
|
// "virtual" dispatcher to the correct [[DefineOwnProperty]] implementation.
|
2015-12-09 18:06:49 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> DefineOwnProperty(
|
|
|
|
Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key,
|
|
|
|
PropertyDescriptor* desc, ShouldThrow should_throw);
|
2015-10-13 14:38:16 +00:00
|
|
|
|
2015-12-01 12:27:01 +00:00
|
|
|
// ES6 7.3.4 (when passed DONT_THROW)
|
|
|
|
MUST_USE_RESULT static Maybe<bool> CreateDataProperty(
|
|
|
|
LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
|
2015-11-16 16:48:43 +00:00
|
|
|
|
2015-11-13 17:18:04 +00:00
|
|
|
// ES6 9.1.6.1
|
2015-12-09 18:06:49 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> OrdinaryDefineOwnProperty(
|
|
|
|
Isolate* isolate, Handle<JSObject> object, Handle<Object> key,
|
|
|
|
PropertyDescriptor* desc, ShouldThrow should_throw);
|
|
|
|
MUST_USE_RESULT static Maybe<bool> OrdinaryDefineOwnProperty(
|
|
|
|
LookupIterator* it, PropertyDescriptor* desc, ShouldThrow should_throw);
|
2015-11-13 17:18:04 +00:00
|
|
|
// ES6 9.1.6.2
|
2015-12-09 18:06:49 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> IsCompatiblePropertyDescriptor(
|
|
|
|
Isolate* isolate, bool extensible, PropertyDescriptor* desc,
|
2015-12-14 13:44:38 +00:00
|
|
|
PropertyDescriptor* current, Handle<Name> property_name,
|
|
|
|
ShouldThrow should_throw);
|
2015-11-13 17:18:04 +00:00
|
|
|
// ES6 9.1.6.3
|
|
|
|
// |it| can be NULL in cases where the ES spec passes |undefined| as the
|
|
|
|
// receiver. Exactly one of |it| and |property_name| must be provided.
|
2015-12-09 18:06:49 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> ValidateAndApplyPropertyDescriptor(
|
2015-11-17 13:08:24 +00:00
|
|
|
Isolate* isolate, LookupIterator* it, bool extensible,
|
|
|
|
PropertyDescriptor* desc, PropertyDescriptor* current,
|
2017-06-12 11:08:30 +00:00
|
|
|
ShouldThrow should_throw, Handle<Name> property_name);
|
2015-10-13 14:38:16 +00:00
|
|
|
|
2016-09-26 07:40:24 +00:00
|
|
|
V8_EXPORT_PRIVATE MUST_USE_RESULT static Maybe<bool> GetOwnPropertyDescriptor(
|
2015-12-09 18:06:49 +00:00
|
|
|
Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key,
|
|
|
|
PropertyDescriptor* desc);
|
|
|
|
MUST_USE_RESULT static Maybe<bool> GetOwnPropertyDescriptor(
|
|
|
|
LookupIterator* it, PropertyDescriptor* desc);
|
2015-10-13 14:38:16 +00:00
|
|
|
|
2015-12-07 11:01:16 +00:00
|
|
|
typedef PropertyAttributes IntegrityLevel;
|
|
|
|
|
|
|
|
// ES6 7.3.14 (when passed DONT_THROW)
|
|
|
|
// 'level' must be SEALED or FROZEN.
|
|
|
|
MUST_USE_RESULT static Maybe<bool> SetIntegrityLevel(
|
|
|
|
Handle<JSReceiver> object, IntegrityLevel lvl, ShouldThrow should_throw);
|
|
|
|
|
2015-12-07 15:35:49 +00:00
|
|
|
// ES6 7.3.15
|
|
|
|
// 'level' must be SEALED or FROZEN.
|
|
|
|
MUST_USE_RESULT static Maybe<bool> TestIntegrityLevel(
|
|
|
|
Handle<JSReceiver> object, IntegrityLevel lvl);
|
|
|
|
|
2015-12-07 11:01:16 +00:00
|
|
|
// ES6 [[PreventExtensions]] (when passed DONT_THROW)
|
2015-10-21 09:23:33 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> PreventExtensions(
|
|
|
|
Handle<JSReceiver> object, ShouldThrow should_throw);
|
|
|
|
|
2015-11-13 14:13:50 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> IsExtensible(Handle<JSReceiver> object);
|
|
|
|
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
// Returns the class name ([[Class]] property in the specification).
|
2017-03-15 15:32:00 +00:00
|
|
|
V8_EXPORT_PRIVATE String* class_name();
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
|
|
|
|
// Returns the constructor name (the name (possibly, inferred name) of the
|
|
|
|
// function that was used to instantiate the object).
|
2015-11-27 13:10:00 +00:00
|
|
|
static Handle<String> GetConstructorName(Handle<JSReceiver> receiver);
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
|
2017-02-20 09:47:14 +00:00
|
|
|
Handle<Context> GetCreationContext();
|
2015-11-16 16:48:43 +00:00
|
|
|
|
2014-07-25 18:32:11 +00:00
|
|
|
MUST_USE_RESULT static inline Maybe<PropertyAttributes> GetPropertyAttributes(
|
|
|
|
Handle<JSReceiver> object, Handle<Name> name);
|
2015-06-02 11:10:50 +00:00
|
|
|
MUST_USE_RESULT static inline Maybe<PropertyAttributes>
|
|
|
|
GetOwnPropertyAttributes(Handle<JSReceiver> object, Handle<Name> name);
|
2016-06-22 10:18:42 +00:00
|
|
|
MUST_USE_RESULT static inline Maybe<PropertyAttributes>
|
|
|
|
GetOwnPropertyAttributes(Handle<JSReceiver> object, uint32_t index);
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
|
2015-06-02 11:10:50 +00:00
|
|
|
MUST_USE_RESULT static inline Maybe<PropertyAttributes> GetElementAttributes(
|
2014-07-25 18:32:11 +00:00
|
|
|
Handle<JSReceiver> object, uint32_t index);
|
|
|
|
MUST_USE_RESULT static inline Maybe<PropertyAttributes>
|
2015-06-02 11:10:50 +00:00
|
|
|
GetOwnElementAttributes(Handle<JSReceiver> object, uint32_t index);
|
|
|
|
|
|
|
|
MUST_USE_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes(
|
|
|
|
LookupIterator* it);
|
|
|
|
|
2015-10-22 11:21:22 +00:00
|
|
|
// Set the object's prototype (only JSReceiver and null are allowed values).
|
|
|
|
MUST_USE_RESULT static Maybe<bool> SetPrototype(Handle<JSReceiver> object,
|
|
|
|
Handle<Object> value,
|
|
|
|
bool from_javascript,
|
|
|
|
ShouldThrow should_throw);
|
|
|
|
|
2016-03-04 15:14:42 +00:00
|
|
|
inline static Handle<Object> GetDataProperty(Handle<JSReceiver> object,
|
|
|
|
Handle<Name> name);
|
2015-05-12 13:52:26 +00:00
|
|
|
static Handle<Object> GetDataProperty(LookupIterator* it);
|
|
|
|
|
|
|
|
|
2011-09-22 13:54:53 +00:00
|
|
|
// Retrieves a permanent object identity hash code. The undefined value might
|
2013-11-05 11:47:11 +00:00
|
|
|
// be returned in case no hash was created yet.
|
2016-06-07 13:51:11 +00:00
|
|
|
static inline Object* GetIdentityHash(Isolate* isolate,
|
|
|
|
Handle<JSReceiver> object);
|
2013-11-05 11:47:11 +00:00
|
|
|
|
|
|
|
// Retrieves a permanent object identity hash code. May create and store a
|
|
|
|
// hash code if needed and none exists.
|
2016-06-07 13:51:11 +00:00
|
|
|
inline static Smi* GetOrCreateIdentityHash(Isolate* isolate,
|
|
|
|
Handle<JSReceiver> object);
|
2011-09-22 13:54:53 +00:00
|
|
|
|
2015-12-07 11:01:16 +00:00
|
|
|
// ES6 [[OwnPropertyKeys]] (modulo return type)
|
2016-05-25 09:13:31 +00:00
|
|
|
MUST_USE_RESULT static inline MaybeHandle<FixedArray> OwnPropertyKeys(
|
|
|
|
Handle<JSReceiver> object);
|
2014-04-16 13:28:11 +00:00
|
|
|
|
2016-02-08 14:10:48 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<FixedArray> GetOwnValues(
|
|
|
|
Handle<JSReceiver> object, PropertyFilter filter);
|
|
|
|
|
|
|
|
MUST_USE_RESULT static MaybeHandle<FixedArray> GetOwnEntries(
|
|
|
|
Handle<JSReceiver> object, PropertyFilter filter);
|
|
|
|
|
2016-01-12 15:43:41 +00:00
|
|
|
// Layout description.
|
|
|
|
static const int kPropertiesOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kHeaderSize = HeapObject::kHeaderSize + kPointerSize;
|
|
|
|
|
2016-07-22 18:42:14 +00:00
|
|
|
bool HasProxyInPrototype(Isolate* isolate);
|
|
|
|
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver);
|
|
|
|
};
|
|
|
|
|
2014-04-15 13:42:41 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// The JSObject describes real heap allocated JavaScript objects with
|
|
|
|
// properties.
|
|
|
|
// Note that the map of JSObject changes during execution to enable inline
|
|
|
|
// caching.
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSObject: public JSReceiver {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2017-05-22 12:47:20 +00:00
|
|
|
static bool IsUnmodifiedApiObject(Object** o);
|
|
|
|
|
2016-01-05 11:05:41 +00:00
|
|
|
static MUST_USE_RESULT MaybeHandle<JSObject> New(
|
|
|
|
Handle<JSFunction> constructor, Handle<JSReceiver> new_target,
|
|
|
|
Handle<AllocationSite> site = Handle<AllocationSite>::null());
|
|
|
|
|
2015-06-01 15:43:24 +00:00
|
|
|
// Gets global object properties.
|
|
|
|
inline GlobalDictionary* global_dictionary();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-11-27 12:16:32 +00:00
|
|
|
static MaybeHandle<Context> GetFunctionRealm(Handle<JSObject> object);
|
|
|
|
|
2008-08-27 10:11:39 +00:00
|
|
|
// [elements]: The elements (properties with names that are integers).
|
2010-08-16 16:06:46 +00:00
|
|
|
//
|
|
|
|
// Elements can be in two general modes: fast and slow. Each mode
|
2016-09-08 12:51:37 +00:00
|
|
|
// corresponds to a set of object representations of elements that
|
2010-08-16 16:06:46 +00:00
|
|
|
// have something in common.
|
|
|
|
//
|
|
|
|
// In the fast mode elements is a FixedArray and so each element can
|
|
|
|
// be quickly accessed. This fact is used in the generated code. The
|
2011-06-16 14:12:58 +00:00
|
|
|
// elements array can have one of three maps in this mode:
|
2014-03-11 14:39:08 +00:00
|
|
|
// fixed_array_map, sloppy_arguments_elements_map or
|
2011-06-16 14:12:58 +00:00
|
|
|
// fixed_cow_array_map (for copy-on-write arrays). In the latter case
|
|
|
|
// the elements array may be shared by a few objects and so before
|
|
|
|
// writing to any element the array must be copied. Use
|
|
|
|
// EnsureWritableFastElements in this case.
|
2010-08-16 16:06:46 +00:00
|
|
|
//
|
2015-07-28 09:29:34 +00:00
|
|
|
// In the slow mode the elements is either a NumberDictionary, a
|
|
|
|
// FixedArray parameter map for a (sloppy) arguments object.
|
2011-08-12 13:54:27 +00:00
|
|
|
DECL_ACCESSORS(elements, FixedArrayBase)
|
2008-08-27 10:11:39 +00:00
|
|
|
inline void initialize_elements();
|
2014-03-31 15:30:13 +00:00
|
|
|
static inline void SetMapAndElements(Handle<JSObject> object,
|
|
|
|
Handle<Map> map,
|
|
|
|
Handle<FixedArrayBase> elements);
|
2009-07-28 08:43:51 +00:00
|
|
|
inline ElementsKind GetElementsKind();
|
2015-06-23 11:35:43 +00:00
|
|
|
ElementsAccessor* GetElementsAccessor();
|
2017-06-30 11:26:14 +00:00
|
|
|
// Returns true if an object has elements of PACKED_SMI_ELEMENTS or
|
|
|
|
// HOLEY_SMI_ELEMENTS ElementsKind.
|
2017-06-30 18:00:44 +00:00
|
|
|
inline bool HasSmiElements();
|
2017-06-30 11:26:14 +00:00
|
|
|
// Returns true if an object has elements of PACKED_ELEMENTS or
|
|
|
|
// HOLEY_ELEMENTS ElementsKind.
|
2017-06-30 18:00:44 +00:00
|
|
|
inline bool HasObjectElements();
|
2017-06-30 11:26:14 +00:00
|
|
|
// Returns true if an object has elements of PACKED_SMI_ELEMENTS,
|
|
|
|
// HOLEY_SMI_ELEMENTS, PACKED_ELEMENTS, or HOLEY_ELEMENTS.
|
2017-06-30 18:00:44 +00:00
|
|
|
inline bool HasSmiOrObjectElements();
|
2017-06-30 11:26:14 +00:00
|
|
|
// Returns true if an object has any of the "fast" elements kinds.
|
2012-11-15 12:19:14 +00:00
|
|
|
inline bool HasFastElements();
|
2017-06-30 11:26:14 +00:00
|
|
|
// Returns true if an object has elements of PACKED_DOUBLE_ELEMENTS or
|
|
|
|
// HOLEY_DOUBLE_ELEMENTS ElementsKind.
|
2017-06-30 18:00:44 +00:00
|
|
|
inline bool HasDoubleElements();
|
|
|
|
// Returns true if an object has elements of HOLEY_SMI_ELEMENTS,
|
|
|
|
// HOLEY_DOUBLE_ELEMENTS, or HOLEY_ELEMENTS ElementsKind.
|
|
|
|
inline bool HasHoleyElements();
|
2014-03-11 14:39:08 +00:00
|
|
|
inline bool HasSloppyArgumentsElements();
|
2016-01-29 18:57:26 +00:00
|
|
|
inline bool HasStringWrapperElements();
|
2009-07-28 08:43:51 +00:00
|
|
|
inline bool HasDictionaryElements();
|
2014-01-16 17:08:45 +00:00
|
|
|
|
|
|
|
inline bool HasFixedTypedArrayElements();
|
|
|
|
|
2014-03-26 12:50:13 +00:00
|
|
|
inline bool HasFixedUint8ClampedElements();
|
|
|
|
inline bool HasFixedArrayElements();
|
|
|
|
inline bool HasFixedInt8Elements();
|
|
|
|
inline bool HasFixedUint8Elements();
|
|
|
|
inline bool HasFixedInt16Elements();
|
|
|
|
inline bool HasFixedUint16Elements();
|
|
|
|
inline bool HasFixedInt32Elements();
|
|
|
|
inline bool HasFixedUint32Elements();
|
|
|
|
inline bool HasFixedFloat32Elements();
|
|
|
|
inline bool HasFixedFloat64Elements();
|
|
|
|
|
2015-07-02 14:38:37 +00:00
|
|
|
inline bool HasFastArgumentsElements();
|
|
|
|
inline bool HasSlowArgumentsElements();
|
2016-01-29 18:57:26 +00:00
|
|
|
inline bool HasFastStringWrapperElements();
|
|
|
|
inline bool HasSlowStringWrapperElements();
|
2016-03-07 19:25:12 +00:00
|
|
|
bool HasEnumerableElements();
|
|
|
|
|
2012-01-16 09:44:35 +00:00
|
|
|
inline SeededNumberDictionary* element_dictionary(); // Gets slow elements.
|
2011-06-16 14:12:58 +00:00
|
|
|
|
|
|
|
// Requires: HasFastElements().
|
2016-02-25 05:39:57 +00:00
|
|
|
static void EnsureWritableFastElements(Handle<JSObject> object);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-10-23 09:39:37 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> SetPropertyWithInterceptor(
|
2016-01-22 09:53:29 +00:00
|
|
|
LookupIterator* it, ShouldThrow should_throw, Handle<Object> value);
|
2012-01-05 17:16:19 +00:00
|
|
|
|
2016-02-04 14:47:11 +00:00
|
|
|
// The API currently still wants DefineOwnPropertyIgnoreAttributes to convert
|
|
|
|
// AccessorInfo objects to data fields. We allow FORCE_FIELD as an exception
|
|
|
|
// to the default behavior that calls the setter.
|
|
|
|
enum AccessorInfoHandling { FORCE_FIELD, DONT_FORCE_FIELD };
|
2015-06-11 20:14:46 +00:00
|
|
|
|
2015-06-12 14:13:56 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> DefineOwnPropertyIgnoreAttributes(
|
|
|
|
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
|
2016-02-04 14:47:11 +00:00
|
|
|
AccessorInfoHandling handling = DONT_FORCE_FIELD);
|
2015-06-12 12:39:32 +00:00
|
|
|
|
2015-10-30 10:45:30 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> DefineOwnPropertyIgnoreAttributes(
|
|
|
|
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
|
|
|
|
ShouldThrow should_throw,
|
2016-02-04 14:47:11 +00:00
|
|
|
AccessorInfoHandling handling = DONT_FORCE_FIELD);
|
2015-10-30 10:45:30 +00:00
|
|
|
|
2014-05-22 15:27:57 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes(
|
2015-06-02 11:10:50 +00:00
|
|
|
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
|
2016-02-04 14:47:11 +00:00
|
|
|
PropertyAttributes attributes);
|
2015-06-11 15:07:00 +00:00
|
|
|
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> SetOwnElementIgnoreAttributes(
|
|
|
|
Handle<JSObject> object, uint32_t index, Handle<Object> value,
|
2016-02-04 14:47:11 +00:00
|
|
|
PropertyAttributes attributes);
|
2015-06-11 15:07:00 +00:00
|
|
|
|
2015-06-12 14:13:56 +00:00
|
|
|
// Equivalent to one of the above depending on whether |name| can be converted
|
|
|
|
// to an array index.
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object>
|
2016-02-04 14:47:11 +00:00
|
|
|
DefinePropertyOrElementIgnoreAttributes(Handle<JSObject> object,
|
|
|
|
Handle<Name> name,
|
|
|
|
Handle<Object> value,
|
|
|
|
PropertyAttributes attributes = NONE);
|
2012-01-05 17:16:19 +00:00
|
|
|
|
2015-06-17 11:25:22 +00:00
|
|
|
// Adds or reconfigures a property to attributes NONE. It will fail when it
|
|
|
|
// cannot.
|
2016-03-17 21:51:07 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> CreateDataProperty(
|
|
|
|
LookupIterator* it, Handle<Object> value,
|
|
|
|
ShouldThrow should_throw = DONT_THROW);
|
2015-06-17 11:25:22 +00:00
|
|
|
|
2015-06-02 11:10:50 +00:00
|
|
|
static void AddProperty(Handle<JSObject> object, Handle<Name> name,
|
2014-07-21 16:01:50 +00:00
|
|
|
Handle<Object> value, PropertyAttributes attributes);
|
2014-06-30 13:48:57 +00:00
|
|
|
|
2015-10-23 09:39:37 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> AddDataElement(
|
|
|
|
Handle<JSObject> receiver, uint32_t index, Handle<Object> value,
|
|
|
|
PropertyAttributes attributes, ShouldThrow should_throw);
|
2015-06-11 15:07:00 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> AddDataElement(
|
|
|
|
Handle<JSObject> receiver, uint32_t index, Handle<Object> value,
|
|
|
|
PropertyAttributes attributes);
|
|
|
|
|
2012-10-17 14:09:42 +00:00
|
|
|
// Extend the receiver with a single fast property appeared first in the
|
|
|
|
// passed map. This also extends the property backing store if necessary.
|
2013-05-08 15:02:08 +00:00
|
|
|
static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map);
|
2012-10-17 14:09:42 +00:00
|
|
|
|
2013-09-23 19:56:36 +00:00
|
|
|
// Migrates the given object to a map whose field representations are the
|
|
|
|
// lowest upper bound of all known representations for that field.
|
2013-04-26 15:30:41 +00:00
|
|
|
static void MigrateInstance(Handle<JSObject> instance);
|
|
|
|
|
2013-09-23 19:56:36 +00:00
|
|
|
// Migrates the given object only if the target map is already available,
|
2014-04-28 05:47:43 +00:00
|
|
|
// or returns false if such a map is not yet available.
|
|
|
|
static bool TryMigrateInstance(Handle<JSObject> instance);
|
2013-05-23 11:30:24 +00:00
|
|
|
|
2009-06-30 10:05:36 +00:00
|
|
|
// Sets the property value in a normalized object given (key, value, details).
|
|
|
|
// Handles the special representation of JS global objects.
|
2015-06-02 11:10:50 +00:00
|
|
|
static void SetNormalizedProperty(Handle<JSObject> object, Handle<Name> name,
|
2013-09-18 16:25:52 +00:00
|
|
|
Handle<Object> value,
|
|
|
|
PropertyDetails details);
|
2015-06-18 12:20:54 +00:00
|
|
|
static void SetDictionaryElement(Handle<JSObject> object, uint32_t index,
|
|
|
|
Handle<Object> value,
|
|
|
|
PropertyAttributes attributes);
|
|
|
|
static void SetDictionaryArgumentsElement(Handle<JSObject> object,
|
|
|
|
uint32_t index,
|
|
|
|
Handle<Object> value,
|
|
|
|
PropertyAttributes attributes);
|
2015-06-11 15:07:00 +00:00
|
|
|
|
2017-06-07 14:33:27 +00:00
|
|
|
static void OptimizeAsPrototype(Handle<JSObject> object);
|
2014-08-04 15:06:28 +00:00
|
|
|
static void ReoptimizeIfPrototype(Handle<JSObject> object);
|
2016-06-08 14:43:22 +00:00
|
|
|
static void MakePrototypesFast(Handle<Object> receiver,
|
|
|
|
WhereToStart where_to_start, Isolate* isolate);
|
2015-04-27 12:59:55 +00:00
|
|
|
static void LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate);
|
2016-01-05 16:15:00 +00:00
|
|
|
static void UpdatePrototypeUserRegistration(Handle<Map> old_map,
|
|
|
|
Handle<Map> new_map,
|
|
|
|
Isolate* isolate);
|
2015-08-08 22:56:15 +00:00
|
|
|
static bool UnregisterPrototypeUser(Handle<Map> user, Isolate* isolate);
|
2015-04-15 12:53:31 +00:00
|
|
|
static void InvalidatePrototypeChains(Map* map);
|
2012-06-06 10:17:26 +00:00
|
|
|
|
2016-11-16 17:44:39 +00:00
|
|
|
// Updates prototype chain tracking information when an object changes its
|
|
|
|
// map from |old_map| to |new_map|.
|
|
|
|
static void NotifyMapChange(Handle<Map> old_map, Handle<Map> new_map,
|
|
|
|
Isolate* isolate);
|
|
|
|
|
2016-08-03 03:26:58 +00:00
|
|
|
// Utility used by many Array builtins and runtime functions
|
|
|
|
static inline bool PrototypeHasNoElements(Isolate* isolate, JSObject* object);
|
|
|
|
|
2015-08-08 22:56:15 +00:00
|
|
|
// Alternative implementation of WeakFixedArray::NullCallback.
|
|
|
|
class PrototypeRegistryCompactionCallback {
|
|
|
|
public:
|
|
|
|
static void Callback(Object* value, int old_index, int new_index);
|
|
|
|
};
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Retrieve interceptors.
|
2016-03-10 10:55:46 +00:00
|
|
|
inline InterceptorInfo* GetNamedInterceptor();
|
2015-11-27 02:51:31 +00:00
|
|
|
inline InterceptorInfo* GetIndexedInterceptor();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
Implement set trap for proxies, and revamp class hierarchy in preparation:
- Introduce a class JSReceiver, that is a common superclass of JSObject and
JSProxy. Use JSReceiver where appropriate (probably lots of places that we
still have to migrate, but we will find those later with proxy test suite).
- Move appropriate methods to JSReceiver class (SetProperty,
GetPropertyAttribute, Get/SetPrototype, Lookup, and so on).
- Introduce new JSFunctionProxy subclass of JSProxy. Currently only a stub.
- Overhaul enum InstanceType:
* Introduce FIRST/LAST_SPEC_OBJECT_TYPE that ranges over all types that
represent JS objects, and use that consistently to check language types.
* Rename FIRST/LAST_JS_OBJECT_TYPE and FIRST/LAST_FUNCTION_CLASS_TYPE
to FIRST/LAST_[NON]CALLABLE_SPEC_OBJECT_TYPE for clarity.
* Eliminate the overlap over JS_REGEXP_TYPE.
* Also replace FIRST_JS_OBJECT with FIRST_JS_RECEIVER, but only use it where
we exclusively talk about the internal representation type.
* Insert JS_PROXY and JS_FUNCTION_PROXY in the appropriate places.
- Fix all checks concerning classification, especially for functions, to
use the CALLABLE_SPEC_OBJECT range (that includes funciton proxies).
- Handle proxies in SetProperty (that was the easiest part :) ).
- A few simple test cases.
R=kmillikin@chromium.org
Review URL: http://codereview.chromium.org/6992072
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8126 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-31 16:38:40 +00:00
|
|
|
// Used from JSReceiver.
|
2014-07-25 18:32:11 +00:00
|
|
|
MUST_USE_RESULT static Maybe<PropertyAttributes>
|
2015-05-21 17:24:28 +00:00
|
|
|
GetPropertyAttributesWithInterceptor(LookupIterator* it);
|
2014-07-25 18:32:11 +00:00
|
|
|
MUST_USE_RESULT static Maybe<PropertyAttributes>
|
|
|
|
GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-10-01 14:26:15 +00:00
|
|
|
// Defines an AccessorPair property on the given object.
|
2014-07-25 18:32:11 +00:00
|
|
|
// TODO(mstarzinger): Rename to SetAccessor().
|
|
|
|
static MaybeHandle<Object> DefineAccessor(Handle<JSObject> object,
|
|
|
|
Handle<Name> name,
|
|
|
|
Handle<Object> getter,
|
|
|
|
Handle<Object> setter,
|
|
|
|
PropertyAttributes attributes);
|
2015-10-13 14:38:16 +00:00
|
|
|
static MaybeHandle<Object> DefineAccessor(LookupIterator* it,
|
|
|
|
Handle<Object> getter,
|
|
|
|
Handle<Object> setter,
|
|
|
|
PropertyAttributes attributes);
|
2013-07-02 16:24:23 +00:00
|
|
|
|
2013-10-01 14:26:15 +00:00
|
|
|
// Defines an AccessorInfo property on the given object.
|
2014-04-17 08:33:18 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> SetAccessor(
|
|
|
|
Handle<JSObject> object,
|
|
|
|
Handle<AccessorInfo> info);
|
2010-05-25 12:14:49 +00:00
|
|
|
|
2015-06-17 14:06:29 +00:00
|
|
|
// The result must be checked first for exceptions. If there's no exception,
|
|
|
|
// the output parameter |done| indicates whether the interceptor has a result
|
|
|
|
// or not.
|
2014-04-04 12:25:45 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithInterceptor(
|
2015-06-17 14:06:29 +00:00
|
|
|
LookupIterator* it, bool* done);
|
2009-09-17 10:35:52 +00:00
|
|
|
|
2017-07-06 08:26:19 +00:00
|
|
|
static void ValidateElements(JSObject* object);
|
2011-09-22 11:30:04 +00:00
|
|
|
|
2011-12-09 08:50:19 +00:00
|
|
|
// Makes sure that this object can contain HeapObject as elements.
|
2013-09-09 14:29:47 +00:00
|
|
|
static inline void EnsureCanContainHeapObjectElements(Handle<JSObject> obj);
|
2011-09-22 11:30:04 +00:00
|
|
|
|
|
|
|
// Makes sure that this object can contain the specified elements.
|
2014-03-21 14:29:27 +00:00
|
|
|
static inline void EnsureCanContainElements(
|
|
|
|
Handle<JSObject> object,
|
2012-02-20 10:17:25 +00:00
|
|
|
Object** elements,
|
|
|
|
uint32_t count,
|
|
|
|
EnsureElementsMode mode);
|
2014-03-21 08:30:42 +00:00
|
|
|
static inline void EnsureCanContainElements(
|
|
|
|
Handle<JSObject> object,
|
|
|
|
Handle<FixedArrayBase> elements,
|
|
|
|
uint32_t length,
|
|
|
|
EnsureElementsMode mode);
|
2014-03-18 11:38:27 +00:00
|
|
|
static void EnsureCanContainElements(
|
|
|
|
Handle<JSObject> object,
|
|
|
|
Arguments* arguments,
|
|
|
|
uint32_t first_arg,
|
|
|
|
uint32_t arg_count,
|
|
|
|
EnsureElementsMode mode);
|
2011-09-22 11:30:04 +00:00
|
|
|
|
2014-03-06 13:07:51 +00:00
|
|
|
// Would we convert a fast elements array to dictionary mode given
|
|
|
|
// an access at key?
|
2015-04-30 12:34:02 +00:00
|
|
|
bool WouldConvertToSlowElements(uint32_t index);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-05-15 15:56:10 +00:00
|
|
|
static const uint32_t kMinAddedElementsCapacity = 16;
|
|
|
|
|
2011-03-03 10:16:22 +00:00
|
|
|
// Computes the new capacity when expanding the elements of a JSObject.
|
2015-06-19 18:59:11 +00:00
|
|
|
static uint32_t NewElementsCapacity(uint32_t old_capacity) {
|
2017-05-15 15:56:10 +00:00
|
|
|
// (old_capacity + 50%) + kMinAddedElementsCapacity
|
|
|
|
return old_capacity + (old_capacity >> 1) + kMinAddedElementsCapacity;
|
2011-03-03 10:16:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-16 13:28:34 +00:00
|
|
|
// These methods do not perform access checks!
|
2016-08-25 11:39:27 +00:00
|
|
|
template <AllocationSiteUpdateMode update_or_check =
|
|
|
|
AllocationSiteUpdateMode::kUpdate>
|
|
|
|
static bool UpdateAllocationSite(Handle<JSObject> object,
|
2015-06-11 15:07:00 +00:00
|
|
|
ElementsKind to_kind);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Lookup interceptors are used for handling properties controlled by host
|
|
|
|
// objects.
|
|
|
|
inline bool HasNamedInterceptor();
|
|
|
|
inline bool HasIndexedInterceptor();
|
|
|
|
|
|
|
|
// Support functions for v8 api (needed for correct interceptor behavior).
|
2014-07-25 18:32:11 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> HasRealNamedProperty(
|
2015-06-02 11:10:50 +00:00
|
|
|
Handle<JSObject> object, Handle<Name> name);
|
2014-07-25 18:32:11 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> HasRealElementProperty(
|
|
|
|
Handle<JSObject> object, uint32_t index);
|
|
|
|
MUST_USE_RESULT static Maybe<bool> HasRealNamedCallbackProperty(
|
2015-06-02 11:10:50 +00:00
|
|
|
Handle<JSObject> object, Handle<Name> name);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Get the header size for a JSObject. Used to compute the index of
|
2017-03-17 13:26:05 +00:00
|
|
|
// embedder fields as well as the number of embedder fields.
|
2015-11-02 08:25:19 +00:00
|
|
|
static inline int GetHeaderSize(InstanceType instance_type);
|
2008-07-03 15:10:15 +00:00
|
|
|
inline int GetHeaderSize();
|
|
|
|
|
2017-07-03 13:29:23 +00:00
|
|
|
static inline int GetEmbedderFieldCount(const Map* map);
|
|
|
|
inline int GetEmbedderFieldCount() const;
|
2017-03-17 13:26:05 +00:00
|
|
|
inline int GetEmbedderFieldOffset(int index);
|
|
|
|
inline Object* GetEmbedderField(int index);
|
|
|
|
inline void SetEmbedderField(int index, Object* value);
|
|
|
|
inline void SetEmbedderField(int index, Smi* value);
|
2016-04-12 10:31:38 +00:00
|
|
|
bool WasConstructedFromApiFunction();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-09-15 16:38:47 +00:00
|
|
|
// Returns a new map with all transitions dropped from the object's current
|
|
|
|
// map and the ElementsKind set.
|
2011-10-21 11:42:54 +00:00
|
|
|
static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
|
|
|
|
ElementsKind to_kind);
|
2013-09-23 11:57:34 +00:00
|
|
|
static void TransitionElementsKind(Handle<JSObject> object,
|
|
|
|
ElementsKind to_kind);
|
2012-01-05 17:16:19 +00:00
|
|
|
|
2015-04-07 10:42:45 +00:00
|
|
|
// Always use this to migrate an object to a new map.
|
|
|
|
// |expected_additional_properties| is only used for fast-to-slow transitions
|
|
|
|
// and ignored otherwise.
|
|
|
|
static void MigrateToMap(Handle<JSObject> object, Handle<Map> new_map,
|
|
|
|
int expected_additional_properties = 0);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-07-19 11:28:43 +00:00
|
|
|
// Forces a prototype without any of the checks that the regular SetPrototype
|
|
|
|
// would do.
|
|
|
|
static void ForceSetPrototype(Handle<JSObject> object, Handle<Object> proto);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Convert the object to use the canonical dictionary
|
2009-07-30 09:13:48 +00:00
|
|
|
// representation. If the object is expected to have additional properties
|
|
|
|
// added this number can be indicated to have the backing store allocated to
|
|
|
|
// an initial capacity for holding these properties.
|
2012-01-05 17:16:19 +00:00
|
|
|
static void NormalizeProperties(Handle<JSObject> object,
|
|
|
|
PropertyNormalizationMode mode,
|
2014-11-07 16:03:11 +00:00
|
|
|
int expected_additional_properties,
|
|
|
|
const char* reason);
|
2012-01-05 17:16:19 +00:00
|
|
|
|
2012-01-16 09:44:35 +00:00
|
|
|
// Convert and update the elements backing store to be a
|
|
|
|
// SeededNumberDictionary dictionary. Returns the backing after conversion.
|
|
|
|
static Handle<SeededNumberDictionary> NormalizeElements(
|
|
|
|
Handle<JSObject> object);
|
2012-01-05 17:16:19 +00:00
|
|
|
|
2015-07-15 12:06:20 +00:00
|
|
|
void RequireSlowElements(SeededNumberDictionary* dictionary);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Transform slow named properties to fast variants.
|
2014-06-24 15:56:36 +00:00
|
|
|
static void MigrateSlowToFast(Handle<JSObject> object,
|
2014-11-07 16:03:11 +00:00
|
|
|
int unused_property_fields, const char* reason);
|
2012-01-05 17:16:19 +00:00
|
|
|
|
2014-11-11 10:24:52 +00:00
|
|
|
inline bool IsUnboxedDoubleField(FieldIndex index);
|
|
|
|
|
2008-10-15 06:03:26 +00:00
|
|
|
// Access fast-case object properties at index.
|
2014-03-31 14:21:04 +00:00
|
|
|
static Handle<Object> FastPropertyAt(Handle<JSObject> object,
|
|
|
|
Representation representation,
|
2014-06-10 14:01:08 +00:00
|
|
|
FieldIndex index);
|
|
|
|
inline Object* RawFastPropertyAt(FieldIndex index);
|
2014-11-11 10:24:52 +00:00
|
|
|
inline double RawFastDoublePropertyAt(FieldIndex index);
|
2017-01-23 18:18:48 +00:00
|
|
|
inline uint64_t RawFastDoublePropertyAsBitsAt(FieldIndex index);
|
2014-11-11 10:24:52 +00:00
|
|
|
|
2014-06-10 14:01:08 +00:00
|
|
|
inline void FastPropertyAtPut(FieldIndex index, Object* value);
|
2014-11-11 10:24:52 +00:00
|
|
|
inline void RawFastPropertyAtPut(FieldIndex index, Object* value);
|
2017-01-23 18:18:48 +00:00
|
|
|
inline void RawFastDoublePropertyAsBitsAtPut(FieldIndex index, uint64_t bits);
|
2016-02-19 10:41:22 +00:00
|
|
|
inline void WriteToField(int descriptor, PropertyDetails details,
|
|
|
|
Object* value);
|
2008-10-15 06:03:26 +00:00
|
|
|
|
2009-03-23 07:27:47 +00:00
|
|
|
// Access to in object properties.
|
2011-03-18 12:49:27 +00:00
|
|
|
inline int GetInObjectPropertyOffset(int index);
|
2009-03-23 07:27:47 +00:00
|
|
|
inline Object* InObjectPropertyAt(int index);
|
2008-10-23 08:46:32 +00:00
|
|
|
inline Object* InObjectPropertyAtPut(int index,
|
|
|
|
Object* value,
|
|
|
|
WriteBarrierMode mode
|
|
|
|
= UPDATE_WRITE_BARRIER);
|
2008-10-15 06:03:26 +00:00
|
|
|
|
2013-07-02 15:32:46 +00:00
|
|
|
// Set the object's prototype (only JSReceiver and null are allowed values).
|
2015-10-22 11:21:22 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> SetPrototype(Handle<JSObject> object,
|
|
|
|
Handle<Object> value,
|
|
|
|
bool from_javascript,
|
|
|
|
ShouldThrow should_throw);
|
2013-07-02 15:32:46 +00:00
|
|
|
|
2016-07-01 19:16:53 +00:00
|
|
|
// Makes the object prototype immutable
|
|
|
|
// Never called from JavaScript
|
|
|
|
static void SetImmutableProto(Handle<JSObject> object);
|
|
|
|
|
2015-11-25 12:41:35 +00:00
|
|
|
// Initializes the body starting at |start_offset|. It is responsibility of
|
|
|
|
// the caller to initialize object header. Fill the pre-allocated fields with
|
2011-09-20 10:06:23 +00:00
|
|
|
// pre_allocated_value and the rest with filler_value.
|
|
|
|
// Note: this call does not update write barrier, the caller is responsible
|
|
|
|
// to ensure that |filler_value| can be collected without WB here.
|
2015-11-25 12:41:35 +00:00
|
|
|
inline void InitializeBody(Map* map, int start_offset,
|
|
|
|
Object* pre_allocated_value, Object* filler_value);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Check whether this object references another object
|
|
|
|
bool ReferencesObject(Object* obj);
|
|
|
|
|
2017-06-22 12:19:26 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> TestIntegrityLevel(Handle<JSObject> object,
|
|
|
|
IntegrityLevel lvl);
|
|
|
|
|
2015-10-21 09:23:33 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> PreventExtensions(
|
|
|
|
Handle<JSObject> object, ShouldThrow should_throw);
|
2010-07-02 14:36:34 +00:00
|
|
|
|
2015-10-01 16:09:50 +00:00
|
|
|
static bool IsExtensible(Handle<JSObject> object);
|
2015-05-27 15:03:28 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSObject)
|
2013-09-20 11:37:02 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Dispatched behavior.
|
|
|
|
void JSObjectShortPrint(StringStream* accumulator);
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSObject)
|
|
|
|
DECL_VERIFIER(JSObject)
|
2010-12-20 10:38:19 +00:00
|
|
|
#ifdef OBJECT_PRINT
|
2017-01-13 13:57:00 +00:00
|
|
|
bool PrintProperties(std::ostream& os); // NOLINT
|
2017-04-06 08:51:47 +00:00
|
|
|
void PrintElements(std::ostream& os); // NOLINT
|
2014-12-08 09:26:04 +00:00
|
|
|
#endif
|
2014-12-09 14:20:01 +00:00
|
|
|
#if defined(DEBUG) || defined(OBJECT_PRINT)
|
2014-09-30 10:29:32 +00:00
|
|
|
void PrintTransitions(std::ostream& os); // NOLINT
|
2010-12-20 10:38:19 +00:00
|
|
|
#endif
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-03-25 15:33:22 +00:00
|
|
|
static void PrintElementsTransition(
|
|
|
|
FILE* file, Handle<JSObject> object,
|
|
|
|
ElementsKind from_kind, Handle<FixedArrayBase> from_elements,
|
|
|
|
ElementsKind to_kind, Handle<FixedArrayBase> to_elements);
|
2011-10-20 09:38:24 +00:00
|
|
|
|
2013-08-19 12:32:50 +00:00
|
|
|
void PrintInstanceMigration(FILE* file, Map* original_map, Map* new_map);
|
|
|
|
|
2010-12-20 10:38:19 +00:00
|
|
|
#ifdef DEBUG
|
2008-07-03 15:10:15 +00:00
|
|
|
// Structure for collecting spill information about JSObjects.
|
2013-08-20 10:52:23 +00:00
|
|
|
class SpillInformation {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
void Clear();
|
|
|
|
void Print();
|
|
|
|
int number_of_objects_;
|
|
|
|
int number_of_objects_with_fast_properties_;
|
|
|
|
int number_of_objects_with_fast_elements_;
|
|
|
|
int number_of_fast_used_fields_;
|
|
|
|
int number_of_fast_unused_fields_;
|
|
|
|
int number_of_slow_used_properties_;
|
|
|
|
int number_of_slow_unused_properties_;
|
|
|
|
int number_of_fast_used_elements_;
|
|
|
|
int number_of_fast_unused_elements_;
|
|
|
|
int number_of_slow_used_elements_;
|
|
|
|
int number_of_slow_unused_elements_;
|
|
|
|
};
|
|
|
|
|
|
|
|
void IncrementSpillStatistics(SpillInformation* info);
|
2013-10-29 07:56:47 +00:00
|
|
|
#endif
|
2013-10-25 12:26:47 +00:00
|
|
|
|
2013-10-29 07:56:47 +00:00
|
|
|
#ifdef VERIFY_HEAP
|
2013-10-25 12:26:47 +00:00
|
|
|
// If a GC was caused while constructing this object, the elements pointer
|
|
|
|
// may point to a one pointer filler map. The object won't be rooted, but
|
|
|
|
// our heap verification code could stumble across it.
|
|
|
|
bool ElementsAreSafeToExamine();
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif
|
2013-10-29 07:56:47 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
Object* SlowReverseLookup(Object* value);
|
|
|
|
|
2010-01-07 13:17:18 +00:00
|
|
|
// Maximal number of elements (numbered 0 .. kMaxElementCount - 1).
|
|
|
|
// Also maximal value of JSArray's length property.
|
|
|
|
static const uint32_t kMaxElementCount = 0xffffffffu;
|
|
|
|
|
2011-07-26 13:56:21 +00:00
|
|
|
// Constants for heuristics controlling conversion of fast elements
|
|
|
|
// to slow elements.
|
|
|
|
|
|
|
|
// Maximal gap that can be introduced by adding an element beyond
|
|
|
|
// the current elements length.
|
2008-07-03 15:10:15 +00:00
|
|
|
static const uint32_t kMaxGap = 1024;
|
2011-07-26 13:56:21 +00:00
|
|
|
|
|
|
|
// Maximal length of fast elements array that won't be checked for
|
|
|
|
// being dense enough on expansion.
|
|
|
|
static const int kMaxUncheckedFastElementsLength = 5000;
|
|
|
|
|
|
|
|
// Same as above but for old arrays. This limit is more strict. We
|
|
|
|
// don't want to be wasteful with long lived objects.
|
|
|
|
static const int kMaxUncheckedOldFastElementsLength = 500;
|
|
|
|
|
2015-05-07 08:39:53 +00:00
|
|
|
// This constant applies only to the initial map of "global.Object" and
|
|
|
|
// not to arbitrary other JSObject maps.
|
2014-05-23 12:55:57 +00:00
|
|
|
static const int kInitialGlobalObjectUnusedPropertiesCount = 4;
|
|
|
|
|
2008-10-16 05:45:33 +00:00
|
|
|
static const int kMaxInstanceSize = 255 * kPointerSize;
|
2017-05-29 09:41:52 +00:00
|
|
|
|
2008-10-09 12:18:48 +00:00
|
|
|
// When extending the backing storage for property values, we increase
|
|
|
|
// its size by more than the 1 entry necessary, so sequentially adding fields
|
|
|
|
// to the same object requires fewer allocations and copies.
|
|
|
|
static const int kFieldsAdded = 3;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Layout description.
|
2016-01-12 15:43:41 +00:00
|
|
|
static const int kElementsOffset = JSReceiver::kHeaderSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kHeaderSize = kElementsOffset + kPointerSize;
|
|
|
|
|
2014-05-27 13:43:29 +00:00
|
|
|
STATIC_ASSERT(kHeaderSize == Internals::kJSObjectHeaderSize);
|
2017-05-29 09:41:52 +00:00
|
|
|
static const int kMaxInObjectProperties =
|
|
|
|
(kMaxInstanceSize - kHeaderSize) >> kPointerSizeLog2;
|
2009-08-26 10:33:11 +00:00
|
|
|
|
2017-03-24 14:42:52 +00:00
|
|
|
class BodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
|
|
|
|
2017-04-07 19:53:55 +00:00
|
|
|
class FastBodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef FastBodyDescriptor FastBodyDescriptorWeak;
|
2010-08-11 14:30:14 +00:00
|
|
|
|
2015-07-15 15:57:27 +00:00
|
|
|
// Gets the number of currently used elements.
|
|
|
|
int GetFastElementsUsage();
|
2015-06-25 10:48:51 +00:00
|
|
|
|
2015-07-17 12:30:05 +00:00
|
|
|
static bool AllCanRead(LookupIterator* it);
|
|
|
|
static bool AllCanWrite(LookupIterator* it);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
2013-07-17 16:38:49 +00:00
|
|
|
friend class JSReceiver;
|
2013-10-10 15:38:52 +00:00
|
|
|
friend class Object;
|
|
|
|
|
|
|
|
// Used from Object::GetProperty().
|
2014-04-04 12:25:45 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithFailedAccessCheck(
|
2015-06-19 19:00:45 +00:00
|
|
|
LookupIterator* it);
|
2011-08-03 11:12:46 +00:00
|
|
|
|
2015-10-23 09:39:37 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> SetPropertyWithFailedAccessCheck(
|
|
|
|
LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
|
2013-09-17 11:01:43 +00:00
|
|
|
|
2015-11-26 09:34:11 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> DeletePropertyWithInterceptor(
|
2016-01-22 09:53:29 +00:00
|
|
|
LookupIterator* it, ShouldThrow should_throw);
|
2013-07-17 16:38:49 +00:00
|
|
|
|
2011-06-16 14:12:58 +00:00
|
|
|
bool ReferencesObjectFromElements(FixedArray* elements,
|
|
|
|
ElementsKind kind,
|
|
|
|
Object* object);
|
|
|
|
|
2016-06-07 13:51:11 +00:00
|
|
|
static Object* GetIdentityHash(Isolate* isolate, Handle<JSObject> object);
|
2011-10-04 07:45:25 +00:00
|
|
|
|
2016-06-07 13:51:11 +00:00
|
|
|
static Smi* GetOrCreateIdentityHash(Isolate* isolate,
|
|
|
|
Handle<JSObject> object);
|
2013-08-30 13:42:16 +00:00
|
|
|
|
2014-12-10 20:02:48 +00:00
|
|
|
// Helper for fast versions of preventExtensions, seal, and freeze.
|
|
|
|
// attrs is one of NONE, SEALED, or FROZEN (depending on the operation).
|
|
|
|
template <PropertyAttributes attrs>
|
2015-10-05 12:08:44 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> PreventExtensionsWithTransition(
|
2015-10-21 09:23:33 +00:00
|
|
|
Handle<JSObject> object, ShouldThrow should_throw);
|
2014-12-10 20:02:48 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject);
|
|
|
|
};
|
2016-01-20 07:55:24 +00:00
|
|
|
|
|
|
|
|
2016-01-20 19:04:06 +00:00
|
|
|
// JSAccessorPropertyDescriptor is just a JSObject with a specific initial
|
|
|
|
// map. This initial map adds in-object properties for "get", "set",
|
|
|
|
// "enumerable" and "configurable" properties, as assigned by the
|
|
|
|
// FromPropertyDescriptor function for regular accessor properties.
|
|
|
|
class JSAccessorPropertyDescriptor: public JSObject {
|
|
|
|
public:
|
|
|
|
// Offsets of object fields.
|
|
|
|
static const int kGetOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kSetOffset = kGetOffset + kPointerSize;
|
|
|
|
static const int kEnumerableOffset = kSetOffset + kPointerSize;
|
|
|
|
static const int kConfigurableOffset = kEnumerableOffset + kPointerSize;
|
|
|
|
static const int kSize = kConfigurableOffset + kPointerSize;
|
|
|
|
// Indices of in-object properties.
|
|
|
|
static const int kGetIndex = 0;
|
|
|
|
static const int kSetIndex = 1;
|
|
|
|
static const int kEnumerableIndex = 2;
|
|
|
|
static const int kConfigurableIndex = 3;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSAccessorPropertyDescriptor);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// JSDataPropertyDescriptor is just a JSObject with a specific initial map.
|
|
|
|
// This initial map adds in-object properties for "value", "writable",
|
|
|
|
// "enumerable" and "configurable" properties, as assigned by the
|
|
|
|
// FromPropertyDescriptor function for regular data properties.
|
|
|
|
class JSDataPropertyDescriptor: public JSObject {
|
|
|
|
public:
|
|
|
|
// Offsets of object fields.
|
|
|
|
static const int kValueOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kWritableOffset = kValueOffset + kPointerSize;
|
|
|
|
static const int kEnumerableOffset = kWritableOffset + kPointerSize;
|
|
|
|
static const int kConfigurableOffset = kEnumerableOffset + kPointerSize;
|
|
|
|
static const int kSize = kConfigurableOffset + kPointerSize;
|
|
|
|
// Indices of in-object properties.
|
|
|
|
static const int kValueIndex = 0;
|
|
|
|
static const int kWritableIndex = 1;
|
|
|
|
static const int kEnumerableIndex = 2;
|
|
|
|
static const int kConfigurableIndex = 3;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSDataPropertyDescriptor);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-02-08 06:55:16 +00:00
|
|
|
// JSIteratorResult is just a JSObject with a specific initial map.
|
2016-02-12 05:10:38 +00:00
|
|
|
// This initial map adds in-object properties for "done" and "value",
|
2016-02-08 06:55:16 +00:00
|
|
|
// as specified by ES6 section 25.1.1.3 The IteratorResult Interface
|
|
|
|
class JSIteratorResult: public JSObject {
|
|
|
|
public:
|
2017-02-28 10:11:54 +00:00
|
|
|
DECL_ACCESSORS(value, Object)
|
2017-02-28 12:40:46 +00:00
|
|
|
|
2016-09-21 14:17:42 +00:00
|
|
|
DECL_ACCESSORS(done, Object)
|
|
|
|
|
2016-02-08 06:55:16 +00:00
|
|
|
// Offsets of object fields.
|
|
|
|
static const int kValueOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kDoneOffset = kValueOffset + kPointerSize;
|
|
|
|
static const int kSize = kDoneOffset + kPointerSize;
|
|
|
|
// Indices of in-object properties.
|
|
|
|
static const int kValueIndex = 0;
|
|
|
|
static const int kDoneIndex = 1;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSIteratorResult);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-06-09 10:03:35 +00:00
|
|
|
// Common superclass for FixedArrays that allow implementations to share
|
|
|
|
// common accessors and some code paths.
|
2013-08-20 10:52:23 +00:00
|
|
|
class FixedArrayBase: public HeapObject {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
// [length]: length of the array.
|
2014-06-20 10:31:17 +00:00
|
|
|
inline int length() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void set_length(int value);
|
|
|
|
|
2014-03-31 14:29:01 +00:00
|
|
|
// Get and set the length using acquire loads and release stores.
|
2014-06-20 10:31:17 +00:00
|
|
|
inline int synchronized_length() const;
|
2014-03-31 14:29:01 +00:00
|
|
|
inline void synchronized_set_length(int value);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(FixedArrayBase)
|
2011-06-09 10:03:35 +00:00
|
|
|
|
2016-08-09 08:54:31 +00:00
|
|
|
static int GetMaxLengthForNewSpaceAllocation(ElementsKind kind);
|
|
|
|
|
2017-06-16 10:07:41 +00:00
|
|
|
bool IsCowArray() const;
|
|
|
|
|
2011-06-09 10:03:35 +00:00
|
|
|
// Layout description.
|
|
|
|
// Length is smi tagged when it is stored.
|
|
|
|
static const int kLengthOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kHeaderSize = kLengthOffset + kPointerSize;
|
|
|
|
};
|
|
|
|
|
2011-08-11 14:00:16 +00:00
|
|
|
|
2011-07-22 09:04:16 +00:00
|
|
|
class FixedDoubleArray;
|
2012-07-05 13:54:20 +00:00
|
|
|
class IncrementalMarking;
|
|
|
|
|
2011-06-09 10:03:35 +00:00
|
|
|
|
|
|
|
// FixedArray describes fixed-sized arrays with element type Object*.
|
2013-08-20 10:52:23 +00:00
|
|
|
class FixedArray: public FixedArrayBase {
|
2011-06-09 10:03:35 +00:00
|
|
|
public:
|
2008-07-03 15:10:15 +00:00
|
|
|
// Setter and getter for elements.
|
2014-10-27 16:34:28 +00:00
|
|
|
inline Object* get(int index) const;
|
2016-01-29 18:57:26 +00:00
|
|
|
static inline Handle<Object> get(FixedArray* array, int index,
|
|
|
|
Isolate* isolate);
|
2016-06-28 23:47:30 +00:00
|
|
|
template <class T>
|
2016-07-28 17:16:33 +00:00
|
|
|
MaybeHandle<T> GetValue(Isolate* isolate, int index) const;
|
2016-06-28 23:47:30 +00:00
|
|
|
|
|
|
|
template <class T>
|
2016-07-28 17:16:33 +00:00
|
|
|
Handle<T> GetValueChecked(Isolate* isolate, int index) const;
|
|
|
|
|
|
|
|
// Return a grown copy if the index is bigger than the array's length.
|
|
|
|
static Handle<FixedArray> SetAndGrow(Handle<FixedArray> array, int index,
|
|
|
|
Handle<Object> value);
|
2016-06-28 23:47:30 +00:00
|
|
|
|
2008-11-25 11:07:48 +00:00
|
|
|
// Setter that uses write barrier.
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void set(int index, Object* value);
|
2016-11-15 18:30:35 +00:00
|
|
|
inline bool is_the_hole(Isolate* isolate, int index);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-06-13 15:00:30 +00:00
|
|
|
// Setter that doesn't need write barrier.
|
2008-11-25 11:07:48 +00:00
|
|
|
inline void set(int index, Smi* value);
|
|
|
|
// Setter with explicit barrier mode.
|
2008-10-23 08:46:32 +00:00
|
|
|
inline void set(int index, Object* value, WriteBarrierMode mode);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Setters for frequently used oddballs located in old space.
|
|
|
|
inline void set_undefined(int index);
|
2016-11-23 09:43:42 +00:00
|
|
|
inline void set_undefined(Isolate* isolate, int index);
|
2008-09-18 11:18:27 +00:00
|
|
|
inline void set_null(int index);
|
2016-11-23 09:43:42 +00:00
|
|
|
inline void set_null(Isolate* isolate, int index);
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void set_the_hole(int index);
|
2016-11-23 09:43:42 +00:00
|
|
|
inline void set_the_hole(Isolate* isolate, int index);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-12-09 08:50:19 +00:00
|
|
|
inline Object** GetFirstElementAddress();
|
|
|
|
inline bool ContainsOnlySmisOrHoles();
|
|
|
|
|
2012-11-15 12:19:14 +00:00
|
|
|
// Gives access to raw memory which stores the array's data.
|
|
|
|
inline Object** data_start();
|
|
|
|
|
2014-03-28 13:05:23 +00:00
|
|
|
inline void FillWithHoles(int from, int to);
|
|
|
|
|
Retry landing "Implement zone-allocated types"
Works around apparent scoping bug in VS, the only change to before being a method rename in the test suite:
--- a/test/cctest/test-types.cc
+++ b/test/cctest/test-types.cc
@@ -153,7 +153,7 @@ struct ZoneRep {
return reinterpret_cast<ZoneList<ZoneType*>*>(AsTagged(t));
}
- static Zone* Region(Zone* zone, Isolate* isolate) { return zone; }
+ static Zone* ToRegion(Zone* zone, Isolate* isolate) { return zone; }
};
@@ -168,7 +168,7 @@ struct HeapRep {
static Object* AsConstant(Handle<Type> t) { return Box::cast(*t)->value(); }
static FixedArray* AsUnion(Handle<Type> t) { return FixedArray::cast(*t); }
- static Isolate* Region(Zone* zone, Isolate* isolate) { return isolate; }
+ static Isolate* ToRegion(Zone* zone, Isolate* isolate) { return isolate; }
};
@@ -183,7 +183,7 @@ struct Tests : Rep {
isolate(CcTest::i_isolate()),
scope(isolate),
zone(isolate),
- T(Rep::Region(&zone, isolate), isolate) {
+ T(Rep::ToRegion(&zone, isolate), isolate) {
}
static void CheckEqual(TypeHandle type1, TypeHandle type2) {
R=titzer@chromium.org
BUG=
Review URL: https://codereview.chromium.org/143693003
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18711 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-01-21 14:14:12 +00:00
|
|
|
// Shrink length and insert filler objects.
|
|
|
|
void Shrink(int length);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Copy a sub array from the receiver to dest.
|
2017-04-04 11:29:59 +00:00
|
|
|
void CopyTo(int pos, FixedArray* dest, int dest_pos, int len) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Garbage collection support.
|
2017-01-18 14:26:56 +00:00
|
|
|
static constexpr int SizeFor(int length) {
|
|
|
|
return kHeaderSize + length * kPointerSize;
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-06-26 11:35:42 +00:00
|
|
|
// Code Generation support.
|
2017-01-18 14:26:56 +00:00
|
|
|
static constexpr int OffsetOfElementAt(int index) { return SizeFor(index); }
|
2009-06-26 11:35:42 +00:00
|
|
|
|
2013-12-23 14:42:42 +00:00
|
|
|
// Garbage collection support.
|
2015-08-13 11:49:01 +00:00
|
|
|
inline Object** RawFieldOfElementAt(int index);
|
2013-12-23 14:42:42 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(FixedArray)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-01-07 13:17:18 +00:00
|
|
|
// Maximal allowed size, in bytes, of a single FixedArray.
|
|
|
|
// Prevents overflowing size computations, as well as extreme memory
|
|
|
|
// consumption.
|
2011-11-22 16:02:26 +00:00
|
|
|
static const int kMaxSize = 128 * MB * kPointerSize;
|
2010-01-07 13:17:18 +00:00
|
|
|
// Maximally allowed length of a FixedArray.
|
|
|
|
static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize;
|
2017-04-27 14:48:32 +00:00
|
|
|
// Maximally allowed length for regular (non large object space) object.
|
|
|
|
STATIC_ASSERT(kMaxRegularHeapObjectSize < kMaxSize);
|
|
|
|
static const int kMaxRegularLength =
|
|
|
|
(kMaxRegularHeapObjectSize - kHeaderSize) / kPointerSize;
|
2009-05-18 12:13:20 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(FixedArray)
|
|
|
|
DECL_VERIFIER(FixedArray)
|
2008-07-03 15:10:15 +00:00
|
|
|
#ifdef DEBUG
|
2008-08-27 10:11:39 +00:00
|
|
|
// Checks if two FixedArrays have identical contents.
|
|
|
|
bool IsEqualTo(FixedArray* other);
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif
|
|
|
|
|
2015-11-13 12:32:08 +00:00
|
|
|
typedef FlexibleBodyDescriptor<kHeaderSize> BodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2010-08-11 14:30:14 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
protected:
|
2010-01-28 08:46:56 +00:00
|
|
|
// Set operation on FixedArray without using write barriers. Can
|
|
|
|
// only be used for storing old space objects or smis.
|
2011-10-21 10:32:38 +00:00
|
|
|
static inline void NoWriteBarrierSet(FixedArray* array,
|
|
|
|
int index,
|
|
|
|
Object* value);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
2014-05-27 13:43:29 +00:00
|
|
|
STATIC_ASSERT(kHeaderSize == Internals::kFixedArrayHeaderSize);
|
2012-11-13 12:27:03 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray);
|
|
|
|
};
|
|
|
|
|
2011-06-09 10:03:35 +00:00
|
|
|
// FixedDoubleArray describes fixed-sized arrays with element type double.
|
2013-08-20 10:52:23 +00:00
|
|
|
class FixedDoubleArray: public FixedArrayBase {
|
2011-06-09 10:03:35 +00:00
|
|
|
public:
|
|
|
|
// Setter and getter for elements.
|
2011-08-03 11:12:46 +00:00
|
|
|
inline double get_scalar(int index);
|
2015-01-21 08:52:00 +00:00
|
|
|
inline uint64_t get_representation(int index);
|
2016-01-29 18:57:26 +00:00
|
|
|
static inline Handle<Object> get(FixedDoubleArray* array, int index,
|
|
|
|
Isolate* isolate);
|
2011-06-09 10:03:35 +00:00
|
|
|
inline void set(int index, double value);
|
2016-11-23 09:43:42 +00:00
|
|
|
inline void set_the_hole(Isolate* isolate, int index);
|
2011-06-09 10:03:35 +00:00
|
|
|
inline void set_the_hole(int index);
|
|
|
|
|
|
|
|
// Checking for the hole.
|
2016-11-15 18:30:35 +00:00
|
|
|
inline bool is_the_hole(Isolate* isolate, int index);
|
2011-06-09 10:03:35 +00:00
|
|
|
inline bool is_the_hole(int index);
|
|
|
|
|
|
|
|
// Garbage collection support.
|
|
|
|
inline static int SizeFor(int length) {
|
|
|
|
return kHeaderSize + length * kDoubleSize;
|
|
|
|
}
|
|
|
|
|
2012-11-15 12:19:14 +00:00
|
|
|
// Gives access to raw memory which stores the array's data.
|
|
|
|
inline double* data_start();
|
|
|
|
|
2014-03-28 13:05:23 +00:00
|
|
|
inline void FillWithHoles(int from, int to);
|
|
|
|
|
2011-07-20 09:11:38 +00:00
|
|
|
// Code Generation support.
|
|
|
|
static int OffsetOfElementAt(int index) { return SizeFor(index); }
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(FixedDoubleArray)
|
2011-06-09 10:03:35 +00:00
|
|
|
|
|
|
|
// Maximal allowed size, in bytes, of a single FixedDoubleArray.
|
|
|
|
// Prevents overflowing size computations, as well as extreme memory
|
|
|
|
// consumption.
|
|
|
|
static const int kMaxSize = 512 * MB;
|
|
|
|
// Maximally allowed length of a FixedArray.
|
|
|
|
static const int kMaxLength = (kMaxSize - kHeaderSize) / kDoubleSize;
|
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(FixedDoubleArray)
|
|
|
|
DECL_VERIFIER(FixedDoubleArray)
|
2011-06-09 10:03:35 +00:00
|
|
|
|
2017-04-27 15:43:54 +00:00
|
|
|
class BodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2017-04-27 15:43:54 +00:00
|
|
|
|
2011-06-09 10:03:35 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray);
|
|
|
|
};
|
|
|
|
|
2014-12-15 19:57:37 +00:00
|
|
|
class WeakFixedArray : public FixedArray {
|
|
|
|
public:
|
|
|
|
// If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated.
|
2015-08-08 22:56:15 +00:00
|
|
|
// This function does not check if the value exists already, callers must
|
|
|
|
// ensure this themselves if necessary.
|
|
|
|
static Handle<WeakFixedArray> Add(Handle<Object> maybe_array,
|
|
|
|
Handle<HeapObject> value,
|
|
|
|
int* assigned_index = NULL);
|
2014-12-15 19:57:37 +00:00
|
|
|
|
2015-04-27 12:59:55 +00:00
|
|
|
// Returns true if an entry was found and removed.
|
|
|
|
bool Remove(Handle<HeapObject> value);
|
2014-12-15 19:57:37 +00:00
|
|
|
|
2015-08-08 22:56:15 +00:00
|
|
|
class NullCallback {
|
|
|
|
public:
|
|
|
|
static void Callback(Object* value, int old_index, int new_index) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class CompactionCallback>
|
2015-04-22 07:40:05 +00:00
|
|
|
void Compact();
|
|
|
|
|
2014-12-15 19:57:37 +00:00
|
|
|
inline Object* Get(int index) const;
|
2015-04-28 11:13:22 +00:00
|
|
|
inline void Clear(int index);
|
2014-12-15 19:57:37 +00:00
|
|
|
inline int Length() const;
|
|
|
|
|
2015-04-28 11:13:22 +00:00
|
|
|
inline bool IsEmptySlot(int index) const;
|
2016-10-07 13:05:07 +00:00
|
|
|
static Object* Empty() { return Smi::kZero; }
|
2015-04-07 10:42:45 +00:00
|
|
|
|
2015-08-21 08:12:11 +00:00
|
|
|
class Iterator {
|
|
|
|
public:
|
|
|
|
explicit Iterator(Object* maybe_array) : list_(NULL) { Reset(maybe_array); }
|
|
|
|
void Reset(Object* maybe_array);
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
inline T* Next();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int index_;
|
|
|
|
WeakFixedArray* list_;
|
|
|
|
#ifdef DEBUG
|
|
|
|
int last_used_index_;
|
|
|
|
DisallowHeapAllocation no_gc_;
|
|
|
|
#endif // DEBUG
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Iterator);
|
|
|
|
};
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(WeakFixedArray)
|
2014-12-15 19:57:37 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static const int kLastUsedIndexIndex = 0;
|
|
|
|
static const int kFirstIndex = 1;
|
|
|
|
|
|
|
|
static Handle<WeakFixedArray> Allocate(
|
|
|
|
Isolate* isolate, int size, Handle<WeakFixedArray> initialize_from);
|
|
|
|
|
|
|
|
static void Set(Handle<WeakFixedArray> array, int index,
|
|
|
|
Handle<HeapObject> value);
|
|
|
|
inline void clear(int index);
|
|
|
|
|
|
|
|
inline int last_used_index() const;
|
|
|
|
inline void set_last_used_index(int index);
|
|
|
|
|
|
|
|
// Disallow inherited setters.
|
|
|
|
void set(int index, Smi* value);
|
|
|
|
void set(int index, Object* value);
|
|
|
|
void set(int index, Object* value, WriteBarrierMode mode);
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(WeakFixedArray);
|
|
|
|
};
|
|
|
|
|
2015-03-06 12:36:16 +00:00
|
|
|
// Generic array grows dynamically with O(1) amortized insertion.
|
2017-04-04 10:53:43 +00:00
|
|
|
//
|
|
|
|
// ArrayList is a FixedArray with static convenience methods for adding more
|
|
|
|
// elements. The Length() method returns the number of elements in the list, not
|
|
|
|
// the allocated size. The number of elements is stored at kLengthIndex and is
|
|
|
|
// updated with every insertion. The elements of the ArrayList are stored in the
|
|
|
|
// underlying FixedArray starting at kFirstIndex.
|
2015-03-06 12:36:16 +00:00
|
|
|
class ArrayList : public FixedArray {
|
|
|
|
public:
|
2015-03-24 14:35:55 +00:00
|
|
|
enum AddMode {
|
|
|
|
kNone,
|
|
|
|
// Use this if GC can delete elements from the array.
|
|
|
|
kReloadLengthAfterAllocation,
|
|
|
|
};
|
|
|
|
static Handle<ArrayList> Add(Handle<ArrayList> array, Handle<Object> obj,
|
|
|
|
AddMode mode = kNone);
|
2015-03-06 12:36:16 +00:00
|
|
|
static Handle<ArrayList> Add(Handle<ArrayList> array, Handle<Object> obj1,
|
2015-03-24 14:35:55 +00:00
|
|
|
Handle<Object> obj2, AddMode = kNone);
|
2017-02-10 08:21:03 +00:00
|
|
|
static Handle<ArrayList> New(Isolate* isolate, int size);
|
2017-04-04 10:53:43 +00:00
|
|
|
|
|
|
|
// Returns the number of elements in the list, not the allocated size, which
|
|
|
|
// is length(). Lower and upper case length() return different results!
|
2017-04-04 11:29:59 +00:00
|
|
|
inline int Length() const;
|
2017-04-04 10:53:43 +00:00
|
|
|
|
|
|
|
// Sets the Length() as used by Elements(). Does not change the underlying
|
|
|
|
// storage capacity, i.e., length().
|
2015-03-06 12:36:16 +00:00
|
|
|
inline void SetLength(int length);
|
2017-04-04 11:29:59 +00:00
|
|
|
inline Object* Get(int index) const;
|
2015-03-06 12:36:16 +00:00
|
|
|
inline Object** Slot(int index);
|
2017-04-04 10:53:43 +00:00
|
|
|
|
|
|
|
// Set the element at index to obj. The underlying array must be large enough.
|
|
|
|
// If you need to grow the ArrayList, use the static Add() methods instead.
|
2016-06-28 12:34:24 +00:00
|
|
|
inline void Set(int index, Object* obj,
|
|
|
|
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
2017-04-04 10:53:43 +00:00
|
|
|
|
|
|
|
// Set the element at index to undefined. This does not change the Length().
|
2015-03-06 12:36:16 +00:00
|
|
|
inline void Clear(int index, Object* undefined);
|
2017-04-03 14:55:22 +00:00
|
|
|
|
2017-04-04 10:53:43 +00:00
|
|
|
// Return a copy of the list of size Length() without the first entry. The
|
|
|
|
// number returned by Length() is stored in the first entry.
|
2017-04-04 11:29:59 +00:00
|
|
|
Handle<FixedArray> Elements() const;
|
2015-12-09 14:53:11 +00:00
|
|
|
bool IsFull();
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(ArrayList)
|
2015-03-06 12:36:16 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static Handle<ArrayList> EnsureSpace(Handle<ArrayList> array, int length);
|
|
|
|
static const int kLengthIndex = 0;
|
|
|
|
static const int kFirstIndex = 1;
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayList);
|
|
|
|
};
|
|
|
|
|
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
|
|
|
enum SearchMode { ALL_ENTRIES, VALID_ENTRIES };
|
2012-07-05 13:54:20 +00:00
|
|
|
|
2014-11-24 14:31:31 +00:00
|
|
|
template <SearchMode search_mode, typename T>
|
|
|
|
inline int Search(T* array, Name* name, int valid_entries = 0,
|
|
|
|
int* out_insertion_index = NULL);
|
2012-07-05 13:54:20 +00:00
|
|
|
|
2017-06-09 13:53:42 +00:00
|
|
|
// HandlerTable is a fixed array containing entries for exception handlers in
|
|
|
|
// the code object it is associated with. The tables comes in two flavors:
|
|
|
|
// 1) Based on ranges: Used for unoptimized code. Contains one entry per
|
|
|
|
// exception handler and a range representing the try-block covered by that
|
2016-08-02 13:46:54 +00:00
|
|
|
// handler. Layout looks as follows:
|
|
|
|
// [ range-start , range-end , handler-offset , handler-data ]
|
|
|
|
// 2) Based on return addresses: Used for turbofanned code. Contains one entry
|
|
|
|
// per call-site that could throw an exception. Layout looks as follows:
|
|
|
|
// [ return-address-offset , handler-offset ]
|
|
|
|
class HandlerTable : public FixedArray {
|
|
|
|
public:
|
|
|
|
// Conservative prediction whether a given handler will locally catch an
|
|
|
|
// exception or cause a re-throw to outside the code boundary. Since this is
|
|
|
|
// undecidable it is merely an approximation (e.g. useful for debugger).
|
|
|
|
enum CatchPrediction {
|
2016-08-03 11:26:20 +00:00
|
|
|
UNCAUGHT, // The handler will (likely) rethrow the exception.
|
|
|
|
CAUGHT, // The exception will be caught by the handler.
|
|
|
|
PROMISE, // The exception will be caught and cause a promise rejection.
|
|
|
|
DESUGARING, // The exception will be caught, but both the exception and the
|
|
|
|
// catching are part of a desugaring and should therefore not
|
|
|
|
// be visible to the user (we won't notify the debugger of such
|
|
|
|
// exceptions).
|
2016-09-13 20:49:54 +00:00
|
|
|
ASYNC_AWAIT, // The exception will be caught and cause a promise rejection
|
|
|
|
// in the desugaring of an async function, so special
|
|
|
|
// async/await handling in the debugger can take place.
|
2016-08-02 13:46:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Getters for handler table based on ranges.
|
|
|
|
inline int GetRangeStart(int index) const;
|
|
|
|
inline int GetRangeEnd(int index) const;
|
|
|
|
inline int GetRangeHandler(int index) const;
|
|
|
|
inline int GetRangeData(int index) const;
|
|
|
|
|
|
|
|
// Setters for handler table based on ranges.
|
|
|
|
inline void SetRangeStart(int index, int value);
|
|
|
|
inline void SetRangeEnd(int index, int value);
|
|
|
|
inline void SetRangeHandler(int index, int offset, CatchPrediction pred);
|
|
|
|
inline void SetRangeData(int index, int value);
|
|
|
|
|
|
|
|
// Setters for handler table based on return addresses.
|
|
|
|
inline void SetReturnOffset(int index, int value);
|
2016-08-04 08:19:15 +00:00
|
|
|
inline void SetReturnHandler(int index, int offset);
|
2016-08-02 13:46:54 +00:00
|
|
|
|
2016-11-29 09:16:40 +00:00
|
|
|
// Lookup handler in a table based on ranges. The {pc_offset} is an offset to
|
|
|
|
// the start of the potentially throwing instruction (using return addresses
|
|
|
|
// for this value would be invalid).
|
2016-08-02 13:46:54 +00:00
|
|
|
int LookupRange(int pc_offset, int* data, CatchPrediction* prediction);
|
|
|
|
|
|
|
|
// Lookup handler in a table based on return addresses.
|
|
|
|
int LookupReturn(int pc_offset);
|
|
|
|
|
|
|
|
// Returns the number of entries in the table.
|
|
|
|
inline int NumberOfRangeEntries() const;
|
|
|
|
|
|
|
|
// Returns the required length of the underlying fixed array.
|
|
|
|
static int LengthForRange(int entries) { return entries * kRangeEntrySize; }
|
|
|
|
static int LengthForReturn(int entries) { return entries * kReturnEntrySize; }
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(HandlerTable)
|
2016-08-02 13:46:54 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_DISASSEMBLER
|
|
|
|
void HandlerTableRangePrint(std::ostream& os); // NOLINT
|
|
|
|
void HandlerTableReturnPrint(std::ostream& os); // NOLINT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Layout description for handler table based on ranges.
|
|
|
|
static const int kRangeStartIndex = 0;
|
|
|
|
static const int kRangeEndIndex = 1;
|
|
|
|
static const int kRangeHandlerIndex = 2;
|
|
|
|
static const int kRangeDataIndex = 3;
|
|
|
|
static const int kRangeEntrySize = 4;
|
|
|
|
|
|
|
|
// Layout description for handler table based on return addresses.
|
|
|
|
static const int kReturnOffsetIndex = 0;
|
|
|
|
static const int kReturnHandlerIndex = 1;
|
|
|
|
static const int kReturnEntrySize = 2;
|
|
|
|
|
|
|
|
// Encoding of the {handler} field.
|
2016-09-13 20:49:54 +00:00
|
|
|
class HandlerPredictionField : public BitField<CatchPrediction, 0, 3> {};
|
|
|
|
class HandlerOffsetField : public BitField<int, 3, 29> {};
|
2016-08-02 13:46:54 +00:00
|
|
|
};
|
2010-08-25 13:25:54 +00:00
|
|
|
|
2011-09-19 18:36:47 +00:00
|
|
|
// ByteArray represents fixed sized byte arrays. Used for the relocation info
|
|
|
|
// that is attached to code objects.
|
2013-08-20 10:52:23 +00:00
|
|
|
class ByteArray: public FixedArrayBase {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2015-08-13 11:49:01 +00:00
|
|
|
inline int Size();
|
2011-09-19 18:36:47 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Setter and getter.
|
2017-05-31 13:06:28 +00:00
|
|
|
inline byte get(int index) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void set(int index, byte value);
|
|
|
|
|
2016-04-29 12:24:58 +00:00
|
|
|
// Copy in / copy out whole byte slices.
|
|
|
|
inline void copy_out(int index, byte* buffer, int length);
|
|
|
|
inline void copy_in(int index, const byte* buffer, int length);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Treat contents as an int array.
|
2017-05-31 13:06:28 +00:00
|
|
|
inline int get_int(int index) const;
|
2016-04-29 12:24:58 +00:00
|
|
|
inline void set_int(int index, int value);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-05-31 13:06:28 +00:00
|
|
|
inline uint32_t get_uint32(int index) const;
|
|
|
|
inline void set_uint32(int index, uint32_t value);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
static int SizeFor(int length) {
|
2010-05-27 12:30:45 +00:00
|
|
|
return OBJECT_POINTER_ALIGN(kHeaderSize + length);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
// We use byte arrays for free blocks in the heap. Given a desired size in
|
|
|
|
// bytes that is a multiple of the word size and big enough to hold a byte
|
|
|
|
// array, this function returns the number of elements a byte array should
|
|
|
|
// have.
|
|
|
|
static int LengthFor(int size_in_bytes) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(IsAligned(size_in_bytes, kPointerSize));
|
|
|
|
DCHECK(size_in_bytes >= kHeaderSize);
|
2008-07-03 15:10:15 +00:00
|
|
|
return size_in_bytes - kHeaderSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns data start address.
|
|
|
|
inline Address GetDataStartAddress();
|
|
|
|
|
2017-05-31 13:06:28 +00:00
|
|
|
inline int DataSize() const;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Returns a pointer to the ByteArray object for a given data start address.
|
|
|
|
static inline ByteArray* FromDataStartAddress(Address address);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(ByteArray)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2015-08-13 11:49:01 +00:00
|
|
|
inline int ByteArraySize();
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(ByteArray)
|
|
|
|
DECL_VERIFIER(ByteArray)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-05-27 12:30:45 +00:00
|
|
|
// Layout description.
|
|
|
|
static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
|
2009-07-17 12:12:24 +00:00
|
|
|
|
2010-01-07 13:17:18 +00:00
|
|
|
// Maximal memory consumption for a single ByteArray.
|
|
|
|
static const int kMaxSize = 512 * MB;
|
|
|
|
// Maximal length of a single ByteArray.
|
|
|
|
static const int kMaxLength = kMaxSize - kHeaderSize;
|
|
|
|
|
2017-04-27 15:43:54 +00:00
|
|
|
class BodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2017-04-27 15:43:54 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray);
|
|
|
|
};
|
|
|
|
|
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
|
|
|
// Wrapper class for ByteArray which can store arbitrary C++ classes, as long
|
|
|
|
// as they can be copied with memcpy.
|
|
|
|
template <class T>
|
|
|
|
class PodArray : public ByteArray {
|
|
|
|
public:
|
|
|
|
static Handle<PodArray<T>> New(Isolate* isolate, int length,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
|
|
|
void copy_out(int index, T* result) {
|
|
|
|
ByteArray::copy_out(index * sizeof(T), reinterpret_cast<byte*>(result),
|
|
|
|
sizeof(T));
|
|
|
|
}
|
|
|
|
T get(int index) {
|
|
|
|
T result;
|
|
|
|
copy_out(index, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
void set(int index, const T& value) {
|
|
|
|
copy_in(index * sizeof(T), reinterpret_cast<const byte*>(&value),
|
|
|
|
sizeof(T));
|
|
|
|
}
|
|
|
|
int length() { return ByteArray::length() / sizeof(T); }
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(PodArray<T>)
|
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
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(PodArray<T>);
|
|
|
|
};
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-07-24 12:02:41 +00:00
|
|
|
// BytecodeArray represents a sequence of interpreter bytecodes.
|
|
|
|
class BytecodeArray : public FixedArrayBase {
|
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
#define DECL_BYTECODE_AGE_ENUM(X) k##X##BytecodeAge,
|
2016-11-29 12:34:31 +00:00
|
|
|
enum Age {
|
|
|
|
kNoAgeBytecodeAge = 0,
|
2017-06-29 13:14:20 +00:00
|
|
|
CODE_AGE_LIST(DECL_BYTECODE_AGE_ENUM) kAfterLastBytecodeAge,
|
2016-11-29 12:34:31 +00:00
|
|
|
kFirstBytecodeAge = kNoAgeBytecodeAge,
|
|
|
|
kLastBytecodeAge = kAfterLastBytecodeAge - 1,
|
|
|
|
kBytecodeAgeCount = kAfterLastBytecodeAge - kFirstBytecodeAge - 1,
|
|
|
|
kIsOldBytecodeAge = kSexagenarianBytecodeAge
|
|
|
|
};
|
2017-06-29 13:14:20 +00:00
|
|
|
#undef DECL_BYTECODE_AGE_ENUM
|
2016-11-29 12:34:31 +00:00
|
|
|
|
2015-07-24 12:02:41 +00:00
|
|
|
static int SizeFor(int length) {
|
|
|
|
return OBJECT_POINTER_ALIGN(kHeaderSize + length);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setter and getter
|
|
|
|
inline byte get(int index);
|
|
|
|
inline void set(int index, byte value);
|
|
|
|
|
|
|
|
// Returns data start address.
|
|
|
|
inline Address GetFirstBytecodeAddress();
|
|
|
|
|
2015-08-27 10:32:26 +00:00
|
|
|
// Accessors for frame size.
|
2015-07-24 12:02:41 +00:00
|
|
|
inline int frame_size() const;
|
2015-08-27 10:32:26 +00:00
|
|
|
inline void set_frame_size(int frame_size);
|
|
|
|
|
2015-09-10 16:21:34 +00:00
|
|
|
// Accessor for register count (derived from frame_size).
|
|
|
|
inline int register_count() const;
|
|
|
|
|
2015-08-27 10:32:26 +00:00
|
|
|
// Accessors for parameter count (including implicit 'this' receiver).
|
|
|
|
inline int parameter_count() const;
|
|
|
|
inline void set_parameter_count(int number_of_parameters);
|
2015-07-24 12:02:41 +00:00
|
|
|
|
2016-02-19 18:46:54 +00:00
|
|
|
// Accessors for profiling count.
|
|
|
|
inline int interrupt_budget() const;
|
|
|
|
inline void set_interrupt_budget(int interrupt_budget);
|
|
|
|
|
2016-07-25 12:19:20 +00:00
|
|
|
// Accessors for OSR loop nesting level.
|
|
|
|
inline int osr_loop_nesting_level() const;
|
|
|
|
inline void set_osr_loop_nesting_level(int depth);
|
|
|
|
|
2016-11-29 12:34:31 +00:00
|
|
|
// Accessors for bytecode's code age.
|
|
|
|
inline Age bytecode_age() const;
|
|
|
|
inline void set_bytecode_age(Age age);
|
|
|
|
|
2015-08-27 11:11:09 +00:00
|
|
|
// Accessors for the constant pool.
|
|
|
|
DECL_ACCESSORS(constant_pool, FixedArray)
|
|
|
|
|
2016-01-18 17:20:39 +00:00
|
|
|
// Accessors for handler table containing offsets of exception handlers.
|
|
|
|
DECL_ACCESSORS(handler_table, FixedArray)
|
|
|
|
|
2016-01-20 14:16:12 +00:00
|
|
|
// Accessors for source position table containing mappings between byte code
|
2017-05-23 13:01:29 +00:00
|
|
|
// offset and source position or SourcePositionTableWithFrameCache.
|
2017-04-12 18:33:20 +00:00
|
|
|
DECL_ACCESSORS(source_position_table, Object)
|
|
|
|
|
|
|
|
inline ByteArray* SourcePositionTable();
|
2016-01-20 14:16:12 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(BytecodeArray)
|
2015-07-24 12:02:41 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2015-08-13 11:49:01 +00:00
|
|
|
inline int BytecodeArraySize();
|
2015-07-24 12:02:41 +00:00
|
|
|
|
2016-01-28 12:11:55 +00:00
|
|
|
inline int instruction_size();
|
|
|
|
|
2016-05-26 09:46:34 +00:00
|
|
|
// Returns the size of bytecode and its metadata. This includes the size of
|
|
|
|
// bytecode, constant pool, source position table, and handler table.
|
|
|
|
inline int SizeIncludingMetadata();
|
|
|
|
|
2016-01-28 12:11:55 +00:00
|
|
|
int SourcePosition(int offset);
|
2016-02-10 14:19:31 +00:00
|
|
|
int SourceStatementPosition(int offset);
|
2016-01-28 12:11:55 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(BytecodeArray)
|
|
|
|
DECL_VERIFIER(BytecodeArray)
|
2015-07-24 12:02:41 +00:00
|
|
|
|
|
|
|
void Disassemble(std::ostream& os);
|
|
|
|
|
2016-02-22 13:16:46 +00:00
|
|
|
void CopyBytecodesTo(BytecodeArray* to);
|
|
|
|
|
2016-11-29 12:34:31 +00:00
|
|
|
// Bytecode aging
|
|
|
|
bool IsOld() const;
|
|
|
|
void MakeOlder();
|
|
|
|
|
2015-07-24 12:02:41 +00:00
|
|
|
// Layout description.
|
2016-02-19 18:46:54 +00:00
|
|
|
static const int kConstantPoolOffset = FixedArrayBase::kHeaderSize;
|
2016-01-18 17:20:39 +00:00
|
|
|
static const int kHandlerTableOffset = kConstantPoolOffset + kPointerSize;
|
2016-01-20 14:16:12 +00:00
|
|
|
static const int kSourcePositionTableOffset =
|
|
|
|
kHandlerTableOffset + kPointerSize;
|
2016-02-19 18:46:54 +00:00
|
|
|
static const int kFrameSizeOffset = kSourcePositionTableOffset + kPointerSize;
|
|
|
|
static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize;
|
|
|
|
static const int kInterruptBudgetOffset = kParameterSizeOffset + kIntSize;
|
2016-07-25 12:19:20 +00:00
|
|
|
static const int kOSRNestingLevelOffset = kInterruptBudgetOffset + kIntSize;
|
2016-11-29 12:34:31 +00:00
|
|
|
static const int kBytecodeAgeOffset = kOSRNestingLevelOffset + kCharSize;
|
|
|
|
static const int kHeaderSize = kBytecodeAgeOffset + kCharSize;
|
2015-07-24 12:02:41 +00:00
|
|
|
|
|
|
|
// Maximal memory consumption for a single BytecodeArray.
|
|
|
|
static const int kMaxSize = 512 * MB;
|
|
|
|
// Maximal length of a single BytecodeArray.
|
|
|
|
static const int kMaxLength = kMaxSize - kHeaderSize;
|
|
|
|
|
2016-09-30 13:57:27 +00:00
|
|
|
static const int kPointerFieldsBeginOffset = kConstantPoolOffset;
|
|
|
|
static const int kPointerFieldsEndOffset = kFrameSizeOffset;
|
|
|
|
|
2015-11-13 12:32:08 +00:00
|
|
|
class BodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2015-11-13 12:32:08 +00:00
|
|
|
|
2015-07-24 12:02:41 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArray);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-01-24 16:01:15 +00:00
|
|
|
// V has parameters (Type, type, TYPE, C type, element_size)
|
|
|
|
#define TYPED_ARRAYS(V) \
|
|
|
|
V(Uint8, uint8, UINT8, uint8_t, 1) \
|
|
|
|
V(Int8, int8, INT8, int8_t, 1) \
|
|
|
|
V(Uint16, uint16, UINT16, uint16_t, 2) \
|
|
|
|
V(Int16, int16, INT16, int16_t, 2) \
|
|
|
|
V(Uint32, uint32, UINT32, uint32_t, 4) \
|
|
|
|
V(Int32, int32, INT32, int32_t, 4) \
|
|
|
|
V(Float32, float32, FLOAT32, float, 4) \
|
|
|
|
V(Float64, float64, FLOAT64, double, 8) \
|
|
|
|
V(Uint8Clamped, uint8_clamped, UINT8_CLAMPED, uint8_t, 1)
|
|
|
|
|
|
|
|
|
2014-01-16 17:08:45 +00:00
|
|
|
class FixedTypedArrayBase: public FixedArrayBase {
|
|
|
|
public:
|
2015-07-28 09:29:34 +00:00
|
|
|
// [base_pointer]: Either points to the FixedTypedArrayBase itself or nullptr.
|
2015-06-16 07:37:16 +00:00
|
|
|
DECL_ACCESSORS(base_pointer, Object)
|
|
|
|
|
2015-07-28 09:29:34 +00:00
|
|
|
// [external_pointer]: Contains the offset between base_pointer and the start
|
|
|
|
// of the data. If the base_pointer is a nullptr, the external_pointer
|
|
|
|
// therefore points to the actual backing store.
|
2015-07-22 10:25:51 +00:00
|
|
|
DECL_ACCESSORS(external_pointer, void)
|
|
|
|
|
2015-06-16 07:37:16 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(FixedTypedArrayBase)
|
2014-01-16 17:08:45 +00:00
|
|
|
|
2015-07-22 10:25:51 +00:00
|
|
|
static const int kBasePointerOffset = FixedArrayBase::kHeaderSize;
|
|
|
|
static const int kExternalPointerOffset = kBasePointerOffset + kPointerSize;
|
|
|
|
static const int kHeaderSize =
|
|
|
|
DOUBLE_POINTER_ALIGN(kExternalPointerOffset + kPointerSize);
|
2015-06-16 07:37:16 +00:00
|
|
|
|
2015-07-22 10:25:51 +00:00
|
|
|
static const int kDataOffset = kHeaderSize;
|
2014-01-16 17:08:45 +00:00
|
|
|
|
[builtins] Copy array contents using JS in ConstructByArrayLike.
The last CL https://chromium-review.googlesource.com/c/456707/ caused
some pretty heavy performance regressions. After experimenting, it
seems the easiest and most straight-forward way to copy the elements
into the new typed array is to do it in JS.
Adds a fast path for typed arrays, where the source typed array has
the same elements kind, in which case we can just copy the backing
store using memcpy.
This CL also removes regression test 319120 which is from a pwn2own
vulnerability. The old code path enforced a maximum byte_length
that was too low, which this change removes. The length property of
the typed array must be a Smi, but the byte_length, which can be up
to 8x larger than length for a Float64Array, can be a heap number.
We can also re-use some of the logic from ConstructByLength when
deciding whether to allocate the buffer on- or off-heap, so that
is factored out into InitializeBasedOnLength. We can also re-use
the DoInitialize helper instead of calling into the runtime,
meaning we can remove InitializeFromArrayLike.
BUG=v8:5977,chromium:705503,chromium:705394
Change-Id: I63372652091d4bdf3a9491acef9b4e3ac793a755
Reviewed-on: https://chromium-review.googlesource.com/459621
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44301}
2017-03-30 13:16:55 +00:00
|
|
|
static const int kMaxElementSize = 8;
|
|
|
|
|
|
|
|
#ifdef V8_HOST_ARCH_32_BIT
|
|
|
|
static const size_t kMaxByteLength = std::numeric_limits<size_t>::max();
|
|
|
|
#else
|
|
|
|
static const size_t kMaxByteLength =
|
|
|
|
static_cast<size_t>(Smi::kMaxValue) * kMaxElementSize;
|
|
|
|
#endif // V8_HOST_ARCH_32_BIT
|
|
|
|
|
|
|
|
static const size_t kMaxLength = Smi::kMaxValue;
|
|
|
|
|
2015-11-13 12:32:08 +00:00
|
|
|
class BodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2015-11-13 12:32:08 +00:00
|
|
|
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int size() const;
|
2014-01-16 17:08:45 +00:00
|
|
|
|
2015-04-02 11:26:11 +00:00
|
|
|
static inline int TypedArraySize(InstanceType type, int length);
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int TypedArraySize(InstanceType type) const;
|
2014-05-27 13:05:11 +00:00
|
|
|
|
2014-03-26 12:50:13 +00:00
|
|
|
// Use with care: returns raw pointer into heap.
|
|
|
|
inline void* DataPtr();
|
|
|
|
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int DataSize() const;
|
2014-03-26 12:50:13 +00:00
|
|
|
|
2014-01-16 17:08:45 +00:00
|
|
|
private:
|
2017-05-02 13:38:36 +00:00
|
|
|
static inline int ElementSize(InstanceType type);
|
|
|
|
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int DataSize(InstanceType type) const;
|
2014-05-27 13:05:11 +00:00
|
|
|
|
2014-01-16 17:08:45 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class Traits>
|
|
|
|
class FixedTypedArray: public FixedTypedArrayBase {
|
|
|
|
public:
|
|
|
|
typedef typename Traits::ElementType ElementType;
|
2015-01-30 07:19:40 +00:00
|
|
|
static const InstanceType kInstanceType = Traits::kInstanceType;
|
2014-01-16 17:08:45 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(FixedTypedArray<Traits>)
|
2014-01-16 17:08:45 +00:00
|
|
|
|
|
|
|
inline ElementType get_scalar(int index);
|
2016-01-29 18:57:26 +00:00
|
|
|
static inline Handle<Object> get(FixedTypedArray* array, int index);
|
2014-01-16 17:08:45 +00:00
|
|
|
inline void set(int index, ElementType value);
|
|
|
|
|
2017-04-19 12:06:39 +00:00
|
|
|
static inline ElementType from(int value);
|
|
|
|
static inline ElementType from(uint32_t value);
|
|
|
|
static inline ElementType from(double value);
|
2014-03-26 12:50:13 +00:00
|
|
|
|
2014-01-16 17:08:45 +00:00
|
|
|
// This accessor applies the correct conversion from Smi, HeapNumber
|
|
|
|
// and undefined.
|
2015-09-01 21:19:44 +00:00
|
|
|
inline void SetValue(uint32_t index, Object* value);
|
2014-01-16 17:08:45 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(FixedTypedArray)
|
|
|
|
DECL_VERIFIER(FixedTypedArray)
|
2014-01-16 17:08:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray);
|
|
|
|
};
|
|
|
|
|
[builtins] Copy array contents using JS in ConstructByArrayLike.
The last CL https://chromium-review.googlesource.com/c/456707/ caused
some pretty heavy performance regressions. After experimenting, it
seems the easiest and most straight-forward way to copy the elements
into the new typed array is to do it in JS.
Adds a fast path for typed arrays, where the source typed array has
the same elements kind, in which case we can just copy the backing
store using memcpy.
This CL also removes regression test 319120 which is from a pwn2own
vulnerability. The old code path enforced a maximum byte_length
that was too low, which this change removes. The length property of
the typed array must be a Smi, but the byte_length, which can be up
to 8x larger than length for a Float64Array, can be a heap number.
We can also re-use some of the logic from ConstructByLength when
deciding whether to allocate the buffer on- or off-heap, so that
is factored out into InitializeBasedOnLength. We can also re-use
the DoInitialize helper instead of calling into the runtime,
meaning we can remove InitializeFromArrayLike.
BUG=v8:5977,chromium:705503,chromium:705394
Change-Id: I63372652091d4bdf3a9491acef9b4e3ac793a755
Reviewed-on: https://chromium-review.googlesource.com/459621
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44301}
2017-03-30 13:16:55 +00:00
|
|
|
#define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType, size) \
|
|
|
|
STATIC_ASSERT(size <= FixedTypedArrayBase::kMaxElementSize); \
|
|
|
|
class Type##ArrayTraits { \
|
|
|
|
public: /* NOLINT */ \
|
|
|
|
typedef elementType ElementType; \
|
|
|
|
static const InstanceType kInstanceType = FIXED_##TYPE##_ARRAY_TYPE; \
|
|
|
|
static const char* Designator() { return #type " array"; } \
|
|
|
|
static inline Handle<Object> ToHandle(Isolate* isolate, \
|
|
|
|
elementType scalar); \
|
|
|
|
static inline elementType defaultValue(); \
|
|
|
|
}; \
|
|
|
|
\
|
2014-01-16 17:08:45 +00:00
|
|
|
typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array;
|
|
|
|
|
2014-01-24 16:01:15 +00:00
|
|
|
TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS)
|
2014-01-16 17:08:45 +00:00
|
|
|
|
|
|
|
#undef FIXED_TYPED_ARRAY_TRAITS
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// DeoptimizationInputData is a fixed array used to hold the deoptimization
|
2017-04-26 14:54:33 +00:00
|
|
|
// data for optimized code. It also contains information about functions that
|
|
|
|
// were inlined. If N different functions were inlined then first N elements of
|
|
|
|
// the literal array will contain these functions.
|
2010-12-07 11:31:57 +00:00
|
|
|
//
|
|
|
|
// It can be empty.
|
2013-08-20 10:52:23 +00:00
|
|
|
class DeoptimizationInputData: public FixedArray {
|
2010-12-07 11:31:57 +00:00
|
|
|
public:
|
|
|
|
// Layout description. Indices in the array.
|
2014-08-25 07:02:19 +00:00
|
|
|
static const int kTranslationByteArrayIndex = 0;
|
|
|
|
static const int kInlinedFunctionCountIndex = 1;
|
|
|
|
static const int kLiteralArrayIndex = 2;
|
|
|
|
static const int kOsrAstIdIndex = 3;
|
|
|
|
static const int kOsrPcOffsetIndex = 4;
|
|
|
|
static const int kOptimizationIdIndex = 5;
|
|
|
|
static const int kSharedFunctionInfoIndex = 6;
|
2015-01-26 15:31:18 +00:00
|
|
|
static const int kWeakCellCacheIndex = 7;
|
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
|
|
|
static const int kInliningPositionsIndex = 8;
|
|
|
|
static const int kFirstDeoptEntryIndex = 9;
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
// Offsets of deopt entry elements relative to the start of the entry.
|
2012-08-06 14:13:09 +00:00
|
|
|
static const int kAstIdRawOffset = 0;
|
2010-12-07 11:31:57 +00:00
|
|
|
static const int kTranslationIndexOffset = 1;
|
|
|
|
static const int kArgumentsStackHeightOffset = 2;
|
2011-11-16 08:44:30 +00:00
|
|
|
static const int kPcOffset = 3;
|
|
|
|
static const int kDeoptEntrySize = 4;
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
// Simple element accessors.
|
2017-06-29 13:14:20 +00:00
|
|
|
#define DECL_ELEMENT_ACCESSORS(name, type) \
|
|
|
|
inline type* name(); \
|
2015-08-13 11:49:01 +00:00
|
|
|
inline void Set##name(type* value);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray)
|
|
|
|
DECL_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi)
|
|
|
|
DECL_ELEMENT_ACCESSORS(LiteralArray, FixedArray)
|
|
|
|
DECL_ELEMENT_ACCESSORS(OsrAstId, Smi)
|
|
|
|
DECL_ELEMENT_ACCESSORS(OsrPcOffset, Smi)
|
|
|
|
DECL_ELEMENT_ACCESSORS(OptimizationId, Smi)
|
|
|
|
DECL_ELEMENT_ACCESSORS(SharedFunctionInfo, Object)
|
|
|
|
DECL_ELEMENT_ACCESSORS(WeakCellCache, Object)
|
|
|
|
DECL_ELEMENT_ACCESSORS(InliningPositions, PodArray<InliningPosition>)
|
|
|
|
|
|
|
|
#undef DECL_ELEMENT_ACCESSORS
|
|
|
|
|
|
|
|
// Accessors for elements of the ith deoptimization entry.
|
|
|
|
#define DECL_ENTRY_ACCESSORS(name, type) \
|
|
|
|
inline type* name(int i); \
|
2015-08-13 11:49:01 +00:00
|
|
|
inline void Set##name(int i, type* value);
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_ENTRY_ACCESSORS(AstIdRaw, Smi)
|
|
|
|
DECL_ENTRY_ACCESSORS(TranslationIndex, Smi)
|
|
|
|
DECL_ENTRY_ACCESSORS(ArgumentsStackHeight, Smi)
|
|
|
|
DECL_ENTRY_ACCESSORS(Pc, Smi)
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
#undef DECL_ENTRY_ACCESSORS
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline BailoutId AstId(int i);
|
2012-08-06 14:13:09 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline void SetAstId(int i, BailoutId value);
|
2012-08-06 14:13:09 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline int DeoptCount();
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2016-11-22 10:14:36 +00:00
|
|
|
static const int kNotInlinedIndex = -1;
|
|
|
|
|
|
|
|
// Returns the inlined function at the given position in LiteralArray, or the
|
|
|
|
// outer function if index == kNotInlinedIndex.
|
|
|
|
class SharedFunctionInfo* GetInlinedFunction(int index);
|
|
|
|
|
2014-04-08 06:15:20 +00:00
|
|
|
// Allocates a DeoptimizationInputData.
|
2014-04-28 15:33:16 +00:00
|
|
|
static Handle<DeoptimizationInputData> New(Isolate* isolate,
|
|
|
|
int deopt_entry_count,
|
|
|
|
PretenureFlag pretenure);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(DeoptimizationInputData)
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2011-06-29 13:17:02 +00:00
|
|
|
#ifdef ENABLE_DISASSEMBLER
|
2014-09-30 10:29:32 +00:00
|
|
|
void DeoptimizationInputDataPrint(std::ostream& os); // NOLINT
|
2010-12-07 11:31:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
static int IndexForEntry(int i) {
|
|
|
|
return kFirstDeoptEntryIndex + (i * kDeoptEntrySize);
|
|
|
|
}
|
2014-04-08 06:15:20 +00:00
|
|
|
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2014-08-25 07:02:19 +00:00
|
|
|
static int LengthFor(int entry_count) { return IndexForEntry(entry_count); }
|
2010-12-07 11:31:57 +00:00
|
|
|
};
|
|
|
|
|
2016-08-01 14:28:06 +00:00
|
|
|
class TemplateList : public FixedArray {
|
|
|
|
public:
|
|
|
|
static Handle<TemplateList> New(Isolate* isolate, int size);
|
|
|
|
inline int length() const;
|
|
|
|
inline Object* get(int index) const;
|
|
|
|
inline void set(int index, Object* value);
|
|
|
|
static Handle<TemplateList> Add(Isolate* isolate, Handle<TemplateList> list,
|
|
|
|
Handle<Object> value);
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(TemplateList)
|
2016-08-01 14:28:06 +00:00
|
|
|
private:
|
|
|
|
static const int kLengthIndex = 0;
|
|
|
|
static const int kFirstElementIndex = kLengthIndex + 1;
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(TemplateList);
|
|
|
|
};
|
2015-03-25 13:13:51 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Code describes objects with on-the-fly generated machine code.
|
2013-08-20 10:52:23 +00:00
|
|
|
class Code: public HeapObject {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
// Opaque data type for encapsulating code flags like kind, inline
|
|
|
|
// cache state, and arguments count.
|
2013-03-19 13:11:49 +00:00
|
|
|
typedef uint32_t Flags;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-06-25 09:09:25 +00:00
|
|
|
#define NON_IC_KIND_LIST(V) \
|
|
|
|
V(FUNCTION) \
|
|
|
|
V(OPTIMIZED_FUNCTION) \
|
2016-03-09 16:51:02 +00:00
|
|
|
V(BYTECODE_HANDLER) \
|
2013-06-25 09:09:25 +00:00
|
|
|
V(STUB) \
|
2013-09-30 13:53:21 +00:00
|
|
|
V(HANDLER) \
|
2013-06-25 09:09:25 +00:00
|
|
|
V(BUILTIN) \
|
2015-08-25 10:17:26 +00:00
|
|
|
V(REGEXP) \
|
2016-03-04 04:45:22 +00:00
|
|
|
V(WASM_FUNCTION) \
|
|
|
|
V(WASM_TO_JS_FUNCTION) \
|
2017-01-11 10:16:10 +00:00
|
|
|
V(JS_TO_WASM_FUNCTION) \
|
|
|
|
V(WASM_INTERPRETER_ENTRY)
|
2013-06-24 12:55:19 +00:00
|
|
|
|
2013-06-25 09:09:25 +00:00
|
|
|
#define IC_KIND_LIST(V) \
|
|
|
|
V(LOAD_IC) \
|
2016-06-14 13:20:42 +00:00
|
|
|
V(LOAD_GLOBAL_IC) \
|
2013-06-25 09:09:25 +00:00
|
|
|
V(KEYED_LOAD_IC) \
|
|
|
|
V(STORE_IC) \
|
2017-03-23 16:46:53 +00:00
|
|
|
V(STORE_GLOBAL_IC) \
|
2013-06-25 09:09:25 +00:00
|
|
|
V(KEYED_STORE_IC) \
|
2017-06-19 12:22:45 +00:00
|
|
|
V(COMPARE_IC)
|
2013-06-25 09:09:25 +00:00
|
|
|
|
|
|
|
#define CODE_KIND_LIST(V) \
|
|
|
|
NON_IC_KIND_LIST(V) \
|
|
|
|
IC_KIND_LIST(V)
|
2012-07-17 11:58:49 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
enum Kind {
|
2012-07-17 11:58:49 +00:00
|
|
|
#define DEFINE_CODE_KIND_ENUM(name) name,
|
|
|
|
CODE_KIND_LIST(DEFINE_CODE_KIND_ENUM)
|
|
|
|
#undef DEFINE_CODE_KIND_ENUM
|
2013-06-25 09:34:22 +00:00
|
|
|
NUMBER_OF_KINDS
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2012-12-21 07:18:56 +00:00
|
|
|
static const char* Kind2String(Kind kind);
|
|
|
|
|
2013-10-23 13:48:04 +00:00
|
|
|
static const int kPrologueOffsetNotSet = -1;
|
|
|
|
|
2016-10-13 14:06:05 +00:00
|
|
|
#if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER)
|
2008-08-06 10:02:49 +00:00
|
|
|
// Printing
|
2008-09-17 12:38:50 +00:00
|
|
|
static const char* ICState2String(InlineCacheState state);
|
2014-09-30 10:29:32 +00:00
|
|
|
static void PrintExtraICState(std::ostream& os, // NOLINT
|
2014-07-07 09:57:29 +00:00
|
|
|
Kind kind, ExtraICState extra);
|
2016-10-13 14:06:05 +00:00
|
|
|
#endif // defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER)
|
|
|
|
|
|
|
|
#ifdef ENABLE_DISASSEMBLER
|
2014-09-30 10:29:32 +00:00
|
|
|
void Disassemble(const char* name, std::ostream& os); // NOLINT
|
2008-08-06 10:02:49 +00:00
|
|
|
#endif // ENABLE_DISASSEMBLER
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// [instruction_size]: Size of the native instructions
|
2014-06-20 10:31:17 +00:00
|
|
|
inline int instruction_size() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void set_instruction_size(int value);
|
|
|
|
|
2010-07-05 11:45:11 +00:00
|
|
|
// [relocation_info]: Code relocation information
|
|
|
|
DECL_ACCESSORS(relocation_info, ByteArray)
|
2010-12-07 11:31:57 +00:00
|
|
|
void InvalidateRelocation();
|
2013-11-22 13:10:31 +00:00
|
|
|
void InvalidateEmbeddedObjects();
|
2010-12-07 09:11:56 +00:00
|
|
|
|
2011-11-11 13:48:14 +00:00
|
|
|
// [handler_table]: Fixed array containing offsets of exception handlers.
|
|
|
|
DECL_ACCESSORS(handler_table, FixedArray)
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// [deoptimization_data]: Array containing data for deopt.
|
|
|
|
DECL_ACCESSORS(deoptimization_data, FixedArray)
|
|
|
|
|
2017-05-23 13:01:29 +00:00
|
|
|
// [source_position_table]: ByteArray for the source positions table or
|
2017-04-12 18:33:20 +00:00
|
|
|
// SourcePositionTableWithFrameCache.
|
|
|
|
DECL_ACCESSORS(source_position_table, Object)
|
|
|
|
|
2017-07-03 13:29:23 +00:00
|
|
|
inline ByteArray* SourcePositionTable() const;
|
2016-06-28 05:51:09 +00:00
|
|
|
|
2017-03-13 22:12:23 +00:00
|
|
|
// [trap_handler_index]: An index into the trap handler's master list of code
|
|
|
|
// objects.
|
|
|
|
DECL_ACCESSORS(trap_handler_index, Smi)
|
|
|
|
|
2013-11-05 10:05:03 +00:00
|
|
|
// [raw_type_feedback_info]: This field stores various things, depending on
|
|
|
|
// the kind of the code object.
|
2013-09-04 13:53:24 +00:00
|
|
|
// FUNCTION => type feedback information.
|
2014-07-21 13:10:14 +00:00
|
|
|
// STUB and ICs => major/minor key as Smi.
|
2013-11-05 10:05:03 +00:00
|
|
|
DECL_ACCESSORS(raw_type_feedback_info, Object)
|
2017-07-03 13:29:23 +00:00
|
|
|
inline Object* type_feedback_info() const;
|
2013-11-05 10:05:03 +00:00
|
|
|
inline void set_type_feedback_info(
|
|
|
|
Object* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
2017-07-03 13:29:23 +00:00
|
|
|
inline uint32_t stub_key() const;
|
2014-07-21 13:10:14 +00:00
|
|
|
inline void set_stub_key(uint32_t key);
|
2013-07-24 11:12:17 +00:00
|
|
|
|
2013-09-04 13:53:24 +00:00
|
|
|
// [next_code_link]: Link for lists of optimized or deoptimized code.
|
|
|
|
// Note that storage for this field is overlapped with typefeedback_info.
|
|
|
|
DECL_ACCESSORS(next_code_link, Object)
|
2012-01-27 13:03:19 +00:00
|
|
|
|
2012-11-29 07:38:00 +00:00
|
|
|
// [prologue_offset]: Offset of the function prologue, used for aging
|
|
|
|
// FUNCTIONs and OPTIMIZED_FUNCTIONs.
|
2014-06-20 10:31:17 +00:00
|
|
|
inline int prologue_offset() const;
|
2012-11-29 07:38:00 +00:00
|
|
|
inline void set_prologue_offset(int offset);
|
|
|
|
|
2015-06-04 14:44:00 +00:00
|
|
|
// [constant_pool offset]: Offset of the constant pool.
|
|
|
|
// Valid for FLAG_enable_embedded_constant_pool only
|
|
|
|
inline int constant_pool_offset() const;
|
|
|
|
inline void set_constant_pool_offset(int offset);
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Unchecked accessors to be used during GC.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline ByteArray* unchecked_relocation_info() const;
|
2010-07-05 11:45:11 +00:00
|
|
|
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int relocation_size() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// [flags]: Various code flags.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline Flags flags() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void set_flags(Flags flags);
|
|
|
|
|
|
|
|
// [flags]: Access to specific code flags.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline Kind kind() const;
|
|
|
|
inline ExtraICState extra_ic_state() const; // Only valid for IC stubs.
|
2013-05-29 14:49:28 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Testers for IC stub kinds.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool is_inline_cache_stub() const;
|
|
|
|
inline bool is_debug_stub() const;
|
|
|
|
inline bool is_handler() const;
|
|
|
|
inline bool is_stub() const;
|
|
|
|
inline bool is_compare_ic_stub() const;
|
|
|
|
inline bool is_optimized_code() const;
|
|
|
|
inline bool is_wasm_code() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool IsCodeStubOrIC() const;
|
2014-07-21 13:10:14 +00:00
|
|
|
|
2013-12-13 10:27:19 +00:00
|
|
|
inline void set_raw_kind_specific_flags1(int value);
|
|
|
|
inline void set_raw_kind_specific_flags2(int value);
|
|
|
|
|
2016-01-26 12:22:45 +00:00
|
|
|
// Testers for interpreter builtins.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool is_interpreter_trampoline_builtin() const;
|
2016-01-26 12:22:45 +00:00
|
|
|
|
2017-06-15 14:53:38 +00:00
|
|
|
// Tells whether the code checks the optimization marker in the function's
|
|
|
|
// feedback vector.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool checks_optimization_marker() const;
|
2017-06-15 14:53:38 +00:00
|
|
|
|
2014-07-30 13:54:45 +00:00
|
|
|
// [is_crankshafted]: For kind STUB or ICs, tells whether or not a code
|
|
|
|
// object was generated by either the hydrogen or the TurboFan optimizing
|
|
|
|
// compiler (but it may not be an optimized function).
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool is_crankshafted() const;
|
|
|
|
inline bool is_hydrogen_stub() const; // Crankshafted, but not a function.
|
2013-04-18 09:50:46 +00:00
|
|
|
inline void set_is_crankshafted(bool value);
|
|
|
|
|
2017-03-17 07:27:39 +00:00
|
|
|
// [has_tagged_params]: For compiled code or builtins: Tells whether the
|
|
|
|
// outgoing parameters of this code are tagged pointers. True for other kinds.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool has_tagged_params() const;
|
2017-03-17 07:27:39 +00:00
|
|
|
inline void set_has_tagged_params(bool value);
|
|
|
|
|
2014-07-30 13:54:45 +00:00
|
|
|
// [is_turbofanned]: For kind STUB or OPTIMIZED_FUNCTION, tells whether the
|
|
|
|
// code object was generated by the TurboFan optimizing compiler.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool is_turbofanned() const;
|
2014-07-30 13:54:45 +00:00
|
|
|
inline void set_is_turbofanned(bool value);
|
|
|
|
|
2015-01-22 15:30:48 +00:00
|
|
|
// [can_have_weak_objects]: For kind OPTIMIZED_FUNCTION, tells whether the
|
|
|
|
// embedded objects in code should be treated weakly.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool can_have_weak_objects() const;
|
2015-01-22 15:30:48 +00:00
|
|
|
inline void set_can_have_weak_objects(bool value);
|
|
|
|
|
2016-07-11 10:03:02 +00:00
|
|
|
// [is_construct_stub]: For kind BUILTIN, tells whether the code object
|
|
|
|
// represents a hand-written construct stub
|
|
|
|
// (e.g., NumberConstructor_ConstructStub).
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool is_construct_stub() const;
|
2016-07-11 10:03:02 +00:00
|
|
|
inline void set_is_construct_stub(bool value);
|
|
|
|
|
2011-09-13 08:31:21 +00:00
|
|
|
// [has_debug_break_slots]: For FUNCTION kind, tells if it has
|
|
|
|
// been compiled with debug break slots.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool has_debug_break_slots() const;
|
2011-09-13 08:31:21 +00:00
|
|
|
inline void set_has_debug_break_slots(bool value);
|
|
|
|
|
2014-11-20 16:20:48 +00:00
|
|
|
// [has_reloc_info_for_serialization]: For FUNCTION kind, tells if its
|
|
|
|
// reloc info includes runtime and external references to support
|
|
|
|
// serialization/deserialization.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool has_reloc_info_for_serialization() const;
|
2014-11-20 16:20:48 +00:00
|
|
|
inline void set_has_reloc_info_for_serialization(bool value);
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// [allow_osr_at_loop_nesting_level]: For FUNCTION kind, tells for
|
|
|
|
// how long the function has been marked for OSR and therefore which
|
|
|
|
// level of loop nesting we are willing to do on-stack replacement
|
|
|
|
// for.
|
|
|
|
inline void set_allow_osr_at_loop_nesting_level(int level);
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int allow_osr_at_loop_nesting_level() const;
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2016-08-18 14:34:03 +00:00
|
|
|
// [builtin_index]: For builtins, tells which builtin index the code object
|
|
|
|
// has. Note that builtins can have a code kind other than BUILTIN. The
|
|
|
|
// builtin index is a non-negative integer for builtins, and -1 otherwise.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int builtin_index() const;
|
2014-07-16 09:55:34 +00:00
|
|
|
inline void set_builtin_index(int id);
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// [stack_slots]: For kind OPTIMIZED_FUNCTION, the number of stack slots
|
|
|
|
// reserved in the code prologue.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline unsigned stack_slots() const;
|
2010-12-07 11:31:57 +00:00
|
|
|
inline void set_stack_slots(unsigned slots);
|
|
|
|
|
2014-07-30 13:54:45 +00:00
|
|
|
// [safepoint_table_start]: For kind OPTIMIZED_FUNCTION, the offset in
|
2010-12-07 11:31:57 +00:00
|
|
|
// the instruction stream where the safepoint table starts.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline unsigned safepoint_table_offset() const;
|
2011-02-03 10:07:22 +00:00
|
|
|
inline void set_safepoint_table_offset(unsigned offset);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2013-04-10 09:24:31 +00:00
|
|
|
// [back_edge_table_start]: For kind FUNCTION, the offset in the
|
|
|
|
// instruction stream where the back edge table starts.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline unsigned back_edge_table_offset() const;
|
2013-04-10 09:24:31 +00:00
|
|
|
inline void set_back_edge_table_offset(unsigned offset);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool back_edges_patched_for_osr() const;
|
2013-03-12 18:03:18 +00:00
|
|
|
|
2011-07-21 13:51:04 +00:00
|
|
|
// [to_boolean_foo]: For kind TO_BOOLEAN_IC tells what state the stub is in.
|
2015-06-25 04:32:07 +00:00
|
|
|
inline uint16_t to_boolean_state();
|
2011-07-21 13:51:04 +00:00
|
|
|
|
2013-01-24 11:55:05 +00:00
|
|
|
// [marked_for_deoptimization]: For kind OPTIMIZED_FUNCTION tells whether
|
|
|
|
// the code is going to be deoptimized because of dead embedded maps.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool marked_for_deoptimization() const;
|
2013-01-24 11:55:05 +00:00
|
|
|
inline void set_marked_for_deoptimization(bool flag);
|
|
|
|
|
2017-05-23 13:01:29 +00:00
|
|
|
// [deopt_already_counted]: For kind OPTIMIZED_FUNCTION tells whether
|
|
|
|
// the code was already deoptimized.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline bool deopt_already_counted() const;
|
2017-04-10 11:07:57 +00:00
|
|
|
inline void set_deopt_already_counted(bool flag);
|
|
|
|
|
2017-05-23 09:06:51 +00:00
|
|
|
// [is_promise_rejection]: For kind BUILTIN tells whether the
|
|
|
|
// exception thrown by the code will lead to promise rejection or
|
|
|
|
// uncaught if both this and is_exception_caught is set.
|
|
|
|
// Use GetBuiltinCatchPrediction to access this.
|
2016-12-01 21:09:44 +00:00
|
|
|
inline void set_is_promise_rejection(bool flag);
|
|
|
|
|
2017-05-23 09:06:51 +00:00
|
|
|
// [is_exception_caught]: For kind BUILTIN tells whether the
|
|
|
|
// exception thrown by the code will be caught internally or
|
|
|
|
// uncaught if both this and is_promise_rejection is set.
|
|
|
|
// Use GetBuiltinCatchPrediction to access this.
|
2016-12-13 23:54:04 +00:00
|
|
|
inline void set_is_exception_caught(bool flag);
|
|
|
|
|
2013-12-30 11:23:59 +00:00
|
|
|
// [constant_pool]: The constant pool for this function.
|
2015-06-04 14:44:00 +00:00
|
|
|
inline Address constant_pool();
|
2013-12-30 11:23:59 +00:00
|
|
|
|
2011-01-12 14:14:14 +00:00
|
|
|
// Get the safepoint entry for the given pc.
|
|
|
|
SafepointEntry GetSafepointEntry(Address pc);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2013-06-27 13:36:15 +00:00
|
|
|
// Find an object in a stub with a specified map
|
|
|
|
Object* FindNthObject(int n, Map* match_map);
|
|
|
|
|
2014-01-02 15:31:27 +00:00
|
|
|
// Find the first allocation site in an IC stub.
|
|
|
|
AllocationSite* FindFirstAllocationSite();
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Find the first map in an IC stub.
|
|
|
|
Map* FindFirstMap();
|
2013-05-02 15:42:22 +00:00
|
|
|
|
2014-03-18 14:15:09 +00:00
|
|
|
// For each (map-to-find, object-to-replace) pair in the pattern, this
|
|
|
|
// function replaces the corresponding placeholder in the code with the
|
|
|
|
// object-to-replace. The function assumes that pairs in the pattern come in
|
|
|
|
// the same order as the placeholders in the code.
|
2015-02-03 11:26:52 +00:00
|
|
|
// If the placeholder is a weak cell, then the value of weak cell is matched
|
|
|
|
// against the map-to-find.
|
2014-03-18 14:15:09 +00:00
|
|
|
void FindAndReplace(const FindAndReplacePattern& pattern);
|
2013-06-27 13:36:15 +00:00
|
|
|
|
2013-11-05 10:14:48 +00:00
|
|
|
// The entire code object including its header is copied verbatim to the
|
|
|
|
// snapshot so that it can be written in one, fast, memcpy during
|
|
|
|
// deserialization. The deserializer will overwrite some pointers, rather
|
|
|
|
// like a runtime linker, but the random allocation addresses used in the
|
|
|
|
// mksnapshot process would still be present in the unlinked snapshot data,
|
|
|
|
// which would make snapshot production non-reproducible. This method wipes
|
|
|
|
// out the to-be-overwritten header data for reproducible snapshots.
|
|
|
|
inline void WipeOutHeader();
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Flags operations.
|
2011-01-18 16:54:48 +00:00
|
|
|
static inline Flags ComputeFlags(
|
2017-03-15 16:12:02 +00:00
|
|
|
Kind kind, ExtraICState extra_ic_state = kNoExtraICState);
|
2014-02-14 15:15:08 +00:00
|
|
|
|
2017-03-15 16:12:02 +00:00
|
|
|
static inline Flags ComputeHandlerFlags(Kind handler_kind);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-09-12 10:50:50 +00:00
|
|
|
static inline Kind ExtractKindFromFlags(Flags flags);
|
|
|
|
static inline ExtraICState ExtractExtraICStateFromFlags(Flags flags);
|
|
|
|
|
2008-12-09 12:53:59 +00:00
|
|
|
// Convert a target address into a code object.
|
|
|
|
static inline Code* GetCodeFromTargetAddress(Address address);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-08-20 07:10:18 +00:00
|
|
|
// Convert an entry address into an object.
|
|
|
|
static inline Object* GetObjectFromEntryAddress(Address location_of_address);
|
|
|
|
|
2017-06-22 13:47:44 +00:00
|
|
|
// Convert a code entry into an object.
|
|
|
|
static inline Object* GetObjectFromCodeEntry(Address code_entry);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Returns the address of the first instruction.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline byte* instruction_start() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-07-05 11:45:11 +00:00
|
|
|
// Returns the address right after the last instruction.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline byte* instruction_end() const;
|
2010-07-05 11:45:11 +00:00
|
|
|
|
2016-06-27 15:06:32 +00:00
|
|
|
// Returns the size of the instructions, padding, relocation and unwinding
|
|
|
|
// information.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int body_size() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-05-26 09:46:34 +00:00
|
|
|
// Returns the size of code and its metadata. This includes the size of code
|
|
|
|
// relocation information, deoptimization data and handler table.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int SizeIncludingMetadata() const;
|
2016-05-26 09:46:34 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Returns the address of the first relocation info (read backwards!).
|
2017-07-03 13:29:23 +00:00
|
|
|
inline byte* relocation_start() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-06-27 15:06:32 +00:00
|
|
|
// [has_unwinding_info]: Whether this code object has unwinding information.
|
|
|
|
// If it doesn't, unwinding_information_start() will point to invalid data.
|
|
|
|
//
|
|
|
|
// The body of all code objects has the following layout.
|
|
|
|
//
|
|
|
|
// +--------------------------+ <-- instruction_start()
|
|
|
|
// | instructions |
|
|
|
|
// | ... |
|
|
|
|
// +--------------------------+
|
|
|
|
// | relocation info |
|
|
|
|
// | ... |
|
|
|
|
// +--------------------------+ <-- instruction_end()
|
|
|
|
//
|
|
|
|
// If has_unwinding_info() is false, instruction_end() points to the first
|
|
|
|
// memory location after the end of the code object. Otherwise, the body
|
|
|
|
// continues as follows:
|
|
|
|
//
|
|
|
|
// +--------------------------+
|
|
|
|
// | padding to the next |
|
|
|
|
// | 8-byte aligned address |
|
|
|
|
// +--------------------------+ <-- instruction_end()
|
|
|
|
// | [unwinding_info_size] |
|
|
|
|
// | as uint64_t |
|
|
|
|
// +--------------------------+ <-- unwinding_info_start()
|
|
|
|
// | unwinding info |
|
|
|
|
// | ... |
|
|
|
|
// +--------------------------+ <-- unwinding_info_end()
|
|
|
|
//
|
|
|
|
// and unwinding_info_end() points to the first memory location after the end
|
|
|
|
// of the code object.
|
|
|
|
//
|
|
|
|
DECL_BOOLEAN_ACCESSORS(has_unwinding_info)
|
|
|
|
|
|
|
|
// [unwinding_info_size]: Size of the unwinding information.
|
|
|
|
inline int unwinding_info_size() const;
|
|
|
|
inline void set_unwinding_info_size(int value);
|
|
|
|
|
|
|
|
// Returns the address of the unwinding information, if any.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline byte* unwinding_info_start() const;
|
2016-06-27 15:06:32 +00:00
|
|
|
|
|
|
|
// Returns the address right after the end of the unwinding information.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline byte* unwinding_info_end() const;
|
2016-06-27 15:06:32 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Code entry point.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline byte* entry() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Returns true if pc is inside this object's instructions.
|
|
|
|
inline bool contains(byte* pc);
|
|
|
|
|
|
|
|
// Relocate the code by delta bytes. Called to signal that this code
|
|
|
|
// object has been moved by delta bytes.
|
2009-11-11 09:50:06 +00:00
|
|
|
void Relocate(intptr_t delta);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Migrate code described by desc.
|
|
|
|
void CopyFrom(const CodeDesc& desc);
|
|
|
|
|
2010-07-13 13:06:33 +00:00
|
|
|
// Returns the object size for a given body (used for allocation).
|
|
|
|
static int SizeFor(int body_size) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK_SIZE_TAG_ALIGNED(body_size);
|
2010-07-13 13:06:33 +00:00
|
|
|
return RoundUp(kHeaderSize + body_size, kCodeAlignment);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 10:53:08 +00:00
|
|
|
// Calculate the size of the code object to report for log events. This takes
|
|
|
|
// the layout of the code object into account.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int ExecutableSize() const;
|
2009-03-05 10:53:08 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(Code)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-07-03 13:29:23 +00:00
|
|
|
inline int CodeSize() const;
|
2012-12-13 10:17:37 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(Code)
|
|
|
|
DECL_VERIFIER(Code)
|
2012-10-12 11:41:14 +00:00
|
|
|
|
2012-03-26 13:08:08 +00:00
|
|
|
void ClearInlineCaches();
|
2013-11-06 15:45:43 +00:00
|
|
|
|
2013-09-04 12:55:59 +00:00
|
|
|
BailoutId TranslatePcOffsetToAstId(uint32_t pc_offset);
|
2013-12-23 14:30:35 +00:00
|
|
|
uint32_t TranslateAstIdToPcOffset(BailoutId ast_id);
|
2013-09-04 12:55:59 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
#define DECL_CODE_AGE_ENUM(X) k##X##CodeAge,
|
2012-11-08 12:18:11 +00:00
|
|
|
enum Age {
|
2015-04-30 12:31:38 +00:00
|
|
|
kToBeExecutedOnceCodeAge = -3,
|
2013-10-23 13:48:04 +00:00
|
|
|
kNotExecutedCodeAge = -2,
|
|
|
|
kExecutedOnceCodeAge = -1,
|
2013-10-24 10:50:35 +00:00
|
|
|
kNoAgeCodeAge = 0,
|
2017-06-29 13:14:20 +00:00
|
|
|
CODE_AGE_LIST(DECL_CODE_AGE_ENUM) kAfterLastCodeAge,
|
2015-04-30 12:31:38 +00:00
|
|
|
kFirstCodeAge = kToBeExecutedOnceCodeAge,
|
2012-11-08 12:18:11 +00:00
|
|
|
kLastCodeAge = kAfterLastCodeAge - 1,
|
2015-04-30 12:31:38 +00:00
|
|
|
kCodeAgeCount = kAfterLastCodeAge - kFirstCodeAge - 1,
|
2013-10-23 13:48:04 +00:00
|
|
|
kIsOldCodeAge = kSexagenarianCodeAge,
|
|
|
|
kPreAgedCodeAge = kIsOldCodeAge - 1
|
2012-11-08 12:18:11 +00:00
|
|
|
};
|
2017-06-29 13:14:20 +00:00
|
|
|
#undef DECL_CODE_AGE_ENUM
|
2012-11-08 12:18:11 +00:00
|
|
|
|
2013-06-19 17:00:01 +00:00
|
|
|
// Code aging. Indicates how many full GCs this code has survived without
|
2017-05-22 08:54:28 +00:00
|
|
|
// being entered through the prologue. Used to determine when to flush code
|
|
|
|
// held in the compilation cache.
|
2013-09-13 10:23:04 +00:00
|
|
|
static void MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate);
|
2013-10-23 13:48:04 +00:00
|
|
|
static void MarkCodeAsExecuted(byte* sequence, Isolate* isolate);
|
2014-11-25 12:03:27 +00:00
|
|
|
void MakeYoung(Isolate* isolate);
|
2016-03-14 18:55:41 +00:00
|
|
|
void PreAge(Isolate* isolate);
|
2015-04-30 12:31:38 +00:00
|
|
|
void MarkToBeExecutedOnce(Isolate* isolate);
|
2016-11-29 12:09:56 +00:00
|
|
|
void MakeOlder();
|
2014-05-06 11:25:37 +00:00
|
|
|
static bool IsYoungSequence(Isolate* isolate, byte* sequence);
|
2012-11-08 12:18:11 +00:00
|
|
|
bool IsOld();
|
2013-10-23 13:48:04 +00:00
|
|
|
Age GetAge();
|
|
|
|
static inline Code* GetPreAgedCodeAgeStub(Isolate* isolate) {
|
2016-11-29 12:09:56 +00:00
|
|
|
return GetCodeAgeStub(isolate, kNotExecutedCodeAge);
|
2013-10-23 13:48:04 +00:00
|
|
|
}
|
2012-11-08 12:18:11 +00:00
|
|
|
|
2015-03-09 14:43:29 +00:00
|
|
|
void PrintDeoptLocation(FILE* out, Address pc);
|
2013-07-02 15:15:58 +00:00
|
|
|
bool CanDeoptAt(Address pc);
|
2012-12-20 11:53:42 +00:00
|
|
|
|
2017-05-23 09:06:51 +00:00
|
|
|
inline HandlerTable::CatchPrediction GetBuiltinCatchPrediction();
|
2013-02-04 10:56:50 +00:00
|
|
|
#ifdef VERIFY_HEAP
|
2013-10-04 07:25:24 +00:00
|
|
|
void VerifyEmbeddedObjectsDependency();
|
2013-02-04 10:56:50 +00:00
|
|
|
#endif
|
|
|
|
|
2014-10-31 09:30:59 +00:00
|
|
|
#ifdef DEBUG
|
2015-02-03 17:46:15 +00:00
|
|
|
enum VerifyMode { kNoContextSpecificPointers, kNoContextRetainingPointers };
|
|
|
|
void VerifyEmbeddedObjects(VerifyMode mode = kNoContextRetainingPointers);
|
2015-08-03 09:14:19 +00:00
|
|
|
static void VerifyRecompiledCode(Code* old_code, Code* new_code);
|
2014-10-31 09:30:59 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool CanContainWeakObjects();
|
2014-04-11 10:36:09 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool IsWeakObject(Object* object);
|
2014-02-19 14:03:48 +00:00
|
|
|
|
2014-04-08 10:00:57 +00:00
|
|
|
static inline bool IsWeakObjectInOptimizedCode(Object* object);
|
2013-10-04 07:25:24 +00:00
|
|
|
|
2015-01-26 15:31:18 +00:00
|
|
|
static Handle<WeakCell> WeakCellFor(Handle<Code> code);
|
|
|
|
WeakCell* CachedWeakCell();
|
|
|
|
|
2015-06-04 14:44:00 +00:00
|
|
|
static const int kConstantPoolSize =
|
|
|
|
FLAG_enable_embedded_constant_pool ? kIntSize : 0;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Layout description.
|
2014-10-27 18:24:05 +00:00
|
|
|
static const int kRelocationInfoOffset = HeapObject::kHeaderSize;
|
2011-11-11 13:48:14 +00:00
|
|
|
static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize;
|
2010-12-07 11:31:57 +00:00
|
|
|
static const int kDeoptimizationDataOffset =
|
2011-11-11 13:48:14 +00:00
|
|
|
kHandlerTableOffset + kPointerSize;
|
2016-06-28 05:51:09 +00:00
|
|
|
static const int kSourcePositionTableOffset =
|
|
|
|
kDeoptimizationDataOffset + kPointerSize;
|
2014-07-21 13:10:14 +00:00
|
|
|
// For FUNCTION kind, we store the type feedback info here.
|
2012-02-20 12:57:23 +00:00
|
|
|
static const int kTypeFeedbackInfoOffset =
|
2016-06-28 05:51:09 +00:00
|
|
|
kSourcePositionTableOffset + kPointerSize;
|
2017-01-31 02:25:57 +00:00
|
|
|
static const int kNextCodeLinkOffset = kTypeFeedbackInfoOffset + kPointerSize;
|
2017-05-22 08:54:28 +00:00
|
|
|
static const int kInstructionSizeOffset = kNextCodeLinkOffset + kPointerSize;
|
2017-06-27 12:17:37 +00:00
|
|
|
static const int kFlagsOffset = kInstructionSizeOffset + kIntSize;
|
2012-07-06 22:08:27 +00:00
|
|
|
static const int kKindSpecificFlags1Offset = kFlagsOffset + kIntSize;
|
|
|
|
static const int kKindSpecificFlags2Offset =
|
|
|
|
kKindSpecificFlags1Offset + kIntSize;
|
2012-11-29 07:38:00 +00:00
|
|
|
// Note: We might be able to squeeze this into the flags above.
|
|
|
|
static const int kPrologueOffset = kKindSpecificFlags2Offset + kIntSize;
|
2015-02-19 09:56:06 +00:00
|
|
|
static const int kConstantPoolOffset = kPrologueOffset + kIntSize;
|
2016-03-22 13:25:05 +00:00
|
|
|
static const int kBuiltinIndexOffset =
|
2015-06-04 14:44:00 +00:00
|
|
|
kConstantPoolOffset + kConstantPoolSize;
|
2017-03-13 22:12:23 +00:00
|
|
|
static const int kTrapHandlerIndex = kBuiltinIndexOffset + kIntSize;
|
|
|
|
static const int kHeaderPaddingStart = kTrapHandlerIndex + kPointerSize;
|
2016-11-30 22:31:37 +00:00
|
|
|
|
|
|
|
enum TrapFields { kTrapCodeOffset, kTrapLandingOffset, kTrapDataSize };
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2009-05-18 12:13:20 +00:00
|
|
|
// Add padding to align the instruction start following right after
|
2009-02-27 11:19:31 +00:00
|
|
|
// the Code object header.
|
2009-05-18 12:13:20 +00:00
|
|
|
static const int kHeaderSize =
|
2010-12-07 11:31:57 +00:00
|
|
|
(kHeaderPaddingStart + kCodeAlignmentMask) & ~kCodeAlignmentMask;
|
2008-07-30 08:49:36 +00:00
|
|
|
|
2016-06-27 15:06:32 +00:00
|
|
|
inline int GetUnwindingInfoSizeOffset() const;
|
|
|
|
|
2015-11-13 12:32:08 +00:00
|
|
|
class BodyDescriptor;
|
|
|
|
|
2011-09-12 10:50:50 +00:00
|
|
|
// Flags layout. BitField<type, shift, size>.
|
2016-07-22 13:18:50 +00:00
|
|
|
class HasUnwindingInfoField : public BitField<bool, 0, 1> {};
|
2017-03-15 16:12:02 +00:00
|
|
|
class KindField : public BitField<Kind, HasUnwindingInfoField::kNext, 5> {};
|
2016-06-14 13:20:42 +00:00
|
|
|
STATIC_ASSERT(NUMBER_OF_KINDS <= KindField::kMax);
|
2016-08-18 08:05:36 +00:00
|
|
|
class ExtraICStateField
|
|
|
|
: public BitField<ExtraICState, KindField::kNext,
|
|
|
|
PlatformSmiTagging::kSmiValueSize - KindField::kNext> {
|
|
|
|
};
|
2010-03-01 16:24:05 +00:00
|
|
|
|
2017-06-09 12:32:27 +00:00
|
|
|
// KindSpecificFlags1 layout (FUNCTION)
|
|
|
|
static const int kFullCodeFlags = kKindSpecificFlags1Offset;
|
2017-06-13 13:56:11 +00:00
|
|
|
static const int kFullCodeFlagsHasDebugBreakSlotsField = 0;
|
|
|
|
static const int kFullCodeFlagsHasRelocInfoForSerialization = 1;
|
2017-06-09 12:32:27 +00:00
|
|
|
class FullCodeFlagsHasDebugBreakSlotsField
|
|
|
|
: public BitField<bool, kFullCodeFlagsHasDebugBreakSlotsField, 1> {};
|
|
|
|
class FullCodeFlagsHasRelocInfoForSerialization
|
|
|
|
: public BitField<bool, kFullCodeFlagsHasRelocInfoForSerialization, 1> {};
|
|
|
|
|
2016-03-22 13:25:05 +00:00
|
|
|
// KindSpecificFlags1 layout (STUB, BUILTIN and OPTIMIZED_FUNCTION)
|
2012-07-06 22:08:27 +00:00
|
|
|
static const int kStackSlotsFirstBit = 0;
|
|
|
|
static const int kStackSlotsBitCount = 24;
|
2015-11-23 10:34:04 +00:00
|
|
|
static const int kMarkedForDeoptimizationBit =
|
2012-07-06 22:08:27 +00:00
|
|
|
kStackSlotsFirstBit + kStackSlotsBitCount;
|
2017-04-10 11:07:57 +00:00
|
|
|
static const int kDeoptAlreadyCountedBit = kMarkedForDeoptimizationBit + 1;
|
|
|
|
static const int kIsTurbofannedBit = kDeoptAlreadyCountedBit + 1;
|
2015-01-22 15:30:48 +00:00
|
|
|
static const int kCanHaveWeakObjects = kIsTurbofannedBit + 1;
|
2016-07-11 10:03:02 +00:00
|
|
|
// Could be moved to overlap previous bits when we need more space.
|
|
|
|
static const int kIsConstructStub = kCanHaveWeakObjects + 1;
|
2016-12-01 21:09:44 +00:00
|
|
|
static const int kIsPromiseRejection = kIsConstructStub + 1;
|
2016-12-13 23:54:04 +00:00
|
|
|
static const int kIsExceptionCaught = kIsPromiseRejection + 1;
|
2012-07-06 22:08:27 +00:00
|
|
|
|
|
|
|
STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32);
|
2016-12-13 23:54:04 +00:00
|
|
|
STATIC_ASSERT(kIsExceptionCaught + 1 <= 32);
|
2012-07-06 22:08:27 +00:00
|
|
|
|
|
|
|
class StackSlotsField: public BitField<int,
|
|
|
|
kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT
|
2014-07-30 13:54:45 +00:00
|
|
|
class MarkedForDeoptimizationField
|
2015-11-23 10:34:04 +00:00
|
|
|
: public BitField<bool, kMarkedForDeoptimizationBit, 1> {}; // NOLINT
|
2017-04-10 11:07:57 +00:00
|
|
|
class DeoptAlreadyCountedField
|
|
|
|
: public BitField<bool, kDeoptAlreadyCountedBit, 1> {}; // NOLINT
|
2014-07-30 13:54:45 +00:00
|
|
|
class IsTurbofannedField : public BitField<bool, kIsTurbofannedBit, 1> {
|
|
|
|
}; // NOLINT
|
2015-01-22 15:30:48 +00:00
|
|
|
class CanHaveWeakObjectsField
|
|
|
|
: public BitField<bool, kCanHaveWeakObjects, 1> {}; // NOLINT
|
2016-07-11 10:03:02 +00:00
|
|
|
class IsConstructStubField : public BitField<bool, kIsConstructStub, 1> {
|
|
|
|
}; // NOLINT
|
2016-12-01 21:09:44 +00:00
|
|
|
class IsPromiseRejectionField
|
|
|
|
: public BitField<bool, kIsPromiseRejection, 1> {}; // NOLINT
|
2016-12-13 23:54:04 +00:00
|
|
|
class IsExceptionCaughtField : public BitField<bool, kIsExceptionCaught, 1> {
|
|
|
|
}; // NOLINT
|
2012-07-06 22:08:27 +00:00
|
|
|
|
2013-04-18 09:50:46 +00:00
|
|
|
// KindSpecificFlags2 layout (ALL)
|
|
|
|
static const int kIsCrankshaftedBit = 0;
|
2017-03-17 07:27:39 +00:00
|
|
|
class IsCrankshaftedField : public BitField<bool, kIsCrankshaftedBit, 1> {};
|
|
|
|
static const int kHasTaggedStackBit = kIsCrankshaftedBit + 1;
|
|
|
|
class HasTaggedStackField : public BitField<bool, kHasTaggedStackBit, 1> {};
|
2013-04-18 09:50:46 +00:00
|
|
|
|
2012-07-06 22:08:27 +00:00
|
|
|
// KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION)
|
2017-03-17 07:27:39 +00:00
|
|
|
static const int kSafepointTableOffsetFirstBit = kHasTaggedStackBit + 1;
|
2015-07-30 08:17:15 +00:00
|
|
|
static const int kSafepointTableOffsetBitCount = 30;
|
2012-07-06 22:08:27 +00:00
|
|
|
|
|
|
|
STATIC_ASSERT(kSafepointTableOffsetFirstBit +
|
|
|
|
kSafepointTableOffsetBitCount <= 32);
|
2014-07-21 13:10:14 +00:00
|
|
|
STATIC_ASSERT(1 + kSafepointTableOffsetBitCount <= 32);
|
2012-07-06 22:08:27 +00:00
|
|
|
|
|
|
|
class SafepointTableOffsetField: public BitField<int,
|
|
|
|
kSafepointTableOffsetFirstBit,
|
|
|
|
kSafepointTableOffsetBitCount> {}; // NOLINT
|
|
|
|
|
|
|
|
// KindSpecificFlags2 layout (FUNCTION)
|
2013-04-18 09:50:46 +00:00
|
|
|
class BackEdgeTableOffsetField: public BitField<int,
|
2014-06-24 09:31:30 +00:00
|
|
|
kIsCrankshaftedBit + 1, 27> {}; // NOLINT
|
|
|
|
class AllowOSRAtLoopNestingLevelField: public BitField<int,
|
|
|
|
kIsCrankshaftedBit + 1 + 27, 4> {}; // NOLINT
|
2012-07-06 22:08:27 +00:00
|
|
|
|
2014-02-14 15:14:34 +00:00
|
|
|
static const int kArgumentsBits = 16;
|
2013-03-18 13:35:17 +00:00
|
|
|
static const int kMaxArguments = (1 << kArgumentsBits) - 1;
|
2009-05-25 18:29:02 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
2012-11-08 12:18:11 +00:00
|
|
|
friend class RelocIterator;
|
2014-02-28 12:41:25 +00:00
|
|
|
friend class Deoptimizer; // For FindCodeAgeSequence.
|
2012-11-08 12:18:11 +00:00
|
|
|
|
|
|
|
// Code aging
|
|
|
|
byte* FindCodeAgeSequence();
|
2016-11-29 12:09:56 +00:00
|
|
|
static Age GetCodeAge(Isolate* isolate, byte* sequence);
|
|
|
|
static Age GetAgeOfCodeAgeStub(Code* code);
|
|
|
|
static Code* GetCodeAgeStub(Isolate* isolate, Age age);
|
2012-11-08 12:18:11 +00:00
|
|
|
|
|
|
|
// Code aging -- platform-specific
|
2016-11-29 12:09:56 +00:00
|
|
|
static void PatchPlatformCodeAge(Isolate* isolate, byte* sequence, Age age);
|
2012-11-08 12:18:11 +00:00
|
|
|
|
2017-07-03 13:29:23 +00:00
|
|
|
bool is_promise_rejection() const;
|
|
|
|
bool is_exception_caught() const;
|
2017-05-23 09:06:51 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
|
|
|
|
};
|
|
|
|
|
2016-01-28 12:11:55 +00:00
|
|
|
class AbstractCode : public HeapObject {
|
|
|
|
public:
|
2016-02-26 11:04:04 +00:00
|
|
|
// All code kinds and INTERPRETED_FUNCTION.
|
|
|
|
enum Kind {
|
|
|
|
#define DEFINE_CODE_KIND_ENUM(name) name,
|
|
|
|
CODE_KIND_LIST(DEFINE_CODE_KIND_ENUM)
|
|
|
|
#undef DEFINE_CODE_KIND_ENUM
|
|
|
|
INTERPRETED_FUNCTION,
|
2016-05-26 09:46:34 +00:00
|
|
|
NUMBER_OF_KINDS
|
2016-02-26 11:04:04 +00:00
|
|
|
};
|
|
|
|
|
2016-05-26 09:46:34 +00:00
|
|
|
static const char* Kind2String(Kind kind);
|
|
|
|
|
2016-01-28 12:11:55 +00:00
|
|
|
int SourcePosition(int offset);
|
2016-02-10 14:19:31 +00:00
|
|
|
int SourceStatementPosition(int offset);
|
2016-01-28 12:11:55 +00:00
|
|
|
|
2016-02-26 11:04:04 +00:00
|
|
|
// Returns the address of the first instruction.
|
|
|
|
inline Address instruction_start();
|
|
|
|
|
|
|
|
// Returns the address right after the last instruction.
|
|
|
|
inline Address instruction_end();
|
|
|
|
|
2016-05-26 09:46:34 +00:00
|
|
|
// Returns the size of the code instructions.
|
2016-02-26 11:04:04 +00:00
|
|
|
inline int instruction_size();
|
|
|
|
|
2016-06-29 12:02:39 +00:00
|
|
|
// Return the source position table.
|
|
|
|
inline ByteArray* source_position_table();
|
|
|
|
|
2016-08-17 09:31:24 +00:00
|
|
|
// Set the source position table.
|
|
|
|
inline void set_source_position_table(ByteArray* source_position_table);
|
|
|
|
|
2017-04-12 18:33:20 +00:00
|
|
|
inline Object* stack_frame_cache();
|
|
|
|
static void SetStackFrameCache(Handle<AbstractCode> abstract_code,
|
|
|
|
Handle<UnseededNumberDictionary> cache);
|
|
|
|
void DropStackFrameCache();
|
|
|
|
|
2016-05-26 09:46:34 +00:00
|
|
|
// Returns the size of instructions and the metadata.
|
|
|
|
inline int SizeIncludingMetadata();
|
|
|
|
|
2016-02-26 11:04:04 +00:00
|
|
|
// Returns true if pc is inside this object's instructions.
|
|
|
|
inline bool contains(byte* pc);
|
|
|
|
|
|
|
|
// Returns the AbstractCode::Kind of the code.
|
|
|
|
inline Kind kind();
|
|
|
|
|
|
|
|
// Calculate the size of the code object to report for log events. This takes
|
|
|
|
// the layout of the code object into account.
|
|
|
|
inline int ExecutableSize();
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(AbstractCode)
|
2016-01-28 12:11:55 +00:00
|
|
|
inline Code* GetCode();
|
|
|
|
inline BytecodeArray* GetBytecodeArray();
|
2016-07-25 12:19:20 +00:00
|
|
|
|
|
|
|
// Max loop nesting marker used to postpose OSR. We don't take loop
|
|
|
|
// nesting that is deeper than 5 levels into account.
|
|
|
|
static const int kMaxLoopNestingMarker = 6;
|
|
|
|
STATIC_ASSERT(Code::AllowOSRAtLoopNestingLevelField::kMax >=
|
|
|
|
kMaxLoopNestingMarker);
|
2016-01-28 12:11:55 +00:00
|
|
|
};
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-11-23 09:30:17 +00:00
|
|
|
// Dependent code is a singly linked list of fixed arrays. Each array contains
|
|
|
|
// code objects in weak cells for one dependent group. The suffix of the array
|
|
|
|
// can be filled with the undefined value if the number of codes is less than
|
|
|
|
// the length of the array.
|
2013-02-20 11:49:54 +00:00
|
|
|
//
|
2015-11-23 09:30:17 +00:00
|
|
|
// +------+-----------------+--------+--------+-----+--------+-----------+-----+
|
|
|
|
// | next | count & group 1 | code 1 | code 2 | ... | code n | undefined | ... |
|
|
|
|
// +------+-----------------+--------+--------+-----+--------+-----------+-----+
|
|
|
|
// |
|
|
|
|
// V
|
|
|
|
// +------+-----------------+--------+--------+-----+--------+-----------+-----+
|
|
|
|
// | next | count & group 2 | code 1 | code 2 | ... | code m | undefined | ... |
|
|
|
|
// +------+-----------------+--------+--------+-----+--------+-----------+-----+
|
|
|
|
// |
|
|
|
|
// V
|
|
|
|
// empty_fixed_array()
|
2013-02-20 11:49:54 +00:00
|
|
|
//
|
2015-11-23 09:30:17 +00:00
|
|
|
// The list of fixed arrays is ordered by dependency groups.
|
2013-02-20 11:49:54 +00:00
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class DependentCode: public FixedArray {
|
2013-01-24 11:55:05 +00:00
|
|
|
public:
|
2013-02-20 11:49:54 +00:00
|
|
|
enum DependencyGroup {
|
|
|
|
// Group of code that weakly embed this map and depend on being
|
|
|
|
// deoptimized when the map is garbage collected.
|
2014-04-11 10:36:09 +00:00
|
|
|
kWeakCodeGroup,
|
2013-04-26 15:30:41 +00:00
|
|
|
// Group of code that embed a transition to this map, and depend on being
|
|
|
|
// deoptimized when the transition is replaced by a new version.
|
|
|
|
kTransitionGroup,
|
2013-02-20 11:49:54 +00:00
|
|
|
// Group of code that omit run-time prototype checks for prototypes
|
|
|
|
// described by this map. The group is deoptimized whenever an object
|
|
|
|
// described by this map changes shape (and transitions to a new map),
|
|
|
|
// possibly invalidating the assumptions embedded in the code.
|
|
|
|
kPrototypeCheckGroup,
|
2013-06-26 16:17:12 +00:00
|
|
|
// Group of code that depends on global property values in property cells
|
|
|
|
// not being changed.
|
|
|
|
kPropertyCellChangedGroup,
|
2016-10-12 11:10:58 +00:00
|
|
|
// Group of code that omit run-time checks for field(s) introduced by
|
|
|
|
// this map, i.e. for the field type.
|
|
|
|
kFieldOwnerGroup,
|
2014-05-23 09:30:47 +00:00
|
|
|
// Group of code that omit run-time type checks for initial maps of
|
|
|
|
// constructors.
|
|
|
|
kInitialMapChangedGroup,
|
2013-11-14 12:05:09 +00:00
|
|
|
// Group of code that depends on tenuring information in AllocationSites
|
|
|
|
// not being changed.
|
|
|
|
kAllocationSiteTenuringChangedGroup,
|
|
|
|
// Group of code that depends on element transition information in
|
|
|
|
// AllocationSites not being changed.
|
2014-08-25 15:41:09 +00:00
|
|
|
kAllocationSiteTransitionChangedGroup
|
2013-02-20 11:49:54 +00:00
|
|
|
};
|
|
|
|
|
2014-08-25 15:41:09 +00:00
|
|
|
static const int kGroupCount = kAllocationSiteTransitionChangedGroup + 1;
|
2016-07-25 17:41:56 +00:00
|
|
|
static const int kNextLinkIndex = 0;
|
|
|
|
static const int kFlagsIndex = 1;
|
|
|
|
static const int kCodesStartIndex = 2;
|
2014-08-25 15:41:09 +00:00
|
|
|
|
2015-02-12 13:21:06 +00:00
|
|
|
bool Contains(DependencyGroup group, WeakCell* code_cell);
|
2015-11-23 09:30:17 +00:00
|
|
|
bool IsEmpty(DependencyGroup group);
|
2015-02-12 13:21:06 +00:00
|
|
|
|
2015-04-20 15:22:02 +00:00
|
|
|
static Handle<DependentCode> InsertCompilationDependencies(
|
2015-02-12 13:21:06 +00:00
|
|
|
Handle<DependentCode> entries, DependencyGroup group,
|
|
|
|
Handle<Foreign> info);
|
|
|
|
|
|
|
|
static Handle<DependentCode> InsertWeakCode(Handle<DependentCode> entries,
|
|
|
|
DependencyGroup group,
|
|
|
|
Handle<WeakCell> code_cell);
|
|
|
|
|
|
|
|
void UpdateToFinishedCode(DependencyGroup group, Foreign* info,
|
|
|
|
WeakCell* code_cell);
|
|
|
|
|
2015-04-20 15:22:02 +00:00
|
|
|
void RemoveCompilationDependencies(DependentCode::DependencyGroup group,
|
|
|
|
Foreign* info);
|
2013-06-12 09:43:22 +00:00
|
|
|
|
2013-03-18 13:57:49 +00:00
|
|
|
void DeoptimizeDependentCodeGroup(Isolate* isolate,
|
|
|
|
DependentCode::DependencyGroup group);
|
2013-02-20 11:49:54 +00:00
|
|
|
|
2014-01-16 10:00:03 +00:00
|
|
|
bool MarkCodeForDeoptimization(Isolate* isolate,
|
|
|
|
DependentCode::DependencyGroup group);
|
|
|
|
|
2013-02-20 11:49:54 +00:00
|
|
|
// The following low-level accessors should only be used by this class
|
|
|
|
// and the mark compact collector.
|
2015-11-23 09:30:17 +00:00
|
|
|
inline DependentCode* next_link();
|
|
|
|
inline void set_next_link(DependentCode* next);
|
|
|
|
inline int count();
|
|
|
|
inline void set_count(int value);
|
|
|
|
inline DependencyGroup group();
|
|
|
|
inline void set_group(DependencyGroup group);
|
2013-06-12 09:43:22 +00:00
|
|
|
inline Object* object_at(int i);
|
2015-02-12 13:21:06 +00:00
|
|
|
inline void set_object_at(int i, Object* object);
|
2013-06-12 09:43:22 +00:00
|
|
|
inline void clear_at(int i);
|
|
|
|
inline void copy(int from, int to);
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(DependentCode)
|
2013-02-20 11:49:54 +00:00
|
|
|
|
2014-08-19 10:56:49 +00:00
|
|
|
static const char* DependencyGroupName(DependencyGroup group);
|
|
|
|
static void SetMarkedForDeoptimization(Code* code, DependencyGroup group);
|
|
|
|
|
2013-01-24 11:55:05 +00:00
|
|
|
private:
|
2015-02-12 13:21:06 +00:00
|
|
|
static Handle<DependentCode> Insert(Handle<DependentCode> entries,
|
|
|
|
DependencyGroup group,
|
|
|
|
Handle<Object> object);
|
2015-11-23 09:30:17 +00:00
|
|
|
static Handle<DependentCode> New(DependencyGroup group, Handle<Object> object,
|
|
|
|
Handle<DependentCode> next);
|
2015-02-12 13:21:06 +00:00
|
|
|
static Handle<DependentCode> EnsureSpace(Handle<DependentCode> entries);
|
|
|
|
// Compact by removing cleared weak cells and return true if there was
|
|
|
|
// any cleared weak cell.
|
|
|
|
bool Compact();
|
|
|
|
static int Grow(int number_of_entries) {
|
|
|
|
if (number_of_entries < 5) return number_of_entries + 1;
|
|
|
|
return number_of_entries * 5 / 4;
|
|
|
|
}
|
2015-11-23 09:30:17 +00:00
|
|
|
inline int flags();
|
|
|
|
inline void set_flags(int flags);
|
|
|
|
class GroupField : public BitField<int, 0, 3> {};
|
|
|
|
class CountField : public BitField<int, 3, 27> {};
|
|
|
|
STATIC_ASSERT(kGroupCount <= GroupField::kMax + 1);
|
2013-01-24 11:55:05 +00:00
|
|
|
};
|
|
|
|
|
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)
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2016-10-12 20:45:28 +00:00
|
|
|
// A container struct to hold state required for PromiseResolveThenableJob.
|
2016-10-12 22:18:54 +00:00
|
|
|
class PromiseResolveThenableJobInfo : public Struct {
|
2016-09-21 03:49:32 +00:00
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(thenable, JSReceiver)
|
2016-09-21 23:55:36 +00:00
|
|
|
DECL_ACCESSORS(then, JSReceiver)
|
2016-09-21 03:49:32 +00:00
|
|
|
DECL_ACCESSORS(resolve, JSFunction)
|
|
|
|
DECL_ACCESSORS(reject, JSFunction)
|
2017-01-03 21:43:38 +00:00
|
|
|
|
2016-11-11 20:59:25 +00:00
|
|
|
DECL_ACCESSORS(context, Context)
|
2016-09-21 03:49:32 +00:00
|
|
|
|
|
|
|
static const int kThenableOffset = Struct::kHeaderSize;
|
|
|
|
static const int kThenOffset = kThenableOffset + kPointerSize;
|
|
|
|
static const int kResolveOffset = kThenOffset + kPointerSize;
|
|
|
|
static const int kRejectOffset = kResolveOffset + kPointerSize;
|
[inspector] change target promise for kDebugWillHandle & kDebugDidHandle
- kDebugPromiseCreated(task, parent_task)
This event occurs when promise is created (PromiseHookType::Init). V8Debugger uses this event to maintain task -> parent task map.
- kDebugEnqueueAsyncFunction(task)
This event occurs when first internal promise for async function is created. V8Debugger collects stack trace at this point.
- kDebugEnqueuePromiseResolve(task),
This event occurs when Promise fulfills with resolved status. V8Debugger collects stack trace at this point.
- kDebugEnqueuePromiseReject(task),
This event occurs when Promise fulfills with rejected status. V8Debugger collects stack trace at this point.
- kDebugPromiseCollected,
This event occurs when Promise is collected and no other chained callbacks can be added. V8Debugger removes information about async task for this promise.
- kDebugWillHandle,
This event occurs when chained promise function (either resolve or reject handler) is called. V8Debugger installs parent promise's stack (based on task -> parent_task map) as current if available or current promise's scheduled stack otherwise.
- kDebugDidHandle,
This event occurs after chained promise function has finished. V8Debugger restores asynchronous call chain to previous one.
With this change all instrumentation calls are related to current promise (before WillHandle and DidHandle were related to next async task).
Before V8Debugger supported only the following:
- asyncTaskScheduled(task1)
- asyncTaskStarted(task1)
- asyncTaskFinished(task1)
Now V8Debugger supports the following:
- asyncTaskScheduled(parent_task)
..
- asyncTaskCreated(task, parent_task),
- asyncTaskStarted(task), uses parent_task scheduled stack
- asyncTaskScheduled(task)
- asyncTaskFinished(task)
Additionally: WillHandle and DidHandle were migrated to PromiseHook API.
More details: https://docs.google.com/document/d/1u19N45f1gSF7M39mGsycJEK3IPyJgIXCBnWyiPeuJFE
BUG=v8:5738
R=dgozman@chromium.org,gsathya@chromium.org,yangguo@chromium.org
Review-Url: https://codereview.chromium.org/2650803003
Cr-Commit-Position: refs/heads/master@{#42644}
2017-01-25 07:05:43 +00:00
|
|
|
static const int kContextOffset = kRejectOffset + kPointerSize;
|
2016-11-11 20:59:25 +00:00
|
|
|
static const int kSize = kContextOffset + kPointerSize;
|
2016-09-21 03:49:32 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(PromiseResolveThenableJobInfo)
|
|
|
|
DECL_PRINTER(PromiseResolveThenableJobInfo)
|
|
|
|
DECL_VERIFIER(PromiseResolveThenableJobInfo)
|
2016-09-21 03:49:32 +00:00
|
|
|
|
|
|
|
private:
|
2016-10-12 22:18:54 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(PromiseResolveThenableJobInfo);
|
2016-09-21 03:49:32 +00:00
|
|
|
};
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-12-15 15:50:54 +00:00
|
|
|
class JSPromise;
|
|
|
|
|
2016-10-12 20:45:28 +00:00
|
|
|
// Struct to hold state required for PromiseReactionJob.
|
|
|
|
class PromiseReactionJobInfo : public Struct {
|
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(value, Object)
|
|
|
|
DECL_ACCESSORS(tasks, Object)
|
2016-12-29 20:30:28 +00:00
|
|
|
|
|
|
|
// Check comment in JSPromise for information on what state these
|
|
|
|
// deferred fields could be in.
|
|
|
|
DECL_ACCESSORS(deferred_promise, Object)
|
|
|
|
DECL_ACCESSORS(deferred_on_resolve, Object)
|
|
|
|
DECL_ACCESSORS(deferred_on_reject, Object)
|
2017-01-03 21:43:38 +00:00
|
|
|
|
|
|
|
DECL_INT_ACCESSORS(debug_id)
|
|
|
|
|
2016-10-12 20:45:28 +00:00
|
|
|
DECL_ACCESSORS(context, Context)
|
|
|
|
|
2017-01-12 22:06:55 +00:00
|
|
|
static const int kValueOffset = Struct::kHeaderSize;
|
2016-10-12 20:45:28 +00:00
|
|
|
static const int kTasksOffset = kValueOffset + kPointerSize;
|
2016-12-29 20:30:28 +00:00
|
|
|
static const int kDeferredPromiseOffset = kTasksOffset + kPointerSize;
|
|
|
|
static const int kDeferredOnResolveOffset =
|
|
|
|
kDeferredPromiseOffset + kPointerSize;
|
|
|
|
static const int kDeferredOnRejectOffset =
|
|
|
|
kDeferredOnResolveOffset + kPointerSize;
|
[inspector] change target promise for kDebugWillHandle & kDebugDidHandle
- kDebugPromiseCreated(task, parent_task)
This event occurs when promise is created (PromiseHookType::Init). V8Debugger uses this event to maintain task -> parent task map.
- kDebugEnqueueAsyncFunction(task)
This event occurs when first internal promise for async function is created. V8Debugger collects stack trace at this point.
- kDebugEnqueuePromiseResolve(task),
This event occurs when Promise fulfills with resolved status. V8Debugger collects stack trace at this point.
- kDebugEnqueuePromiseReject(task),
This event occurs when Promise fulfills with rejected status. V8Debugger collects stack trace at this point.
- kDebugPromiseCollected,
This event occurs when Promise is collected and no other chained callbacks can be added. V8Debugger removes information about async task for this promise.
- kDebugWillHandle,
This event occurs when chained promise function (either resolve or reject handler) is called. V8Debugger installs parent promise's stack (based on task -> parent_task map) as current if available or current promise's scheduled stack otherwise.
- kDebugDidHandle,
This event occurs after chained promise function has finished. V8Debugger restores asynchronous call chain to previous one.
With this change all instrumentation calls are related to current promise (before WillHandle and DidHandle were related to next async task).
Before V8Debugger supported only the following:
- asyncTaskScheduled(task1)
- asyncTaskStarted(task1)
- asyncTaskFinished(task1)
Now V8Debugger supports the following:
- asyncTaskScheduled(parent_task)
..
- asyncTaskCreated(task, parent_task),
- asyncTaskStarted(task), uses parent_task scheduled stack
- asyncTaskScheduled(task)
- asyncTaskFinished(task)
Additionally: WillHandle and DidHandle were migrated to PromiseHook API.
More details: https://docs.google.com/document/d/1u19N45f1gSF7M39mGsycJEK3IPyJgIXCBnWyiPeuJFE
BUG=v8:5738
R=dgozman@chromium.org,gsathya@chromium.org,yangguo@chromium.org
Review-Url: https://codereview.chromium.org/2650803003
Cr-Commit-Position: refs/heads/master@{#42644}
2017-01-25 07:05:43 +00:00
|
|
|
static const int kContextOffset = kDeferredOnRejectOffset + kPointerSize;
|
2016-10-12 20:45:28 +00:00
|
|
|
static const int kSize = kContextOffset + kPointerSize;
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(PromiseReactionJobInfo)
|
|
|
|
DECL_PRINTER(PromiseReactionJobInfo)
|
|
|
|
DECL_VERIFIER(PromiseReactionJobInfo)
|
2016-10-12 20:45:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(PromiseReactionJobInfo);
|
|
|
|
};
|
|
|
|
|
[async-iteration] implement AsyncGenerator
- Introduce new struct AsyncGeneratorRequest, which holds
information pertinent to resuming execution of an
AsyncGenerator, such as the Promise associated with the async
generator request. It is intended to be used as a singly
linked list, and holds a pointer to the next item in te queue.
- Introduce JSAsyncGeneratorObject (subclass of
JSGeneratorObject), which includes several new internal fields
(`queue` which contains a singly linked list of
AsyncGeneratorRequest objects, and `await_input` which
contains the sent value from an Await expression (This is
necessary to prevent function.sent (used by yield*) from
having the sent value observably overwritten during
execution).
- Modify SuspendGenerator to accept a set of Flags, which
indicate whether the suspend is for a Yield or Await, and
whether it takes place on an async generator or ES6
generator.
- Introduce interpreter intrinsics and TF intrinsic lowering for
accessing the await input of an async generator
- Modify the JSGeneratorStore operator to understand whether or
not it's suspending for a normal yield, or an AsyncGenerator
Await. This ensures appropriate registers are stored.
- Add versions of ResumeGeneratorTrampoline which store the
input value in a different field depending on wether it's an
AsyncGenerator Await resume, or an ordinary resume. Also modifies
whether debug code will assert that the generator object is a
JSGeneratorObject or a JSAsyncGeneratorObject depending on the
resume type.
BUG=v8:5855
R=bmeurer@chromium.org, rmcilroy@chromium.org, jgruber@chromium.org,
littledan@chromium.org, neis@chromium.org
TBR=marja@chromium.org
Change-Id: I9d58df1d344465fc937fe7eed322424204497187
Reviewed-on: https://chromium-review.googlesource.com/446961
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44240}
2017-03-29 13:41:45 +00:00
|
|
|
class AsyncGeneratorRequest : public Struct {
|
|
|
|
public:
|
|
|
|
// Holds an AsyncGeneratorRequest, or Undefined.
|
|
|
|
DECL_ACCESSORS(next, Object)
|
|
|
|
DECL_INT_ACCESSORS(resume_mode)
|
|
|
|
DECL_ACCESSORS(value, Object)
|
|
|
|
DECL_ACCESSORS(promise, Object)
|
|
|
|
|
|
|
|
static const int kNextOffset = Struct::kHeaderSize;
|
|
|
|
static const int kResumeModeOffset = kNextOffset + kPointerSize;
|
|
|
|
static const int kValueOffset = kResumeModeOffset + kPointerSize;
|
|
|
|
static const int kPromiseOffset = kValueOffset + kPointerSize;
|
|
|
|
static const int kSize = kPromiseOffset + kPointerSize;
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(AsyncGeneratorRequest)
|
|
|
|
DECL_PRINTER(AsyncGeneratorRequest)
|
|
|
|
DECL_VERIFIER(AsyncGeneratorRequest)
|
[async-iteration] implement AsyncGenerator
- Introduce new struct AsyncGeneratorRequest, which holds
information pertinent to resuming execution of an
AsyncGenerator, such as the Promise associated with the async
generator request. It is intended to be used as a singly
linked list, and holds a pointer to the next item in te queue.
- Introduce JSAsyncGeneratorObject (subclass of
JSGeneratorObject), which includes several new internal fields
(`queue` which contains a singly linked list of
AsyncGeneratorRequest objects, and `await_input` which
contains the sent value from an Await expression (This is
necessary to prevent function.sent (used by yield*) from
having the sent value observably overwritten during
execution).
- Modify SuspendGenerator to accept a set of Flags, which
indicate whether the suspend is for a Yield or Await, and
whether it takes place on an async generator or ES6
generator.
- Introduce interpreter intrinsics and TF intrinsic lowering for
accessing the await input of an async generator
- Modify the JSGeneratorStore operator to understand whether or
not it's suspending for a normal yield, or an AsyncGenerator
Await. This ensures appropriate registers are stored.
- Add versions of ResumeGeneratorTrampoline which store the
input value in a different field depending on wether it's an
AsyncGenerator Await resume, or an ordinary resume. Also modifies
whether debug code will assert that the generator object is a
JSGeneratorObject or a JSAsyncGeneratorObject depending on the
resume type.
BUG=v8:5855
R=bmeurer@chromium.org, rmcilroy@chromium.org, jgruber@chromium.org,
littledan@chromium.org, neis@chromium.org
TBR=marja@chromium.org
Change-Id: I9d58df1d344465fc937fe7eed322424204497187
Reviewed-on: https://chromium-review.googlesource.com/446961
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44240}
2017-03-29 13:41:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(AsyncGeneratorRequest);
|
|
|
|
};
|
|
|
|
|
2015-04-07 10:42:45 +00:00
|
|
|
// Container for metadata stored on each prototype map.
|
|
|
|
class PrototypeInfo : public Struct {
|
|
|
|
public:
|
2015-08-08 22:56:15 +00:00
|
|
|
static const int UNREGISTERED = -1;
|
|
|
|
|
2016-10-17 11:44:37 +00:00
|
|
|
// [weak_cell]: A WeakCell containing this prototype. ICs cache the cell here.
|
|
|
|
DECL_ACCESSORS(weak_cell, Object)
|
|
|
|
|
2015-04-07 10:42:45 +00:00
|
|
|
// [prototype_users]: WeakFixedArray containing maps using this prototype,
|
|
|
|
// or Smi(0) if uninitialized.
|
|
|
|
DECL_ACCESSORS(prototype_users, Object)
|
2016-06-23 12:16:35 +00:00
|
|
|
|
|
|
|
// [object_create_map]: A field caching the map for Object.create(prototype).
|
|
|
|
static inline void SetObjectCreateMap(Handle<PrototypeInfo> info,
|
|
|
|
Handle<Map> map);
|
|
|
|
inline Map* ObjectCreateMap();
|
|
|
|
inline bool HasObjectCreateMap();
|
|
|
|
|
2015-08-08 22:56:15 +00:00
|
|
|
// [registry_slot]: Slot in prototype's user registry where this user
|
|
|
|
// is stored. Returns UNREGISTERED if this prototype has not been registered.
|
|
|
|
inline int registry_slot() const;
|
|
|
|
inline void set_registry_slot(int slot);
|
2015-04-07 10:42:45 +00:00
|
|
|
// [validity_cell]: Cell containing the validity bit for prototype chains
|
|
|
|
// going through this object, or Smi(0) if uninitialized.
|
2015-09-24 14:09:41 +00:00
|
|
|
// When a prototype object changes its map, then both its own validity cell
|
|
|
|
// and those of all "downstream" prototypes are invalidated; handlers for a
|
|
|
|
// given receiver embed the currently valid cell for that receiver's prototype
|
|
|
|
// during their compilation and check it on execution.
|
2015-04-07 10:42:45 +00:00
|
|
|
DECL_ACCESSORS(validity_cell, Object)
|
2016-06-08 14:43:22 +00:00
|
|
|
// [bit_field]
|
|
|
|
inline int bit_field() const;
|
|
|
|
inline void set_bit_field(int bit_field);
|
|
|
|
|
|
|
|
DECL_BOOLEAN_ACCESSORS(should_be_fast_map)
|
2015-04-07 10:42:45 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(PrototypeInfo)
|
2015-04-07 10:42:45 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(PrototypeInfo)
|
|
|
|
DECL_VERIFIER(PrototypeInfo)
|
2015-04-07 10:42:45 +00:00
|
|
|
|
2016-10-17 11:44:37 +00:00
|
|
|
static const int kWeakCellOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kPrototypeUsersOffset = kWeakCellOffset + kPointerSize;
|
2015-08-08 22:56:15 +00:00
|
|
|
static const int kRegistrySlotOffset = kPrototypeUsersOffset + kPointerSize;
|
|
|
|
static const int kValidityCellOffset = kRegistrySlotOffset + kPointerSize;
|
2016-06-23 12:16:35 +00:00
|
|
|
static const int kObjectCreateMap = kValidityCellOffset + kPointerSize;
|
|
|
|
static const int kBitFieldOffset = kObjectCreateMap + kPointerSize;
|
2016-06-08 14:43:22 +00:00
|
|
|
static const int kSize = kBitFieldOffset + kPointerSize;
|
|
|
|
|
|
|
|
// Bit field usage.
|
|
|
|
static const int kShouldBeFastBit = 0;
|
2015-04-07 10:42:45 +00:00
|
|
|
|
|
|
|
private:
|
2016-06-23 12:16:35 +00:00
|
|
|
DECL_ACCESSORS(object_create_map, Object)
|
|
|
|
|
2015-04-07 10:42:45 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo);
|
|
|
|
};
|
|
|
|
|
2016-12-02 10:03:18 +00:00
|
|
|
class Tuple2 : public Struct {
|
2016-10-13 16:18:53 +00:00
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(value1, Object)
|
|
|
|
DECL_ACCESSORS(value2, Object)
|
2016-12-02 10:03:18 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(Tuple2)
|
2016-12-02 10:03:18 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(Tuple2)
|
|
|
|
DECL_VERIFIER(Tuple2)
|
2016-12-02 10:03:18 +00:00
|
|
|
|
|
|
|
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:
|
2016-10-13 16:18:53 +00:00
|
|
|
DECL_ACCESSORS(value3, Object)
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(Tuple3)
|
2016-10-13 16:18:53 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(Tuple3)
|
|
|
|
DECL_VERIFIER(Tuple3)
|
2016-10-13 16:18:53 +00:00
|
|
|
|
2016-12-02 10:03:18 +00:00
|
|
|
static const int kValue3Offset = Tuple2::kSize;
|
2016-10-13 16:18:53 +00:00
|
|
|
static const int kSize = kValue3Offset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Tuple3);
|
|
|
|
};
|
2015-04-07 10:42:45 +00:00
|
|
|
|
[es6] Parameter scopes for sloppy eval
This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,
let x = 1;
function f(g = () => x) {
var y
eval("var x = 2")
return g() + x // f() = 3
}
we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:
- Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.
- When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).
- While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.
- Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.
- Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.
- In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.
- In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.
- ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.
- Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.
- While at it, refactor and unify some respective code in the debugger.
Sorry, this CL is large. I could try to split it up, but everything is rather entangled.
@mstarzinger: Please review the changes to contexts.
@yangguo: Please have a look at the debugger stuff.
R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
BUG=v8:811,v8:2160
LOG=N
Review URL: https://codereview.chromium.org/1292753007
Cr-Commit-Position: refs/heads/master@{#30295}
2015-08-21 10:58:35 +00:00
|
|
|
// Pair used to store both a ScopeInfo and an extension object in the extension
|
2016-09-01 15:03:44 +00:00
|
|
|
// slot of a block, catch, or with context. Needed in the rare case where a
|
|
|
|
// declaration block scope (a "varblock" as used to desugar parameter
|
|
|
|
// destructuring) also contains a sloppy direct eval, or for with and catch
|
|
|
|
// scopes. (In no other case both are needed at the same time.)
|
|
|
|
class ContextExtension : public Struct {
|
[es6] Parameter scopes for sloppy eval
This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,
let x = 1;
function f(g = () => x) {
var y
eval("var x = 2")
return g() + x // f() = 3
}
we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:
- Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.
- When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).
- While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.
- Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.
- Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.
- In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.
- In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.
- ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.
- Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.
- While at it, refactor and unify some respective code in the debugger.
Sorry, this CL is large. I could try to split it up, but everything is rather entangled.
@mstarzinger: Please review the changes to contexts.
@yangguo: Please have a look at the debugger stuff.
R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
BUG=v8:811,v8:2160
LOG=N
Review URL: https://codereview.chromium.org/1292753007
Cr-Commit-Position: refs/heads/master@{#30295}
2015-08-21 10:58:35 +00:00
|
|
|
public:
|
|
|
|
// [scope_info]: Scope info.
|
|
|
|
DECL_ACCESSORS(scope_info, ScopeInfo)
|
|
|
|
// [extension]: Extension object.
|
2016-09-01 15:03:44 +00:00
|
|
|
DECL_ACCESSORS(extension, Object)
|
[es6] Parameter scopes for sloppy eval
This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,
let x = 1;
function f(g = () => x) {
var y
eval("var x = 2")
return g() + x // f() = 3
}
we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:
- Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.
- When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).
- While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.
- Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.
- Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.
- In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.
- In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.
- ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.
- Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.
- While at it, refactor and unify some respective code in the debugger.
Sorry, this CL is large. I could try to split it up, but everything is rather entangled.
@mstarzinger: Please review the changes to contexts.
@yangguo: Please have a look at the debugger stuff.
R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
BUG=v8:811,v8:2160
LOG=N
Review URL: https://codereview.chromium.org/1292753007
Cr-Commit-Position: refs/heads/master@{#30295}
2015-08-21 10:58:35 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(ContextExtension)
|
[es6] Parameter scopes for sloppy eval
This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,
let x = 1;
function f(g = () => x) {
var y
eval("var x = 2")
return g() + x // f() = 3
}
we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:
- Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.
- When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).
- While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.
- Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.
- Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.
- In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.
- In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.
- ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.
- Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.
- While at it, refactor and unify some respective code in the debugger.
Sorry, this CL is large. I could try to split it up, but everything is rather entangled.
@mstarzinger: Please review the changes to contexts.
@yangguo: Please have a look at the debugger stuff.
R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
BUG=v8:811,v8:2160
LOG=N
Review URL: https://codereview.chromium.org/1292753007
Cr-Commit-Position: refs/heads/master@{#30295}
2015-08-21 10:58:35 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(ContextExtension)
|
|
|
|
DECL_VERIFIER(ContextExtension)
|
[es6] Parameter scopes for sloppy eval
This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,
let x = 1;
function f(g = () => x) {
var y
eval("var x = 2")
return g() + x // f() = 3
}
we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:
- Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.
- When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).
- While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.
- Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.
- Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.
- In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.
- In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.
- ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.
- Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.
- While at it, refactor and unify some respective code in the debugger.
Sorry, this CL is large. I could try to split it up, but everything is rather entangled.
@mstarzinger: Please review the changes to contexts.
@yangguo: Please have a look at the debugger stuff.
R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
BUG=v8:811,v8:2160
LOG=N
Review URL: https://codereview.chromium.org/1292753007
Cr-Commit-Position: refs/heads/master@{#30295}
2015-08-21 10:58:35 +00:00
|
|
|
|
|
|
|
static const int kScopeInfoOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kExtensionOffset = kScopeInfoOffset + kPointerSize;
|
|
|
|
static const int kSize = kExtensionOffset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
2016-09-01 15:03:44 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(ContextExtension);
|
[es6] Parameter scopes for sloppy eval
This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,
let x = 1;
function f(g = () => x) {
var y
eval("var x = 2")
return g() + x // f() = 3
}
we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:
- Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.
- When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).
- While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.
- Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.
- Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.
- In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.
- In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.
- ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.
- Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.
- While at it, refactor and unify some respective code in the debugger.
Sorry, this CL is large. I could try to split it up, but everything is rather entangled.
@mstarzinger: Please review the changes to contexts.
@yangguo: Please have a look at the debugger stuff.
R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
BUG=v8:811,v8:2160
LOG=N
Review URL: https://codereview.chromium.org/1292753007
Cr-Commit-Position: refs/heads/master@{#30295}
2015-08-21 10:58:35 +00:00
|
|
|
};
|
|
|
|
|
2010-12-14 18:53:48 +00:00
|
|
|
// List of builtin functions we want to identify to improve code
|
|
|
|
// generation.
|
|
|
|
//
|
|
|
|
// Each entry has a name of a global object property holding an object
|
|
|
|
// optionally followed by ".prototype", a name of a builtin function
|
|
|
|
// on the object (the one the id is set for), and a label.
|
|
|
|
//
|
|
|
|
// Installation of ids for the selected builtin functions is handled
|
|
|
|
// by the bootstrapper.
|
2016-03-01 18:16:33 +00:00
|
|
|
#define FUNCTIONS_WITH_ID_LIST(V) \
|
2017-01-20 08:56:33 +00:00
|
|
|
V(Array, isArray, ArrayIsArray) \
|
2016-11-28 08:00:48 +00:00
|
|
|
V(Array.prototype, concat, ArrayConcat) \
|
|
|
|
V(Array.prototype, every, ArrayEvery) \
|
|
|
|
V(Array.prototype, fill, ArrayFill) \
|
|
|
|
V(Array.prototype, filter, ArrayFilter) \
|
|
|
|
V(Array.prototype, findIndex, ArrayFindIndex) \
|
|
|
|
V(Array.prototype, forEach, ArrayForEach) \
|
|
|
|
V(Array.prototype, includes, ArrayIncludes) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Array.prototype, indexOf, ArrayIndexOf) \
|
2016-11-28 08:00:48 +00:00
|
|
|
V(Array.prototype, join, ArrayJoin) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Array.prototype, lastIndexOf, ArrayLastIndexOf) \
|
2016-11-28 08:00:48 +00:00
|
|
|
V(Array.prototype, map, ArrayMap) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Array.prototype, pop, ArrayPop) \
|
2016-11-28 08:00:48 +00:00
|
|
|
V(Array.prototype, push, ArrayPush) \
|
|
|
|
V(Array.prototype, reverse, ArrayReverse) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Array.prototype, shift, ArrayShift) \
|
2016-11-28 08:00:48 +00:00
|
|
|
V(Array.prototype, slice, ArraySlice) \
|
|
|
|
V(Array.prototype, some, ArraySome) \
|
|
|
|
V(Array.prototype, splice, ArraySplice) \
|
|
|
|
V(Array.prototype, unshift, ArrayUnshift) \
|
2016-11-24 06:41:25 +00:00
|
|
|
V(Date, now, DateNow) \
|
2016-08-29 10:53:25 +00:00
|
|
|
V(Date.prototype, getDate, DateGetDate) \
|
2016-08-30 10:05:40 +00:00
|
|
|
V(Date.prototype, getDay, DateGetDay) \
|
2016-08-29 10:53:25 +00:00
|
|
|
V(Date.prototype, getFullYear, DateGetFullYear) \
|
|
|
|
V(Date.prototype, getHours, DateGetHours) \
|
|
|
|
V(Date.prototype, getMilliseconds, DateGetMilliseconds) \
|
2016-08-30 10:05:40 +00:00
|
|
|
V(Date.prototype, getMinutes, DateGetMinutes) \
|
2016-08-29 10:53:25 +00:00
|
|
|
V(Date.prototype, getMonth, DateGetMonth) \
|
|
|
|
V(Date.prototype, getSeconds, DateGetSeconds) \
|
|
|
|
V(Date.prototype, getTime, DateGetTime) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Function.prototype, apply, FunctionApply) \
|
2017-06-02 12:30:04 +00:00
|
|
|
V(Function.prototype, bind, FunctionBind) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Function.prototype, call, FunctionCall) \
|
2017-01-20 08:56:33 +00:00
|
|
|
V(Object, assign, ObjectAssign) \
|
|
|
|
V(Object, create, ObjectCreate) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Object.prototype, hasOwnProperty, ObjectHasOwnProperty) \
|
[builtins] Properly optimize Object.prototype.isPrototypeOf.
Port the baseline implementation of Object.prototype.isPrototypeOf to
the CodeStubAssembler, sharing the existing prototype chain lookup logic
with the instanceof / OrdinaryHasInstance implementation. Based on that,
do the same in TurboFan, introducing a new JSHasInPrototypeChain
operator, which encapsulates the central prototype chain walk logic.
This speeds up Object.prototype.isPrototypeOf by more than a factor of
four, so that the code
A.prototype.isPrototypeOf(a)
is now performance-wise on par with
a instanceof A
for the case where A is a regular constructor function and a is an
instance of A.
Since instanceof does more than just the fundamental prototype chain
lookup, it was discovered in Node core that O.p.isPrototypeOf would
be a more appropriate alternative for certain sanity checks, since
it's less vulnerable to monkey-patching. In addition, the Object
builtin would also avoid the performance-cliff associated with
instanceof (due to the Symbol.hasInstance hook), as for example hit
by https://github.com/nodejs/node/pull/13403#issuecomment-305915874.
The main blocker was the missing performance of isPrototypeOf, since
it was still a JS builtin backed by a runtime call.
This CL also adds more test coverage for the
Object.prototype.isPrototypeOf builtin, especially when called from
optimized code.
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_rel_ng
BUG=v8:5269,v8:5989,v8:6483
R=jgruber@chromium.org
Review-Url: https://codereview.chromium.org/2934893002
Cr-Commit-Position: refs/heads/master@{#45925}
2017-06-13 19:14:00 +00:00
|
|
|
V(Object.prototype, isPrototypeOf, ObjectIsPrototypeOf) \
|
2017-01-26 12:07:22 +00:00
|
|
|
V(Object.prototype, toString, ObjectToString) \
|
2016-11-24 06:01:44 +00:00
|
|
|
V(RegExp.prototype, compile, RegExpCompile) \
|
|
|
|
V(RegExp.prototype, exec, RegExpExec) \
|
|
|
|
V(RegExp.prototype, test, RegExpTest) \
|
|
|
|
V(RegExp.prototype, toString, RegExpToString) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(String.prototype, charCodeAt, StringCharCodeAt) \
|
|
|
|
V(String.prototype, charAt, StringCharAt) \
|
2016-11-27 19:20:18 +00:00
|
|
|
V(String.prototype, codePointAt, StringCodePointAt) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(String.prototype, concat, StringConcat) \
|
2016-11-27 19:20:18 +00:00
|
|
|
V(String.prototype, endsWith, StringEndsWith) \
|
|
|
|
V(String.prototype, includes, StringIncludes) \
|
|
|
|
V(String.prototype, indexOf, StringIndexOf) \
|
|
|
|
V(String.prototype, lastIndexOf, StringLastIndexOf) \
|
|
|
|
V(String.prototype, repeat, StringRepeat) \
|
|
|
|
V(String.prototype, slice, StringSlice) \
|
|
|
|
V(String.prototype, startsWith, StringStartsWith) \
|
2016-08-09 07:13:38 +00:00
|
|
|
V(String.prototype, substr, StringSubstr) \
|
2016-11-27 19:20:18 +00:00
|
|
|
V(String.prototype, substring, StringSubstring) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(String.prototype, toLowerCase, StringToLowerCase) \
|
2016-11-27 19:20:18 +00:00
|
|
|
V(String.prototype, toString, StringToString) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(String.prototype, toUpperCase, StringToUpperCase) \
|
2016-11-27 19:20:18 +00:00
|
|
|
V(String.prototype, trim, StringTrim) \
|
|
|
|
V(String.prototype, trimLeft, StringTrimLeft) \
|
|
|
|
V(String.prototype, trimRight, StringTrimRight) \
|
|
|
|
V(String.prototype, valueOf, StringValueOf) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(String, fromCharCode, StringFromCharCode) \
|
2016-11-27 19:20:18 +00:00
|
|
|
V(String, fromCodePoint, StringFromCodePoint) \
|
|
|
|
V(String, raw, StringRaw) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Math, random, MathRandom) \
|
|
|
|
V(Math, floor, MathFloor) \
|
|
|
|
V(Math, round, MathRound) \
|
|
|
|
V(Math, ceil, MathCeil) \
|
|
|
|
V(Math, abs, MathAbs) \
|
|
|
|
V(Math, log, MathLog) \
|
2016-06-13 05:46:38 +00:00
|
|
|
V(Math, log1p, MathLog1p) \
|
2016-06-16 11:22:32 +00:00
|
|
|
V(Math, log2, MathLog2) \
|
|
|
|
V(Math, log10, MathLog10) \
|
2016-06-17 09:13:22 +00:00
|
|
|
V(Math, cbrt, MathCbrt) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Math, exp, MathExp) \
|
2016-06-17 09:13:22 +00:00
|
|
|
V(Math, expm1, MathExpm1) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Math, sqrt, MathSqrt) \
|
|
|
|
V(Math, pow, MathPow) \
|
|
|
|
V(Math, max, MathMax) \
|
|
|
|
V(Math, min, MathMin) \
|
|
|
|
V(Math, cos, MathCos) \
|
2016-06-30 08:41:05 +00:00
|
|
|
V(Math, cosh, MathCosh) \
|
[builtins] Unify most of the remaining Math builtins.
Import fdlibm versions of acos, acosh, asin and asinh, which are more
precise and produce the same result across platforms (we were using
libm versions for asin and acos so far, where both speed and precision
depended on the operating system so far). Introduce appropriate TurboFan
operators for these functions and use them both for inlining and for the
generic builtin.
Also migrate the Math.imul and Math.fround builtins to TurboFan builtins
to ensure that their behavior is always exactly the same as the inlined
TurboFan version (i.e. C++ truncation semantics for double to float
don't necessarily meet the JavaScript semantics).
For completeness, also migrate Math.sign, which can even get some nice
love in TurboFan.
Drive-by-fix: Some alpha-sorting on the Math related functions, and
cleanup the list of Math intrinsics that we have to export via the
native context currently.
BUG=v8:3266,v8:3496,v8:3509,v8:3952,v8:5169,v8:5170,v8:5171,v8:5172
TBR=rossberg@chromium.org
R=franzih@chromium.org
Review-Url: https://codereview.chromium.org/2116753002
Cr-Commit-Position: refs/heads/master@{#37476}
2016-07-01 11:11:33 +00:00
|
|
|
V(Math, sign, MathSign) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Math, sin, MathSin) \
|
2016-06-30 08:41:05 +00:00
|
|
|
V(Math, sinh, MathSinh) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Math, tan, MathTan) \
|
2016-06-30 08:41:05 +00:00
|
|
|
V(Math, tanh, MathTanh) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Math, acos, MathAcos) \
|
[builtins] Unify most of the remaining Math builtins.
Import fdlibm versions of acos, acosh, asin and asinh, which are more
precise and produce the same result across platforms (we were using
libm versions for asin and acos so far, where both speed and precision
depended on the operating system so far). Introduce appropriate TurboFan
operators for these functions and use them both for inlining and for the
generic builtin.
Also migrate the Math.imul and Math.fround builtins to TurboFan builtins
to ensure that their behavior is always exactly the same as the inlined
TurboFan version (i.e. C++ truncation semantics for double to float
don't necessarily meet the JavaScript semantics).
For completeness, also migrate Math.sign, which can even get some nice
love in TurboFan.
Drive-by-fix: Some alpha-sorting on the Math related functions, and
cleanup the list of Math intrinsics that we have to export via the
native context currently.
BUG=v8:3266,v8:3496,v8:3509,v8:3952,v8:5169,v8:5170,v8:5171,v8:5172
TBR=rossberg@chromium.org
R=franzih@chromium.org
Review-Url: https://codereview.chromium.org/2116753002
Cr-Commit-Position: refs/heads/master@{#37476}
2016-07-01 11:11:33 +00:00
|
|
|
V(Math, acosh, MathAcosh) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Math, asin, MathAsin) \
|
[builtins] Unify most of the remaining Math builtins.
Import fdlibm versions of acos, acosh, asin and asinh, which are more
precise and produce the same result across platforms (we were using
libm versions for asin and acos so far, where both speed and precision
depended on the operating system so far). Introduce appropriate TurboFan
operators for these functions and use them both for inlining and for the
generic builtin.
Also migrate the Math.imul and Math.fround builtins to TurboFan builtins
to ensure that their behavior is always exactly the same as the inlined
TurboFan version (i.e. C++ truncation semantics for double to float
don't necessarily meet the JavaScript semantics).
For completeness, also migrate Math.sign, which can even get some nice
love in TurboFan.
Drive-by-fix: Some alpha-sorting on the Math related functions, and
cleanup the list of Math intrinsics that we have to export via the
native context currently.
BUG=v8:3266,v8:3496,v8:3509,v8:3952,v8:5169,v8:5170,v8:5171,v8:5172
TBR=rossberg@chromium.org
R=franzih@chromium.org
Review-Url: https://codereview.chromium.org/2116753002
Cr-Commit-Position: refs/heads/master@{#37476}
2016-07-01 11:11:33 +00:00
|
|
|
V(Math, asinh, MathAsinh) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Math, atan, MathAtan) \
|
|
|
|
V(Math, atan2, MathAtan2) \
|
2016-06-17 09:13:22 +00:00
|
|
|
V(Math, atanh, MathAtanh) \
|
2016-03-01 18:16:33 +00:00
|
|
|
V(Math, imul, MathImul) \
|
|
|
|
V(Math, clz32, MathClz32) \
|
2016-03-30 11:56:31 +00:00
|
|
|
V(Math, fround, MathFround) \
|
2016-07-05 09:49:52 +00:00
|
|
|
V(Math, trunc, MathTrunc) \
|
2016-09-07 10:14:19 +00:00
|
|
|
V(Number, isFinite, NumberIsFinite) \
|
|
|
|
V(Number, isInteger, NumberIsInteger) \
|
|
|
|
V(Number, isNaN, NumberIsNaN) \
|
|
|
|
V(Number, isSafeInteger, NumberIsSafeInteger) \
|
2016-10-07 08:58:43 +00:00
|
|
|
V(Number, parseFloat, NumberParseFloat) \
|
2016-08-09 07:13:38 +00:00
|
|
|
V(Number, parseInt, NumberParseInt) \
|
2017-01-13 16:47:12 +00:00
|
|
|
V(Number.prototype, toString, NumberToString) \
|
2017-01-20 08:56:33 +00:00
|
|
|
V(Map.prototype, clear, MapClear) \
|
|
|
|
V(Map.prototype, delete, MapDelete) \
|
|
|
|
V(Map.prototype, entries, MapEntries) \
|
|
|
|
V(Map.prototype, forEach, MapForEach) \
|
|
|
|
V(Map.prototype, has, MapHas) \
|
|
|
|
V(Map.prototype, keys, MapKeys) \
|
|
|
|
V(Map.prototype, set, MapSet) \
|
|
|
|
V(Map.prototype, values, MapValues) \
|
|
|
|
V(Set.prototype, add, SetAdd) \
|
|
|
|
V(Set.prototype, clear, SetClear) \
|
|
|
|
V(Set.prototype, delete, SetDelete) \
|
|
|
|
V(Set.prototype, entries, SetEntries) \
|
|
|
|
V(Set.prototype, forEach, SetForEach) \
|
|
|
|
V(Set.prototype, has, SetHas) \
|
|
|
|
V(Set.prototype, keys, SetKeys) \
|
|
|
|
V(Set.prototype, values, SetValues) \
|
|
|
|
V(WeakMap.prototype, delete, WeakMapDelete) \
|
|
|
|
V(WeakMap.prototype, has, WeakMapHas) \
|
|
|
|
V(WeakMap.prototype, set, WeakMapSet) \
|
|
|
|
V(WeakSet.prototype, add, WeakSetAdd) \
|
|
|
|
V(WeakSet.prototype, delete, WeakSetDelete) \
|
|
|
|
V(WeakSet.prototype, has, WeakSetHas)
|
2010-12-14 18:53:48 +00:00
|
|
|
|
2017-04-11 00:09:37 +00:00
|
|
|
#define ATOMIC_FUNCTIONS_WITH_ID_LIST(V) \
|
|
|
|
V(Atomics, load, AtomicsLoad) \
|
|
|
|
V(Atomics, store, AtomicsStore) \
|
|
|
|
V(Atomics, exchange, AtomicsExchange) \
|
|
|
|
V(Atomics, compareExchange, AtomicsCompareExchange) \
|
|
|
|
V(Atomics, add, AtomicsAdd) \
|
|
|
|
V(Atomics, sub, AtomicsSub) \
|
|
|
|
V(Atomics, and, AtomicsAnd) \
|
|
|
|
V(Atomics, or, AtomicsOr) \
|
|
|
|
V(Atomics, xor, AtomicsXor)
|
2015-06-03 17:58:29 +00:00
|
|
|
|
2010-12-14 18:53:48 +00:00
|
|
|
enum BuiltinFunctionId {
|
2017-06-26 10:03:43 +00:00
|
|
|
kInvalidBuiltinFunctionId = -1,
|
2013-06-19 09:25:24 +00:00
|
|
|
kArrayCode,
|
2017-06-29 13:14:20 +00:00
|
|
|
#define DECL_FUNCTION_ID(ignored1, ignore2, name) k##name,
|
|
|
|
FUNCTIONS_WITH_ID_LIST(DECL_FUNCTION_ID)
|
|
|
|
ATOMIC_FUNCTIONS_WITH_ID_LIST(DECL_FUNCTION_ID)
|
|
|
|
#undef DECL_FUNCTION_ID
|
2010-12-14 18:53:48 +00:00
|
|
|
// Fake id for a special case of Math.pow. Note, it continues the
|
|
|
|
// list of math functions.
|
2016-06-08 07:40:11 +00:00
|
|
|
kMathPowHalf,
|
|
|
|
// These are manually assigned to special getters during bootstrapping.
|
2016-07-06 19:23:44 +00:00
|
|
|
kArrayBufferByteLength,
|
2016-11-14 15:58:48 +00:00
|
|
|
kArrayEntries,
|
|
|
|
kArrayKeys,
|
|
|
|
kArrayValues,
|
|
|
|
kArrayIteratorNext,
|
2017-07-06 10:39:28 +00:00
|
|
|
kMapIteratorNext,
|
|
|
|
kSetIteratorNext,
|
2016-06-08 07:40:11 +00:00
|
|
|
kDataViewBuffer,
|
|
|
|
kDataViewByteLength,
|
|
|
|
kDataViewByteOffset,
|
2016-11-18 06:30:57 +00:00
|
|
|
kFunctionHasInstance,
|
2016-08-09 07:13:38 +00:00
|
|
|
kGlobalDecodeURI,
|
|
|
|
kGlobalDecodeURIComponent,
|
|
|
|
kGlobalEncodeURI,
|
|
|
|
kGlobalEncodeURIComponent,
|
|
|
|
kGlobalEscape,
|
|
|
|
kGlobalUnescape,
|
2016-09-07 10:14:19 +00:00
|
|
|
kGlobalIsFinite,
|
|
|
|
kGlobalIsNaN,
|
2016-06-08 07:40:11 +00:00
|
|
|
kTypedArrayByteLength,
|
|
|
|
kTypedArrayByteOffset,
|
2016-11-14 15:58:48 +00:00
|
|
|
kTypedArrayEntries,
|
|
|
|
kTypedArrayKeys,
|
2016-06-08 07:40:11 +00:00
|
|
|
kTypedArrayLength,
|
2016-11-14 15:58:48 +00:00
|
|
|
kTypedArrayValues,
|
2016-07-07 19:42:15 +00:00
|
|
|
kSharedArrayBufferByteLength,
|
2016-10-18 16:32:31 +00:00
|
|
|
kStringIterator,
|
2016-10-05 18:45:54 +00:00
|
|
|
kStringIteratorNext,
|
2017-06-26 08:19:08 +00:00
|
|
|
kStringToLowerCaseIntl,
|
|
|
|
kStringToUpperCaseIntl
|
2010-12-07 11:31:57 +00:00
|
|
|
};
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSGeneratorObject: public JSObject {
|
2013-04-15 12:29:44 +00:00
|
|
|
public:
|
|
|
|
// [function]: The function corresponding to this generator object.
|
|
|
|
DECL_ACCESSORS(function, JSFunction)
|
|
|
|
|
2013-04-19 14:11:23 +00:00
|
|
|
// [context]: The context of the suspended computation.
|
|
|
|
DECL_ACCESSORS(context, Context)
|
2013-04-15 12:29:44 +00:00
|
|
|
|
2013-04-25 10:59:09 +00:00
|
|
|
// [receiver]: The receiver of the suspended computation.
|
|
|
|
DECL_ACCESSORS(receiver, Object)
|
|
|
|
|
2016-06-21 12:12:47 +00:00
|
|
|
// [input_or_debug_pos]
|
|
|
|
// For executing generators: the most recent input value.
|
2016-11-22 13:48:32 +00:00
|
|
|
// For suspended generators: debug information (bytecode offset).
|
2016-06-21 12:12:47 +00:00
|
|
|
// There is currently no need to remember the most recent input value for a
|
|
|
|
// suspended generator.
|
|
|
|
DECL_ACCESSORS(input_or_debug_pos, Object)
|
2016-01-28 08:54:29 +00:00
|
|
|
|
2016-04-11 08:25:44 +00:00
|
|
|
// [resume_mode]: The most recent resume mode.
|
|
|
|
enum ResumeMode { kNext, kReturn, kThrow };
|
|
|
|
DECL_INT_ACCESSORS(resume_mode)
|
|
|
|
|
2016-06-21 12:12:47 +00:00
|
|
|
// [continuation]
|
2013-04-19 14:11:23 +00:00
|
|
|
//
|
2016-06-21 12:12:47 +00:00
|
|
|
// A positive value indicates a suspended generator. The special
|
2013-04-19 14:11:23 +00:00
|
|
|
// kGeneratorExecuting and kGeneratorClosed values indicate that a generator
|
|
|
|
// cannot be resumed.
|
2014-06-20 10:31:17 +00:00
|
|
|
inline int continuation() const;
|
2013-04-15 12:29:44 +00:00
|
|
|
inline void set_continuation(int continuation);
|
2016-06-21 12:12:47 +00:00
|
|
|
inline bool is_closed() const;
|
|
|
|
inline bool is_executing() const;
|
|
|
|
inline bool is_suspended() const;
|
|
|
|
|
|
|
|
// For suspended generators: the source position at which the generator
|
|
|
|
// is suspended.
|
|
|
|
int source_position() const;
|
2013-04-15 12:29:44 +00:00
|
|
|
|
2016-11-21 13:31:09 +00:00
|
|
|
// [register_file]: Saved interpreter register file.
|
|
|
|
DECL_ACCESSORS(register_file, FixedArray)
|
2013-04-15 12:29:44 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSGeneratorObject)
|
2013-04-15 12:29:44 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(JSGeneratorObject)
|
2013-04-15 12:29:44 +00:00
|
|
|
|
2013-04-19 14:11:23 +00:00
|
|
|
// Magic sentinel values for the continuation.
|
2016-04-18 14:13:04 +00:00
|
|
|
static const int kGeneratorExecuting = -2;
|
|
|
|
static const int kGeneratorClosed = -1;
|
2013-04-19 14:11:23 +00:00
|
|
|
|
2013-04-15 12:29:44 +00:00
|
|
|
// Layout description.
|
|
|
|
static const int kFunctionOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kContextOffset = kFunctionOffset + kPointerSize;
|
2013-04-25 10:59:09 +00:00
|
|
|
static const int kReceiverOffset = kContextOffset + kPointerSize;
|
2016-06-21 12:12:47 +00:00
|
|
|
static const int kInputOrDebugPosOffset = kReceiverOffset + kPointerSize;
|
|
|
|
static const int kResumeModeOffset = kInputOrDebugPosOffset + kPointerSize;
|
2016-04-11 08:25:44 +00:00
|
|
|
static const int kContinuationOffset = kResumeModeOffset + kPointerSize;
|
2016-11-21 13:31:09 +00:00
|
|
|
static const int kRegisterFileOffset = kContinuationOffset + kPointerSize;
|
|
|
|
static const int kSize = kRegisterFileOffset + kPointerSize;
|
2013-04-15 12:29:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSGeneratorObject);
|
|
|
|
};
|
|
|
|
|
[async-iteration] implement AsyncGenerator
- Introduce new struct AsyncGeneratorRequest, which holds
information pertinent to resuming execution of an
AsyncGenerator, such as the Promise associated with the async
generator request. It is intended to be used as a singly
linked list, and holds a pointer to the next item in te queue.
- Introduce JSAsyncGeneratorObject (subclass of
JSGeneratorObject), which includes several new internal fields
(`queue` which contains a singly linked list of
AsyncGeneratorRequest objects, and `await_input` which
contains the sent value from an Await expression (This is
necessary to prevent function.sent (used by yield*) from
having the sent value observably overwritten during
execution).
- Modify SuspendGenerator to accept a set of Flags, which
indicate whether the suspend is for a Yield or Await, and
whether it takes place on an async generator or ES6
generator.
- Introduce interpreter intrinsics and TF intrinsic lowering for
accessing the await input of an async generator
- Modify the JSGeneratorStore operator to understand whether or
not it's suspending for a normal yield, or an AsyncGenerator
Await. This ensures appropriate registers are stored.
- Add versions of ResumeGeneratorTrampoline which store the
input value in a different field depending on wether it's an
AsyncGenerator Await resume, or an ordinary resume. Also modifies
whether debug code will assert that the generator object is a
JSGeneratorObject or a JSAsyncGeneratorObject depending on the
resume type.
BUG=v8:5855
R=bmeurer@chromium.org, rmcilroy@chromium.org, jgruber@chromium.org,
littledan@chromium.org, neis@chromium.org
TBR=marja@chromium.org
Change-Id: I9d58df1d344465fc937fe7eed322424204497187
Reviewed-on: https://chromium-review.googlesource.com/446961
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44240}
2017-03-29 13:41:45 +00:00
|
|
|
class JSAsyncGeneratorObject : public JSGeneratorObject {
|
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSAsyncGeneratorObject)
|
[async-iteration] implement AsyncGenerator
- Introduce new struct AsyncGeneratorRequest, which holds
information pertinent to resuming execution of an
AsyncGenerator, such as the Promise associated with the async
generator request. It is intended to be used as a singly
linked list, and holds a pointer to the next item in te queue.
- Introduce JSAsyncGeneratorObject (subclass of
JSGeneratorObject), which includes several new internal fields
(`queue` which contains a singly linked list of
AsyncGeneratorRequest objects, and `await_input` which
contains the sent value from an Await expression (This is
necessary to prevent function.sent (used by yield*) from
having the sent value observably overwritten during
execution).
- Modify SuspendGenerator to accept a set of Flags, which
indicate whether the suspend is for a Yield or Await, and
whether it takes place on an async generator or ES6
generator.
- Introduce interpreter intrinsics and TF intrinsic lowering for
accessing the await input of an async generator
- Modify the JSGeneratorStore operator to understand whether or
not it's suspending for a normal yield, or an AsyncGenerator
Await. This ensures appropriate registers are stored.
- Add versions of ResumeGeneratorTrampoline which store the
input value in a different field depending on wether it's an
AsyncGenerator Await resume, or an ordinary resume. Also modifies
whether debug code will assert that the generator object is a
JSGeneratorObject or a JSAsyncGeneratorObject depending on the
resume type.
BUG=v8:5855
R=bmeurer@chromium.org, rmcilroy@chromium.org, jgruber@chromium.org,
littledan@chromium.org, neis@chromium.org
TBR=marja@chromium.org
Change-Id: I9d58df1d344465fc937fe7eed322424204497187
Reviewed-on: https://chromium-review.googlesource.com/446961
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44240}
2017-03-29 13:41:45 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(JSAsyncGeneratorObject)
|
[async-iteration] implement AsyncGenerator
- Introduce new struct AsyncGeneratorRequest, which holds
information pertinent to resuming execution of an
AsyncGenerator, such as the Promise associated with the async
generator request. It is intended to be used as a singly
linked list, and holds a pointer to the next item in te queue.
- Introduce JSAsyncGeneratorObject (subclass of
JSGeneratorObject), which includes several new internal fields
(`queue` which contains a singly linked list of
AsyncGeneratorRequest objects, and `await_input` which
contains the sent value from an Await expression (This is
necessary to prevent function.sent (used by yield*) from
having the sent value observably overwritten during
execution).
- Modify SuspendGenerator to accept a set of Flags, which
indicate whether the suspend is for a Yield or Await, and
whether it takes place on an async generator or ES6
generator.
- Introduce interpreter intrinsics and TF intrinsic lowering for
accessing the await input of an async generator
- Modify the JSGeneratorStore operator to understand whether or
not it's suspending for a normal yield, or an AsyncGenerator
Await. This ensures appropriate registers are stored.
- Add versions of ResumeGeneratorTrampoline which store the
input value in a different field depending on wether it's an
AsyncGenerator Await resume, or an ordinary resume. Also modifies
whether debug code will assert that the generator object is a
JSGeneratorObject or a JSAsyncGeneratorObject depending on the
resume type.
BUG=v8:5855
R=bmeurer@chromium.org, rmcilroy@chromium.org, jgruber@chromium.org,
littledan@chromium.org, neis@chromium.org
TBR=marja@chromium.org
Change-Id: I9d58df1d344465fc937fe7eed322424204497187
Reviewed-on: https://chromium-review.googlesource.com/446961
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44240}
2017-03-29 13:41:45 +00:00
|
|
|
|
|
|
|
// [queue]
|
|
|
|
// Pointer to the head of a singly linked list of AsyncGeneratorRequest, or
|
|
|
|
// undefined.
|
|
|
|
DECL_ACCESSORS(queue, HeapObject)
|
|
|
|
|
|
|
|
// [await_input_or_debug_pos]
|
|
|
|
// Holds the value to resume generator with after an Await(), in order to
|
|
|
|
// avoid clobbering function.sent. If awaited_promise is not undefined, holds
|
|
|
|
// current bytecode offset for debugging instead.
|
|
|
|
DECL_ACCESSORS(await_input_or_debug_pos, Object)
|
|
|
|
|
|
|
|
// [awaited_promise]
|
|
|
|
// A reference to the Promise of an AwaitExpression.
|
|
|
|
DECL_ACCESSORS(awaited_promise, HeapObject)
|
|
|
|
|
|
|
|
// Layout description.
|
|
|
|
static const int kQueueOffset = JSGeneratorObject::kSize;
|
|
|
|
static const int kAwaitInputOrDebugPosOffset = kQueueOffset + kPointerSize;
|
|
|
|
static const int kAwaitedPromiseOffset =
|
|
|
|
kAwaitInputOrDebugPosOffset + kPointerSize;
|
|
|
|
static const int kSize = kAwaitedPromiseOffset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSAsyncGeneratorObject);
|
|
|
|
};
|
|
|
|
|
2016-10-07 19:37:04 +00:00
|
|
|
// When importing a module namespace (import * as foo from "bar"), a
|
|
|
|
// JSModuleNamespace object (representing module "bar") is created and bound to
|
|
|
|
// the declared variable (foo). A module can have at most one namespace object.
|
|
|
|
class JSModuleNamespace : public JSObject {
|
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSModuleNamespace)
|
|
|
|
DECL_PRINTER(JSModuleNamespace)
|
|
|
|
DECL_VERIFIER(JSModuleNamespace)
|
2016-10-07 19:37:04 +00:00
|
|
|
|
|
|
|
// The actual module whose namespace is being represented.
|
|
|
|
DECL_ACCESSORS(module, Module)
|
|
|
|
|
|
|
|
// Retrieve the value exported by [module] under the given [name]. If there is
|
|
|
|
// no such export, return Just(undefined). If the export is uninitialized,
|
|
|
|
// schedule an exception and return Nothing.
|
|
|
|
MUST_USE_RESULT MaybeHandle<Object> GetExport(Handle<String> name);
|
|
|
|
|
2017-01-12 21:40:04 +00:00
|
|
|
// In-object fields.
|
|
|
|
enum {
|
|
|
|
kToStringTagFieldIndex,
|
|
|
|
kInObjectFieldCount,
|
|
|
|
};
|
|
|
|
|
2016-10-07 19:37:04 +00:00
|
|
|
static const int kModuleOffset = JSObject::kHeaderSize;
|
2017-01-12 21:40:04 +00:00
|
|
|
static const int kHeaderSize = kModuleOffset + kPointerSize;
|
|
|
|
|
|
|
|
static const int kSize = kHeaderSize + kPointerSize * kInObjectFieldCount;
|
2016-10-07 19:37:04 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSModuleNamespace);
|
|
|
|
};
|
|
|
|
|
2016-09-16 16:47:07 +00:00
|
|
|
// A Module object is a mapping from export names to cells
|
2016-09-12 12:54:47 +00:00
|
|
|
// This is still very much in flux.
|
2016-09-16 16:47:07 +00:00
|
|
|
class Module : public Struct {
|
2016-09-12 12:54:47 +00:00
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(Module)
|
|
|
|
DECL_VERIFIER(Module)
|
|
|
|
DECL_PRINTER(Module)
|
2016-09-12 12:54:47 +00:00
|
|
|
|
2016-10-17 07:36:42 +00:00
|
|
|
// The code representing this Module, or an abstraction thereof.
|
|
|
|
// This is either a SharedFunctionInfo or a JSFunction or a ModuleInfo
|
|
|
|
// depending on whether the module has been instantiated and evaluated. See
|
|
|
|
// Module::ModuleVerify() for the precise invariant.
|
2016-09-16 21:47:14 +00:00
|
|
|
DECL_ACCESSORS(code, Object)
|
|
|
|
|
2016-11-07 16:23:20 +00:00
|
|
|
// Arrays of cells corresponding to regular exports and regular imports.
|
|
|
|
// A cell's position in the array is determined by the cell index of the
|
|
|
|
// associated module entry (which coincides with the variable index of the
|
|
|
|
// associated variable).
|
|
|
|
DECL_ACCESSORS(regular_exports, FixedArray)
|
|
|
|
DECL_ACCESSORS(regular_imports, FixedArray)
|
|
|
|
|
|
|
|
// The complete export table, mapping an export name to its cell.
|
|
|
|
// TODO(neis): We may want to remove the regular exports from the table.
|
2016-09-16 16:47:07 +00:00
|
|
|
DECL_ACCESSORS(exports, ObjectHashTable)
|
2016-09-12 12:54:47 +00:00
|
|
|
|
2016-10-17 07:36:42 +00:00
|
|
|
// Hash for this object (a random non-zero Smi).
|
|
|
|
DECL_INT_ACCESSORS(hash)
|
|
|
|
|
2017-06-28 12:56:11 +00:00
|
|
|
// Status.
|
2017-02-28 11:35:16 +00:00
|
|
|
DECL_INT_ACCESSORS(status)
|
2017-06-28 12:56:11 +00:00
|
|
|
enum Status {
|
|
|
|
// Order matters!
|
|
|
|
kUninstantiated,
|
|
|
|
kPreInstantiating,
|
|
|
|
kInstantiating,
|
|
|
|
kInstantiated,
|
|
|
|
kEvaluating,
|
|
|
|
kEvaluated,
|
|
|
|
kErrored
|
|
|
|
};
|
|
|
|
|
|
|
|
// The exception in the case {status} is kErrored.
|
|
|
|
Object* GetException();
|
2017-02-28 11:35:16 +00:00
|
|
|
|
2016-10-07 19:37:04 +00:00
|
|
|
// The namespace object (or undefined).
|
|
|
|
DECL_ACCESSORS(module_namespace, HeapObject)
|
|
|
|
|
2016-10-17 07:36:42 +00:00
|
|
|
// Modules imported or re-exported by this module.
|
2016-09-20 18:49:58 +00:00
|
|
|
// Corresponds 1-to-1 to the module specifier strings in
|
|
|
|
// ModuleInfo::module_requests.
|
|
|
|
DECL_ACCESSORS(requested_modules, FixedArray)
|
|
|
|
|
2017-06-21 12:30:56 +00:00
|
|
|
// [script]: Script from which the module originates.
|
|
|
|
DECL_ACCESSORS(script, Script)
|
|
|
|
|
2016-09-23 19:02:26 +00:00
|
|
|
// Get the ModuleInfo associated with the code.
|
|
|
|
inline ModuleInfo* info() const;
|
|
|
|
|
2016-09-26 18:50:28 +00:00
|
|
|
// Implementation of spec operation ModuleDeclarationInstantiation.
|
|
|
|
// Returns false if an exception occurred during instantiation, true
|
2017-04-19 18:28:09 +00:00
|
|
|
// otherwise. (In the case where the callback throws an exception, that
|
|
|
|
// exception is propagated.)
|
2016-09-26 18:50:28 +00:00
|
|
|
static MUST_USE_RESULT bool Instantiate(Handle<Module> module,
|
|
|
|
v8::Local<v8::Context> context,
|
2016-10-11 19:22:03 +00:00
|
|
|
v8::Module::ResolveCallback callback);
|
2016-09-26 18:50:28 +00:00
|
|
|
|
2016-09-27 18:32:05 +00:00
|
|
|
// Implementation of spec operation ModuleEvaluation.
|
|
|
|
static MUST_USE_RESULT MaybeHandle<Object> Evaluate(Handle<Module> module);
|
|
|
|
|
2017-05-03 18:34:36 +00:00
|
|
|
Cell* GetCell(int cell_index);
|
2016-11-07 16:23:20 +00:00
|
|
|
static Handle<Object> LoadVariable(Handle<Module> module, int cell_index);
|
|
|
|
static void StoreVariable(Handle<Module> module, int cell_index,
|
|
|
|
Handle<Object> value);
|
2016-09-16 16:47:07 +00:00
|
|
|
|
2016-10-07 19:37:04 +00:00
|
|
|
// Get the namespace object for [module_request] of [module]. If it doesn't
|
|
|
|
// exist yet, it is created.
|
|
|
|
static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module,
|
|
|
|
int module_request);
|
|
|
|
|
2017-04-11 09:33:11 +00:00
|
|
|
// Get the namespace object for [module]. If it doesn't exist yet, it is
|
|
|
|
// created.
|
|
|
|
static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module);
|
|
|
|
|
2016-09-26 18:50:28 +00:00
|
|
|
static const int kCodeOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kExportsOffset = kCodeOffset + kPointerSize;
|
2016-11-07 16:23:20 +00:00
|
|
|
static const int kRegularExportsOffset = kExportsOffset + kPointerSize;
|
|
|
|
static const int kRegularImportsOffset = kRegularExportsOffset + kPointerSize;
|
|
|
|
static const int kHashOffset = kRegularImportsOffset + kPointerSize;
|
2016-10-17 07:36:42 +00:00
|
|
|
static const int kModuleNamespaceOffset = kHashOffset + kPointerSize;
|
|
|
|
static const int kRequestedModulesOffset =
|
|
|
|
kModuleNamespaceOffset + kPointerSize;
|
2017-02-28 11:35:16 +00:00
|
|
|
static const int kStatusOffset = kRequestedModulesOffset + kPointerSize;
|
2017-06-28 12:56:11 +00:00
|
|
|
static const int kDfsIndexOffset = kStatusOffset + kPointerSize;
|
|
|
|
static const int kDfsAncestorIndexOffset = kDfsIndexOffset + kPointerSize;
|
|
|
|
static const int kExceptionOffset = kDfsAncestorIndexOffset + kPointerSize;
|
|
|
|
static const int kScriptOffset = kExceptionOffset + kPointerSize;
|
2017-06-21 12:30:56 +00:00
|
|
|
static const int kSize = kScriptOffset + kPointerSize;
|
2016-09-26 18:50:28 +00:00
|
|
|
|
|
|
|
private:
|
2017-06-28 12:56:11 +00:00
|
|
|
friend class Factory;
|
|
|
|
|
|
|
|
DECL_ACCESSORS(exception, Object)
|
|
|
|
|
|
|
|
// TODO(neis): Don't store those in the module object?
|
|
|
|
DECL_INT_ACCESSORS(dfs_index)
|
|
|
|
DECL_INT_ACCESSORS(dfs_ancestor_index)
|
|
|
|
|
|
|
|
// Helpers for Instantiate and Evaluate.
|
|
|
|
|
2016-11-07 16:23:20 +00:00
|
|
|
static void CreateExport(Handle<Module> module, int cell_index,
|
|
|
|
Handle<FixedArray> names);
|
2016-09-26 18:50:28 +00:00
|
|
|
static void CreateIndirectExport(Handle<Module> module, Handle<String> name,
|
|
|
|
Handle<ModuleInfoEntry> entry);
|
|
|
|
|
2016-09-24 01:46:45 +00:00
|
|
|
// The [must_resolve] argument indicates whether or not an exception should be
|
2016-09-27 17:31:14 +00:00
|
|
|
// thrown in case the module does not provide an export named [name]
|
|
|
|
// (including when a cycle is detected). An exception is always thrown in the
|
|
|
|
// case of conflicting star exports.
|
2016-09-24 01:46:45 +00:00
|
|
|
//
|
|
|
|
// If [must_resolve] is true, a null result indicates an exception. If
|
2016-09-27 17:31:14 +00:00
|
|
|
// [must_resolve] is false, a null result may or may not indicate an
|
|
|
|
// exception (so check manually!).
|
2016-09-26 22:42:09 +00:00
|
|
|
class ResolveSet;
|
|
|
|
static MUST_USE_RESULT MaybeHandle<Cell> ResolveExport(
|
2016-10-26 15:09:47 +00:00
|
|
|
Handle<Module> module, Handle<String> name, MessageLocation loc,
|
|
|
|
bool must_resolve, ResolveSet* resolve_set);
|
2016-09-26 22:42:09 +00:00
|
|
|
static MUST_USE_RESULT MaybeHandle<Cell> ResolveImport(
|
|
|
|
Handle<Module> module, Handle<String> name, int module_request,
|
2016-10-26 15:09:47 +00:00
|
|
|
MessageLocation loc, bool must_resolve, ResolveSet* resolve_set);
|
2016-09-23 19:02:26 +00:00
|
|
|
|
2016-09-24 01:46:45 +00:00
|
|
|
// Helper for ResolveExport.
|
|
|
|
static MUST_USE_RESULT MaybeHandle<Cell> ResolveExportUsingStarExports(
|
2016-10-26 15:09:47 +00:00
|
|
|
Handle<Module> module, Handle<String> name, MessageLocation loc,
|
|
|
|
bool must_resolve, ResolveSet* resolve_set);
|
2016-09-24 01:46:45 +00:00
|
|
|
|
2017-02-28 11:35:16 +00:00
|
|
|
static MUST_USE_RESULT bool PrepareInstantiate(
|
|
|
|
Handle<Module> module, v8::Local<v8::Context> context,
|
|
|
|
v8::Module::ResolveCallback callback);
|
2017-06-28 12:56:11 +00:00
|
|
|
static MUST_USE_RESULT bool FinishInstantiate(
|
|
|
|
Handle<Module> module, ZoneForwardList<Handle<Module>>* stack,
|
2017-06-28 14:20:43 +00:00
|
|
|
unsigned* dfs_index, Zone* zone);
|
2017-06-28 12:56:11 +00:00
|
|
|
static MUST_USE_RESULT MaybeHandle<Object> Evaluate(
|
|
|
|
Handle<Module> module, ZoneForwardList<Handle<Module>>* stack,
|
|
|
|
unsigned* dfs_index);
|
|
|
|
|
|
|
|
static void MaybeTransitionComponent(Handle<Module> module,
|
|
|
|
ZoneForwardList<Handle<Module>>* stack,
|
|
|
|
Status new_status);
|
|
|
|
|
|
|
|
// To set status to kErrored, RecordError should be used.
|
|
|
|
void SetStatus(Status status);
|
|
|
|
void RecordError();
|
2017-02-28 11:35:16 +00:00
|
|
|
|
2016-09-16 16:47:07 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Module);
|
2016-09-12 12:54:47 +00:00
|
|
|
};
|
2013-04-15 12:29:44 +00:00
|
|
|
|
2015-12-27 06:30:53 +00:00
|
|
|
// JSBoundFunction describes a bound function exotic object.
|
|
|
|
class JSBoundFunction : public JSObject {
|
|
|
|
public:
|
|
|
|
// [bound_target_function]: The wrapped function object.
|
2017-06-19 07:09:06 +00:00
|
|
|
inline Object* raw_bound_target_function() const;
|
2015-12-27 06:30:53 +00:00
|
|
|
DECL_ACCESSORS(bound_target_function, JSReceiver)
|
|
|
|
|
|
|
|
// [bound_this]: The value that is always passed as the this value when
|
|
|
|
// calling the wrapped function.
|
|
|
|
DECL_ACCESSORS(bound_this, Object)
|
|
|
|
|
|
|
|
// [bound_arguments]: A list of values whose elements are used as the first
|
|
|
|
// arguments to any call to the wrapped function.
|
|
|
|
DECL_ACCESSORS(bound_arguments, FixedArray)
|
|
|
|
|
2016-04-07 13:36:40 +00:00
|
|
|
static MaybeHandle<String> GetName(Isolate* isolate,
|
|
|
|
Handle<JSBoundFunction> function);
|
2015-12-27 06:30:53 +00:00
|
|
|
static MaybeHandle<Context> GetFunctionRealm(
|
|
|
|
Handle<JSBoundFunction> function);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSBoundFunction)
|
2015-12-27 06:30:53 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSBoundFunction)
|
|
|
|
DECL_VERIFIER(JSBoundFunction)
|
2015-12-27 06:30:53 +00:00
|
|
|
|
|
|
|
// The bound function's string representation implemented according
|
|
|
|
// to ES6 section 19.2.3.5 Function.prototype.toString ( ).
|
|
|
|
static Handle<String> ToString(Handle<JSBoundFunction> function);
|
|
|
|
|
|
|
|
// Layout description.
|
|
|
|
static const int kBoundTargetFunctionOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kBoundThisOffset = kBoundTargetFunctionOffset + kPointerSize;
|
|
|
|
static const int kBoundArgumentsOffset = kBoundThisOffset + kPointerSize;
|
2016-04-07 13:36:40 +00:00
|
|
|
static const int kSize = kBoundArgumentsOffset + kPointerSize;
|
2015-12-27 06:30:53 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSBoundFunction);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// JSFunction describes JavaScript functions.
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSFunction: public JSObject {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
// [prototype_or_initial_map]:
|
|
|
|
DECL_ACCESSORS(prototype_or_initial_map, Object)
|
|
|
|
|
2011-09-13 11:42:57 +00:00
|
|
|
// [shared]: The information about the function that
|
2008-07-03 15:10:15 +00:00
|
|
|
// can be shared by instances.
|
|
|
|
DECL_ACCESSORS(shared, SharedFunctionInfo)
|
|
|
|
|
2016-06-08 09:44:27 +00:00
|
|
|
static const int kLengthDescriptorIndex = 0;
|
|
|
|
static const int kNameDescriptorIndex = 1;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// [context]: The context for this function.
|
|
|
|
inline Context* context();
|
2017-02-20 09:47:14 +00:00
|
|
|
inline bool has_context() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void set_context(Object* context);
|
2014-07-01 12:12:34 +00:00
|
|
|
inline JSObject* global_proxy();
|
2015-11-20 12:50:03 +00:00
|
|
|
inline Context* native_context();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-04-07 13:36:40 +00:00
|
|
|
static Handle<Object> GetName(Isolate* isolate, Handle<JSFunction> function);
|
2016-06-27 18:03:59 +00:00
|
|
|
static MaybeHandle<Smi> GetLength(Isolate* isolate,
|
|
|
|
Handle<JSFunction> function);
|
2015-12-07 16:35:03 +00:00
|
|
|
static Handle<Context> GetFunctionRealm(Handle<JSFunction> function);
|
2015-11-27 12:16:32 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// [code]: The generated code object for this function. Executed
|
|
|
|
// when the function is invoked, e.g. foo() or new foo(). See
|
|
|
|
// [[Call]] and [[Construct]] description in ECMA-262, section
|
|
|
|
// 8.6.2, page 27.
|
|
|
|
inline Code* code();
|
2010-12-07 11:31:57 +00:00
|
|
|
inline void set_code(Code* code);
|
2013-03-12 18:03:18 +00:00
|
|
|
inline void set_code_no_write_barrier(Code* code);
|
2010-12-07 11:31:57 +00:00
|
|
|
inline void ReplaceCode(Code* code);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-02-26 11:04:04 +00:00
|
|
|
// Get the abstract code associated with the function, which will either be
|
|
|
|
// a Code object or a BytecodeArray.
|
|
|
|
inline AbstractCode* abstract_code();
|
|
|
|
|
2015-07-20 14:53:28 +00:00
|
|
|
// Tells whether this function inlines the given shared function info.
|
|
|
|
bool Inlines(SharedFunctionInfo* candidate);
|
|
|
|
|
2016-11-09 17:19:32 +00:00
|
|
|
// Tells whether or not this function is interpreted.
|
|
|
|
//
|
|
|
|
// Note: function->IsInterpreted() does not necessarily return the same value
|
2017-03-27 10:49:51 +00:00
|
|
|
// as function->shared()->IsInterpreted() because the closure might have been
|
|
|
|
// optimized.
|
2016-11-09 17:19:32 +00:00
|
|
|
inline bool IsInterpreted();
|
|
|
|
|
2017-06-15 14:53:38 +00:00
|
|
|
// Tells whether or not this function checks its optimization marker in its
|
|
|
|
// feedback vector.
|
|
|
|
inline bool ChecksOptimizationMarker();
|
|
|
|
|
|
|
|
// Tells whether or not this function holds optimized code.
|
|
|
|
//
|
|
|
|
// Note: Returning false does not necessarily mean that this function hasn't
|
|
|
|
// been optimized, as it may have optimized code on its feedback vector.
|
2010-12-07 11:31:57 +00:00
|
|
|
inline bool IsOptimized();
|
|
|
|
|
2017-06-15 14:53:38 +00:00
|
|
|
// Tells whether or not this function has optimized code available to it,
|
|
|
|
// either because it is optimized or because it has optimized code in its
|
|
|
|
// feedback vector.
|
|
|
|
inline bool HasOptimizedCode();
|
|
|
|
|
|
|
|
// Tells whether or not this function has a (non-zero) optimization marker.
|
|
|
|
inline bool HasOptimizationMarker();
|
|
|
|
|
2016-04-25 10:46:38 +00:00
|
|
|
// Mark this function for lazy recompilation. The function will be recompiled
|
|
|
|
// the next time it is executed.
|
2017-06-15 14:53:38 +00:00
|
|
|
void MarkForOptimization(ConcurrencyMode mode);
|
2013-12-23 14:30:35 +00:00
|
|
|
|
2016-04-25 10:46:38 +00:00
|
|
|
// Tells whether or not the function is already marked for lazy recompilation.
|
2013-12-23 14:30:35 +00:00
|
|
|
inline bool IsMarkedForOptimization();
|
|
|
|
inline bool IsMarkedForConcurrentOptimization();
|
2012-07-19 18:58:23 +00:00
|
|
|
|
2013-08-22 16:14:37 +00:00
|
|
|
// Tells whether or not the function is on the concurrent recompilation queue.
|
2013-12-23 14:30:35 +00:00
|
|
|
inline bool IsInOptimizationQueue();
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2017-05-09 21:45:33 +00:00
|
|
|
// Clears the optimized code slot in the function's feedback vector.
|
|
|
|
inline void ClearOptimizedCodeSlot(const char* reason);
|
|
|
|
|
2017-06-15 14:53:38 +00:00
|
|
|
// Sets the optimization marker in the function's feedback vector.
|
|
|
|
inline void SetOptimizationMarker(OptimizationMarker marker);
|
|
|
|
|
|
|
|
// Clears the optimization marker in the function's feedback vector.
|
|
|
|
inline void ClearOptimizationMarker();
|
|
|
|
|
2015-12-03 10:02:46 +00:00
|
|
|
// Completes inobject slack tracking on initial map if it is active.
|
|
|
|
inline void CompleteInobjectSlackTrackingIfActive();
|
2014-05-23 08:52:05 +00:00
|
|
|
|
2017-02-06 10:18:05 +00:00
|
|
|
// [feedback_vector_cell]: Fixed array holding the feedback vector.
|
|
|
|
DECL_ACCESSORS(feedback_vector_cell, Cell)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-02-08 11:51:06 +00:00
|
|
|
enum FeedbackVectorState {
|
|
|
|
TOP_LEVEL_SCRIPT_NEEDS_VECTOR,
|
|
|
|
NEEDS_VECTOR,
|
|
|
|
HAS_VECTOR
|
|
|
|
};
|
|
|
|
|
|
|
|
inline FeedbackVectorState GetFeedbackVectorState(Isolate* isolate) const;
|
|
|
|
|
2017-02-06 10:18:05 +00:00
|
|
|
// feedback_vector() can be used once the function is compiled.
|
2017-02-07 14:05:02 +00:00
|
|
|
inline FeedbackVector* feedback_vector() const;
|
2017-02-06 10:18:05 +00:00
|
|
|
inline bool has_feedback_vector() const;
|
2016-05-27 08:09:12 +00:00
|
|
|
static void EnsureLiterals(Handle<JSFunction> function);
|
|
|
|
|
2017-02-15 12:12:46 +00:00
|
|
|
// Unconditionally clear the type feedback vector.
|
2016-05-27 08:09:12 +00:00
|
|
|
void ClearTypeFeedbackInfo();
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// The initial map for an object created by this constructor.
|
|
|
|
inline Map* initial_map();
|
2014-08-11 14:00:58 +00:00
|
|
|
static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map,
|
|
|
|
Handle<Object> prototype);
|
2008-07-03 15:10:15 +00:00
|
|
|
inline bool has_initial_map();
|
2013-11-05 12:11:27 +00:00
|
|
|
static void EnsureHasInitialMap(Handle<JSFunction> function);
|
2015-11-27 21:44:27 +00:00
|
|
|
|
|
|
|
// Creates a map that matches the constructor's initial map, but with
|
|
|
|
// [[prototype]] being new.target.prototype. Because new.target can be a
|
|
|
|
// JSProxy, this can call back into JavaScript.
|
|
|
|
static MUST_USE_RESULT MaybeHandle<Map> GetDerivedMap(
|
|
|
|
Isolate* isolate, Handle<JSFunction> constructor,
|
|
|
|
Handle<JSReceiver> new_target);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Get and set the prototype property on a JSFunction. If the
|
|
|
|
// function has an initial map the prototype is set on the initial
|
|
|
|
// map. Otherwise, the prototype is put in the initial map field
|
|
|
|
// until an initial map is needed.
|
|
|
|
inline bool has_prototype();
|
|
|
|
inline bool has_instance_prototype();
|
|
|
|
inline Object* prototype();
|
|
|
|
inline Object* instance_prototype();
|
2013-07-18 07:59:48 +00:00
|
|
|
static void SetPrototype(Handle<JSFunction> function,
|
|
|
|
Handle<Object> value);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Returns if this function has been compiled to native code yet.
|
|
|
|
inline bool is_compiled();
|
|
|
|
|
2013-09-04 13:53:24 +00:00
|
|
|
// [next_function_link]: Links functions into various lists, e.g. the list
|
2017-05-22 08:54:28 +00:00
|
|
|
// of optimized functions hanging off the native_context. Treated weakly
|
2013-09-04 13:53:24 +00:00
|
|
|
// by the garbage collector.
|
2010-12-07 11:31:57 +00:00
|
|
|
DECL_ACCESSORS(next_function_link, Object)
|
|
|
|
|
|
|
|
// Prints the name of the function using PrintF.
|
2013-08-30 07:41:24 +00:00
|
|
|
void PrintName(FILE* out = stdout);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSFunction)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-11-02 08:25:19 +00:00
|
|
|
// Calculate the instance size and in-object properties count.
|
2017-04-05 11:22:02 +00:00
|
|
|
static void CalculateInstanceSizeForDerivedClass(
|
|
|
|
Handle<JSFunction> function, InstanceType instance_type,
|
|
|
|
int requested_embedder_fields, int* instance_size,
|
|
|
|
int* in_object_properties);
|
2016-03-09 12:41:46 +00:00
|
|
|
static void CalculateInstanceSizeHelper(InstanceType instance_type,
|
2017-03-17 13:26:05 +00:00
|
|
|
int requested_embedder_fields,
|
2016-03-09 12:41:46 +00:00
|
|
|
int requested_in_object_properties,
|
|
|
|
int* instance_size,
|
|
|
|
int* in_object_properties);
|
2017-06-12 16:58:06 +00:00
|
|
|
enum BodyVisitingPolicy { kIgnoreWeakness, kRespectWeakness };
|
2015-11-10 11:46:13 +00:00
|
|
|
// Iterates the function object according to the visiting policy.
|
|
|
|
template <BodyVisitingPolicy>
|
|
|
|
class BodyDescriptorImpl;
|
|
|
|
|
2017-06-12 16:58:06 +00:00
|
|
|
typedef BodyDescriptorImpl<kIgnoreWeakness> BodyDescriptor;
|
|
|
|
typedef BodyDescriptorImpl<kRespectWeakness> BodyDescriptorWeak;
|
2010-08-20 07:10:18 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSFunction)
|
|
|
|
DECL_VERIFIER(JSFunction)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-03-13 15:11:47 +00:00
|
|
|
// The function's name if it is configured, otherwise shared function info
|
|
|
|
// debug name.
|
2015-11-19 19:32:31 +00:00
|
|
|
static Handle<String> GetName(Handle<JSFunction> function);
|
|
|
|
|
2016-02-04 22:36:15 +00:00
|
|
|
// ES6 section 9.2.11 SetFunctionName
|
|
|
|
// Because of the way this abstract operation is used in the spec,
|
|
|
|
// it should never fail.
|
|
|
|
static void SetName(Handle<JSFunction> function, Handle<Name> name,
|
|
|
|
Handle<String> prefix);
|
|
|
|
|
2015-11-19 19:32:31 +00:00
|
|
|
// The function's displayName if it is set, otherwise name if it is
|
|
|
|
// configured, otherwise shared function info
|
|
|
|
// debug name.
|
2015-03-13 15:11:47 +00:00
|
|
|
static Handle<String> GetDebugName(Handle<JSFunction> function);
|
|
|
|
|
2015-12-22 06:32:46 +00:00
|
|
|
// The function's string representation implemented according to
|
|
|
|
// ES6 section 19.2.3.5 Function.prototype.toString ( ).
|
|
|
|
static Handle<String> ToString(Handle<JSFunction> function);
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Layout descriptors. The last property (from kNonWeakFieldsEndOffset to
|
|
|
|
// kSize) is weak and has special handling during garbage collection.
|
2015-11-10 11:46:13 +00:00
|
|
|
static const int kPrototypeOrInitialMapOffset = JSObject::kHeaderSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kSharedFunctionInfoOffset =
|
|
|
|
kPrototypeOrInitialMapOffset + kPointerSize;
|
|
|
|
static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize;
|
2017-01-30 12:31:35 +00:00
|
|
|
static const int kFeedbackVectorOffset = kContextOffset + kPointerSize;
|
|
|
|
static const int kNonWeakFieldsEndOffset =
|
|
|
|
kFeedbackVectorOffset + kPointerSize;
|
2015-11-10 11:46:13 +00:00
|
|
|
static const int kCodeEntryOffset = kNonWeakFieldsEndOffset;
|
|
|
|
static const int kNextFunctionLinkOffset = kCodeEntryOffset + kPointerSize;
|
2010-12-07 11:31:57 +00:00
|
|
|
static const int kSize = kNextFunctionLinkOffset + kPointerSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
Split window support from V8.
Here is a description of the background and design of split window in Chrome and V8:
https://docs.google.com/a/google.com/Doc?id=chhjkpg_47fwddxbfr
This change list splits the window object into two parts: 1) an inner window object used as the global object of contexts; 2) an outer window object exposed to JavaScript and accessible by the name 'window'. Firefox did it awhile ago, here are some discussions: https://wiki.mozilla.org/Gecko:SplitWindow. One additional benefit of splitting window in Chrome is that accessing global variables don't need security checks anymore, it can improve applications that use many global variables.
V8 support of split window:
There are a small number of changes on V8 api to support split window:
Security context is removed from V8, so does related API functions;
A global object can be detached from its context and reused by a new context;
Access checks on an object template can be turned on/off by default;
An object can turn on its access checks later;
V8 has a new object type, ApiGlobalObject, which is the outer window object type. The existing JSGlobalObject becomes the inner window object type. Security checks are moved from JSGlobalObject to ApiGlobalObject. ApiGlobalObject is the one exposed to JavaScript, it is accessible through Context::Global(). ApiGlobalObject's prototype is set to JSGlobalObject so that property lookups are forwarded to JSGlobalObject. ApiGlobalObject forwards all other property access requests to JSGlobalObject, such as SetProperty, DeleteProperty, etc.
Security token is moved to a global context, and ApiGlobalObject has a reference to its global context. JSGlobalObject has a reference to its global context as well. When accessing properties on a global object in JavaScript, the domain security check is performed by comparing the security token of the lexical context (Top::global_context()) to the token of global object's context. The check is only needed when the receiver is a window object, such as 'window.document'. Accessing global variables, such as 'var foo = 3; foo' does not need checks because the receiver is the inner window object.
When an outer window is detached from its global context (when a frame navigates away from a page), it is completely detached from the inner window. A new context is created for the new page, and the outer global object is reused. At this point, the access check on the DOMWindow wrapper of the old context is turned on. The code in old context is still able to access DOMWindow properties, but it has to go through domain security checks.
It is debatable on how to implement the outer window object. Currently each property access function has to check if the receiver is ApiGlobalObject type. This approach might be error-prone that one may forget to check the receiver when adding new functions. It is unlikely a performance issue because accessing global variables are more common than 'window.foo' style coding.
I am still working on the ARM port, and I'd like to hear comments and suggestions on the best way to support it in V8.
Review URL: http://codereview.chromium.org/7366
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@540 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2008-10-21 19:07:58 +00:00
|
|
|
// JSGlobalProxy's prototype must be a JSGlobalObject or null,
|
|
|
|
// and the prototype is hidden. JSGlobalProxy always delegates
|
|
|
|
// property accesses to its prototype if the prototype is not null.
|
|
|
|
//
|
|
|
|
// A JSGlobalProxy can be reinitialized which will preserve its identity.
|
|
|
|
//
|
|
|
|
// Accessing a JSGlobalProxy requires security check.
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSGlobalProxy : public JSObject {
|
Split window support from V8.
Here is a description of the background and design of split window in Chrome and V8:
https://docs.google.com/a/google.com/Doc?id=chhjkpg_47fwddxbfr
This change list splits the window object into two parts: 1) an inner window object used as the global object of contexts; 2) an outer window object exposed to JavaScript and accessible by the name 'window'. Firefox did it awhile ago, here are some discussions: https://wiki.mozilla.org/Gecko:SplitWindow. One additional benefit of splitting window in Chrome is that accessing global variables don't need security checks anymore, it can improve applications that use many global variables.
V8 support of split window:
There are a small number of changes on V8 api to support split window:
Security context is removed from V8, so does related API functions;
A global object can be detached from its context and reused by a new context;
Access checks on an object template can be turned on/off by default;
An object can turn on its access checks later;
V8 has a new object type, ApiGlobalObject, which is the outer window object type. The existing JSGlobalObject becomes the inner window object type. Security checks are moved from JSGlobalObject to ApiGlobalObject. ApiGlobalObject is the one exposed to JavaScript, it is accessible through Context::Global(). ApiGlobalObject's prototype is set to JSGlobalObject so that property lookups are forwarded to JSGlobalObject. ApiGlobalObject forwards all other property access requests to JSGlobalObject, such as SetProperty, DeleteProperty, etc.
Security token is moved to a global context, and ApiGlobalObject has a reference to its global context. JSGlobalObject has a reference to its global context as well. When accessing properties on a global object in JavaScript, the domain security check is performed by comparing the security token of the lexical context (Top::global_context()) to the token of global object's context. The check is only needed when the receiver is a window object, such as 'window.document'. Accessing global variables, such as 'var foo = 3; foo' does not need checks because the receiver is the inner window object.
When an outer window is detached from its global context (when a frame navigates away from a page), it is completely detached from the inner window. A new context is created for the new page, and the outer global object is reused. At this point, the access check on the DOMWindow wrapper of the old context is turned on. The code in old context is still able to access DOMWindow properties, but it has to go through domain security checks.
It is debatable on how to implement the outer window object. Currently each property access function has to check if the receiver is ApiGlobalObject type. This approach might be error-prone that one may forget to check the receiver when adding new functions. It is unlikely a performance issue because accessing global variables are more common than 'window.foo' style coding.
I am still working on the ARM port, and I'd like to hear comments and suggestions on the best way to support it in V8.
Review URL: http://codereview.chromium.org/7366
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@540 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2008-10-21 19:07:58 +00:00
|
|
|
public:
|
2012-08-20 11:35:50 +00:00
|
|
|
// [native_context]: the owner native context of this global proxy object.
|
Split window support from V8.
Here is a description of the background and design of split window in Chrome and V8:
https://docs.google.com/a/google.com/Doc?id=chhjkpg_47fwddxbfr
This change list splits the window object into two parts: 1) an inner window object used as the global object of contexts; 2) an outer window object exposed to JavaScript and accessible by the name 'window'. Firefox did it awhile ago, here are some discussions: https://wiki.mozilla.org/Gecko:SplitWindow. One additional benefit of splitting window in Chrome is that accessing global variables don't need security checks anymore, it can improve applications that use many global variables.
V8 support of split window:
There are a small number of changes on V8 api to support split window:
Security context is removed from V8, so does related API functions;
A global object can be detached from its context and reused by a new context;
Access checks on an object template can be turned on/off by default;
An object can turn on its access checks later;
V8 has a new object type, ApiGlobalObject, which is the outer window object type. The existing JSGlobalObject becomes the inner window object type. Security checks are moved from JSGlobalObject to ApiGlobalObject. ApiGlobalObject is the one exposed to JavaScript, it is accessible through Context::Global(). ApiGlobalObject's prototype is set to JSGlobalObject so that property lookups are forwarded to JSGlobalObject. ApiGlobalObject forwards all other property access requests to JSGlobalObject, such as SetProperty, DeleteProperty, etc.
Security token is moved to a global context, and ApiGlobalObject has a reference to its global context. JSGlobalObject has a reference to its global context as well. When accessing properties on a global object in JavaScript, the domain security check is performed by comparing the security token of the lexical context (Top::global_context()) to the token of global object's context. The check is only needed when the receiver is a window object, such as 'window.document'. Accessing global variables, such as 'var foo = 3; foo' does not need checks because the receiver is the inner window object.
When an outer window is detached from its global context (when a frame navigates away from a page), it is completely detached from the inner window. A new context is created for the new page, and the outer global object is reused. At this point, the access check on the DOMWindow wrapper of the old context is turned on. The code in old context is still able to access DOMWindow properties, but it has to go through domain security checks.
It is debatable on how to implement the outer window object. Currently each property access function has to check if the receiver is ApiGlobalObject type. This approach might be error-prone that one may forget to check the receiver when adding new functions. It is unlikely a performance issue because accessing global variables are more common than 'window.foo' style coding.
I am still working on the ARM port, and I'd like to hear comments and suggestions on the best way to support it in V8.
Review URL: http://codereview.chromium.org/7366
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@540 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2008-10-21 19:07:58 +00:00
|
|
|
// It is null value if this object is not used by any context.
|
2012-08-20 11:35:50 +00:00
|
|
|
DECL_ACCESSORS(native_context, Object)
|
Split window support from V8.
Here is a description of the background and design of split window in Chrome and V8:
https://docs.google.com/a/google.com/Doc?id=chhjkpg_47fwddxbfr
This change list splits the window object into two parts: 1) an inner window object used as the global object of contexts; 2) an outer window object exposed to JavaScript and accessible by the name 'window'. Firefox did it awhile ago, here are some discussions: https://wiki.mozilla.org/Gecko:SplitWindow. One additional benefit of splitting window in Chrome is that accessing global variables don't need security checks anymore, it can improve applications that use many global variables.
V8 support of split window:
There are a small number of changes on V8 api to support split window:
Security context is removed from V8, so does related API functions;
A global object can be detached from its context and reused by a new context;
Access checks on an object template can be turned on/off by default;
An object can turn on its access checks later;
V8 has a new object type, ApiGlobalObject, which is the outer window object type. The existing JSGlobalObject becomes the inner window object type. Security checks are moved from JSGlobalObject to ApiGlobalObject. ApiGlobalObject is the one exposed to JavaScript, it is accessible through Context::Global(). ApiGlobalObject's prototype is set to JSGlobalObject so that property lookups are forwarded to JSGlobalObject. ApiGlobalObject forwards all other property access requests to JSGlobalObject, such as SetProperty, DeleteProperty, etc.
Security token is moved to a global context, and ApiGlobalObject has a reference to its global context. JSGlobalObject has a reference to its global context as well. When accessing properties on a global object in JavaScript, the domain security check is performed by comparing the security token of the lexical context (Top::global_context()) to the token of global object's context. The check is only needed when the receiver is a window object, such as 'window.document'. Accessing global variables, such as 'var foo = 3; foo' does not need checks because the receiver is the inner window object.
When an outer window is detached from its global context (when a frame navigates away from a page), it is completely detached from the inner window. A new context is created for the new page, and the outer global object is reused. At this point, the access check on the DOMWindow wrapper of the old context is turned on. The code in old context is still able to access DOMWindow properties, but it has to go through domain security checks.
It is debatable on how to implement the outer window object. Currently each property access function has to check if the receiver is ApiGlobalObject type. This approach might be error-prone that one may forget to check the receiver when adding new functions. It is unlikely a performance issue because accessing global variables are more common than 'window.foo' style coding.
I am still working on the ARM port, and I'd like to hear comments and suggestions on the best way to support it in V8.
Review URL: http://codereview.chromium.org/7366
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@540 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2008-10-21 19:07:58 +00:00
|
|
|
|
2014-05-05 18:27:57 +00:00
|
|
|
// [hash]: The hash code property (undefined if not initialized yet).
|
|
|
|
DECL_ACCESSORS(hash, Object)
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSGlobalProxy)
|
Split window support from V8.
Here is a description of the background and design of split window in Chrome and V8:
https://docs.google.com/a/google.com/Doc?id=chhjkpg_47fwddxbfr
This change list splits the window object into two parts: 1) an inner window object used as the global object of contexts; 2) an outer window object exposed to JavaScript and accessible by the name 'window'. Firefox did it awhile ago, here are some discussions: https://wiki.mozilla.org/Gecko:SplitWindow. One additional benefit of splitting window in Chrome is that accessing global variables don't need security checks anymore, it can improve applications that use many global variables.
V8 support of split window:
There are a small number of changes on V8 api to support split window:
Security context is removed from V8, so does related API functions;
A global object can be detached from its context and reused by a new context;
Access checks on an object template can be turned on/off by default;
An object can turn on its access checks later;
V8 has a new object type, ApiGlobalObject, which is the outer window object type. The existing JSGlobalObject becomes the inner window object type. Security checks are moved from JSGlobalObject to ApiGlobalObject. ApiGlobalObject is the one exposed to JavaScript, it is accessible through Context::Global(). ApiGlobalObject's prototype is set to JSGlobalObject so that property lookups are forwarded to JSGlobalObject. ApiGlobalObject forwards all other property access requests to JSGlobalObject, such as SetProperty, DeleteProperty, etc.
Security token is moved to a global context, and ApiGlobalObject has a reference to its global context. JSGlobalObject has a reference to its global context as well. When accessing properties on a global object in JavaScript, the domain security check is performed by comparing the security token of the lexical context (Top::global_context()) to the token of global object's context. The check is only needed when the receiver is a window object, such as 'window.document'. Accessing global variables, such as 'var foo = 3; foo' does not need checks because the receiver is the inner window object.
When an outer window is detached from its global context (when a frame navigates away from a page), it is completely detached from the inner window. A new context is created for the new page, and the outer global object is reused. At this point, the access check on the DOMWindow wrapper of the old context is turned on. The code in old context is still able to access DOMWindow properties, but it has to go through domain security checks.
It is debatable on how to implement the outer window object. Currently each property access function has to check if the receiver is ApiGlobalObject type. This approach might be error-prone that one may forget to check the receiver when adding new functions. It is unlikely a performance issue because accessing global variables are more common than 'window.foo' style coding.
I am still working on the ARM port, and I'd like to hear comments and suggestions on the best way to support it in V8.
Review URL: http://codereview.chromium.org/7366
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@540 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2008-10-21 19:07:58 +00:00
|
|
|
|
2015-11-02 14:57:59 +00:00
|
|
|
inline bool IsDetachedFrom(JSGlobalObject* global) const;
|
2013-12-11 13:51:48 +00:00
|
|
|
|
2017-03-17 13:26:05 +00:00
|
|
|
static int SizeWithEmbedderFields(int embedder_field_count);
|
2016-11-04 10:02:02 +00:00
|
|
|
|
Split window support from V8.
Here is a description of the background and design of split window in Chrome and V8:
https://docs.google.com/a/google.com/Doc?id=chhjkpg_47fwddxbfr
This change list splits the window object into two parts: 1) an inner window object used as the global object of contexts; 2) an outer window object exposed to JavaScript and accessible by the name 'window'. Firefox did it awhile ago, here are some discussions: https://wiki.mozilla.org/Gecko:SplitWindow. One additional benefit of splitting window in Chrome is that accessing global variables don't need security checks anymore, it can improve applications that use many global variables.
V8 support of split window:
There are a small number of changes on V8 api to support split window:
Security context is removed from V8, so does related API functions;
A global object can be detached from its context and reused by a new context;
Access checks on an object template can be turned on/off by default;
An object can turn on its access checks later;
V8 has a new object type, ApiGlobalObject, which is the outer window object type. The existing JSGlobalObject becomes the inner window object type. Security checks are moved from JSGlobalObject to ApiGlobalObject. ApiGlobalObject is the one exposed to JavaScript, it is accessible through Context::Global(). ApiGlobalObject's prototype is set to JSGlobalObject so that property lookups are forwarded to JSGlobalObject. ApiGlobalObject forwards all other property access requests to JSGlobalObject, such as SetProperty, DeleteProperty, etc.
Security token is moved to a global context, and ApiGlobalObject has a reference to its global context. JSGlobalObject has a reference to its global context as well. When accessing properties on a global object in JavaScript, the domain security check is performed by comparing the security token of the lexical context (Top::global_context()) to the token of global object's context. The check is only needed when the receiver is a window object, such as 'window.document'. Accessing global variables, such as 'var foo = 3; foo' does not need checks because the receiver is the inner window object.
When an outer window is detached from its global context (when a frame navigates away from a page), it is completely detached from the inner window. A new context is created for the new page, and the outer global object is reused. At this point, the access check on the DOMWindow wrapper of the old context is turned on. The code in old context is still able to access DOMWindow properties, but it has to go through domain security checks.
It is debatable on how to implement the outer window object. Currently each property access function has to check if the receiver is ApiGlobalObject type. This approach might be error-prone that one may forget to check the receiver when adding new functions. It is unlikely a performance issue because accessing global variables are more common than 'window.foo' style coding.
I am still working on the ARM port, and I'd like to hear comments and suggestions on the best way to support it in V8.
Review URL: http://codereview.chromium.org/7366
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@540 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2008-10-21 19:07:58 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSGlobalProxy)
|
|
|
|
DECL_VERIFIER(JSGlobalProxy)
|
Split window support from V8.
Here is a description of the background and design of split window in Chrome and V8:
https://docs.google.com/a/google.com/Doc?id=chhjkpg_47fwddxbfr
This change list splits the window object into two parts: 1) an inner window object used as the global object of contexts; 2) an outer window object exposed to JavaScript and accessible by the name 'window'. Firefox did it awhile ago, here are some discussions: https://wiki.mozilla.org/Gecko:SplitWindow. One additional benefit of splitting window in Chrome is that accessing global variables don't need security checks anymore, it can improve applications that use many global variables.
V8 support of split window:
There are a small number of changes on V8 api to support split window:
Security context is removed from V8, so does related API functions;
A global object can be detached from its context and reused by a new context;
Access checks on an object template can be turned on/off by default;
An object can turn on its access checks later;
V8 has a new object type, ApiGlobalObject, which is the outer window object type. The existing JSGlobalObject becomes the inner window object type. Security checks are moved from JSGlobalObject to ApiGlobalObject. ApiGlobalObject is the one exposed to JavaScript, it is accessible through Context::Global(). ApiGlobalObject's prototype is set to JSGlobalObject so that property lookups are forwarded to JSGlobalObject. ApiGlobalObject forwards all other property access requests to JSGlobalObject, such as SetProperty, DeleteProperty, etc.
Security token is moved to a global context, and ApiGlobalObject has a reference to its global context. JSGlobalObject has a reference to its global context as well. When accessing properties on a global object in JavaScript, the domain security check is performed by comparing the security token of the lexical context (Top::global_context()) to the token of global object's context. The check is only needed when the receiver is a window object, such as 'window.document'. Accessing global variables, such as 'var foo = 3; foo' does not need checks because the receiver is the inner window object.
When an outer window is detached from its global context (when a frame navigates away from a page), it is completely detached from the inner window. A new context is created for the new page, and the outer global object is reused. At this point, the access check on the DOMWindow wrapper of the old context is turned on. The code in old context is still able to access DOMWindow properties, but it has to go through domain security checks.
It is debatable on how to implement the outer window object. Currently each property access function has to check if the receiver is ApiGlobalObject type. This approach might be error-prone that one may forget to check the receiver when adding new functions. It is unlikely a performance issue because accessing global variables are more common than 'window.foo' style coding.
I am still working on the ARM port, and I'd like to hear comments and suggestions on the best way to support it in V8.
Review URL: http://codereview.chromium.org/7366
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@540 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2008-10-21 19:07:58 +00:00
|
|
|
|
|
|
|
// Layout description.
|
2012-08-20 11:35:50 +00:00
|
|
|
static const int kNativeContextOffset = JSObject::kHeaderSize;
|
2014-05-05 18:27:57 +00:00
|
|
|
static const int kHashOffset = kNativeContextOffset + kPointerSize;
|
|
|
|
static const int kSize = kHashOffset + kPointerSize;
|
Split window support from V8.
Here is a description of the background and design of split window in Chrome and V8:
https://docs.google.com/a/google.com/Doc?id=chhjkpg_47fwddxbfr
This change list splits the window object into two parts: 1) an inner window object used as the global object of contexts; 2) an outer window object exposed to JavaScript and accessible by the name 'window'. Firefox did it awhile ago, here are some discussions: https://wiki.mozilla.org/Gecko:SplitWindow. One additional benefit of splitting window in Chrome is that accessing global variables don't need security checks anymore, it can improve applications that use many global variables.
V8 support of split window:
There are a small number of changes on V8 api to support split window:
Security context is removed from V8, so does related API functions;
A global object can be detached from its context and reused by a new context;
Access checks on an object template can be turned on/off by default;
An object can turn on its access checks later;
V8 has a new object type, ApiGlobalObject, which is the outer window object type. The existing JSGlobalObject becomes the inner window object type. Security checks are moved from JSGlobalObject to ApiGlobalObject. ApiGlobalObject is the one exposed to JavaScript, it is accessible through Context::Global(). ApiGlobalObject's prototype is set to JSGlobalObject so that property lookups are forwarded to JSGlobalObject. ApiGlobalObject forwards all other property access requests to JSGlobalObject, such as SetProperty, DeleteProperty, etc.
Security token is moved to a global context, and ApiGlobalObject has a reference to its global context. JSGlobalObject has a reference to its global context as well. When accessing properties on a global object in JavaScript, the domain security check is performed by comparing the security token of the lexical context (Top::global_context()) to the token of global object's context. The check is only needed when the receiver is a window object, such as 'window.document'. Accessing global variables, such as 'var foo = 3; foo' does not need checks because the receiver is the inner window object.
When an outer window is detached from its global context (when a frame navigates away from a page), it is completely detached from the inner window. A new context is created for the new page, and the outer global object is reused. At this point, the access check on the DOMWindow wrapper of the old context is turned on. The code in old context is still able to access DOMWindow properties, but it has to go through domain security checks.
It is debatable on how to implement the outer window object. Currently each property access function has to check if the receiver is ApiGlobalObject type. This approach might be error-prone that one may forget to check the receiver when adding new functions. It is unlikely a performance issue because accessing global variables are more common than 'window.foo' style coding.
I am still working on the ARM port, and I'd like to hear comments and suggestions on the best way to support it in V8.
Review URL: http://codereview.chromium.org/7366
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@540 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2008-10-21 19:07:58 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-11-02 14:57:59 +00:00
|
|
|
// JavaScript global object.
|
|
|
|
class JSGlobalObject : public JSObject {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2012-08-17 09:03:08 +00:00
|
|
|
// [native context]: the natives corresponding to this global object.
|
|
|
|
DECL_ACCESSORS(native_context, Context)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-07-01 12:12:34 +00:00
|
|
|
// [global proxy]: the global proxy object of the context
|
|
|
|
DECL_ACCESSORS(global_proxy, JSObject)
|
Split window support from V8.
Here is a description of the background and design of split window in Chrome and V8:
https://docs.google.com/a/google.com/Doc?id=chhjkpg_47fwddxbfr
This change list splits the window object into two parts: 1) an inner window object used as the global object of contexts; 2) an outer window object exposed to JavaScript and accessible by the name 'window'. Firefox did it awhile ago, here are some discussions: https://wiki.mozilla.org/Gecko:SplitWindow. One additional benefit of splitting window in Chrome is that accessing global variables don't need security checks anymore, it can improve applications that use many global variables.
V8 support of split window:
There are a small number of changes on V8 api to support split window:
Security context is removed from V8, so does related API functions;
A global object can be detached from its context and reused by a new context;
Access checks on an object template can be turned on/off by default;
An object can turn on its access checks later;
V8 has a new object type, ApiGlobalObject, which is the outer window object type. The existing JSGlobalObject becomes the inner window object type. Security checks are moved from JSGlobalObject to ApiGlobalObject. ApiGlobalObject is the one exposed to JavaScript, it is accessible through Context::Global(). ApiGlobalObject's prototype is set to JSGlobalObject so that property lookups are forwarded to JSGlobalObject. ApiGlobalObject forwards all other property access requests to JSGlobalObject, such as SetProperty, DeleteProperty, etc.
Security token is moved to a global context, and ApiGlobalObject has a reference to its global context. JSGlobalObject has a reference to its global context as well. When accessing properties on a global object in JavaScript, the domain security check is performed by comparing the security token of the lexical context (Top::global_context()) to the token of global object's context. The check is only needed when the receiver is a window object, such as 'window.document'. Accessing global variables, such as 'var foo = 3; foo' does not need checks because the receiver is the inner window object.
When an outer window is detached from its global context (when a frame navigates away from a page), it is completely detached from the inner window. A new context is created for the new page, and the outer global object is reused. At this point, the access check on the DOMWindow wrapper of the old context is turned on. The code in old context is still able to access DOMWindow properties, but it has to go through domain security checks.
It is debatable on how to implement the outer window object. Currently each property access function has to check if the receiver is ApiGlobalObject type. This approach might be error-prone that one may forget to check the receiver when adding new functions. It is unlikely a performance issue because accessing global variables are more common than 'window.foo' style coding.
I am still working on the ARM port, and I'd like to hear comments and suggestions on the best way to support it in V8.
Review URL: http://codereview.chromium.org/7366
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@540 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2008-10-21 19:07:58 +00:00
|
|
|
|
2008-10-23 08:42:22 +00:00
|
|
|
|
2015-11-02 14:57:59 +00:00
|
|
|
static void InvalidatePropertyCell(Handle<JSGlobalObject> object,
|
2014-11-07 16:29:13 +00:00
|
|
|
Handle<Name> name);
|
2015-02-11 09:15:19 +00:00
|
|
|
// Ensure that the global object has a cell for the given property name.
|
2016-07-07 12:32:15 +00:00
|
|
|
static Handle<PropertyCell> EnsureEmptyPropertyCell(
|
|
|
|
Handle<JSGlobalObject> global, Handle<Name> name,
|
|
|
|
PropertyCellType cell_type, int* entry_out = nullptr);
|
2014-11-07 16:29:13 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSGlobalObject)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-12-11 13:51:48 +00:00
|
|
|
inline bool IsDetached();
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSGlobalObject)
|
|
|
|
DECL_VERIFIER(JSGlobalObject)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Layout description.
|
2015-11-02 14:57:59 +00:00
|
|
|
static const int kNativeContextOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kGlobalProxyOffset = kNativeContextOffset + kPointerSize;
|
|
|
|
static const int kHeaderSize = kGlobalProxyOffset + kPointerSize;
|
|
|
|
static const int kSize = kHeaderSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalObject);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-03-09 11:11:55 +00:00
|
|
|
// Representation for JS Wrapper objects, String, Number, Boolean, etc.
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSValue: public JSObject {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
// [value]: the object being wrapped.
|
|
|
|
DECL_ACCESSORS(value, Object)
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSValue)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSValue)
|
|
|
|
DECL_VERIFIER(JSValue)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Layout description.
|
|
|
|
static const int kValueOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kSize = kValueOffset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue);
|
|
|
|
};
|
|
|
|
|
2011-02-02 13:31:52 +00:00
|
|
|
|
2012-03-09 12:07:29 +00:00
|
|
|
class DateCache;
|
|
|
|
|
2012-03-09 11:11:55 +00:00
|
|
|
// Representation for JS date objects.
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSDate: public JSObject {
|
2012-03-09 11:11:55 +00:00
|
|
|
public:
|
2016-01-05 11:05:41 +00:00
|
|
|
static MUST_USE_RESULT MaybeHandle<JSDate> New(Handle<JSFunction> constructor,
|
|
|
|
Handle<JSReceiver> new_target,
|
|
|
|
double tv);
|
|
|
|
|
2012-03-09 11:11:55 +00:00
|
|
|
// If one component is NaN, all of them are, indicating a NaN time value.
|
|
|
|
// [value]: the time value.
|
|
|
|
DECL_ACCESSORS(value, Object)
|
|
|
|
// [year]: caches year. Either undefined, smi, or NaN.
|
|
|
|
DECL_ACCESSORS(year, Object)
|
|
|
|
// [month]: caches month. Either undefined, smi, or NaN.
|
|
|
|
DECL_ACCESSORS(month, Object)
|
|
|
|
// [day]: caches day. Either undefined, smi, or NaN.
|
|
|
|
DECL_ACCESSORS(day, Object)
|
2012-03-09 12:07:29 +00:00
|
|
|
// [weekday]: caches day of week. Either undefined, smi, or NaN.
|
|
|
|
DECL_ACCESSORS(weekday, Object)
|
2012-03-09 11:11:55 +00:00
|
|
|
// [hour]: caches hours. Either undefined, smi, or NaN.
|
|
|
|
DECL_ACCESSORS(hour, Object)
|
|
|
|
// [min]: caches minutes. Either undefined, smi, or NaN.
|
|
|
|
DECL_ACCESSORS(min, Object)
|
|
|
|
// [sec]: caches seconds. Either undefined, smi, or NaN.
|
|
|
|
DECL_ACCESSORS(sec, Object)
|
2012-03-09 12:07:29 +00:00
|
|
|
// [cache stamp]: sample of the date cache stamp at the
|
2014-05-22 15:27:57 +00:00
|
|
|
// moment when chached fields were cached.
|
2012-03-09 12:07:29 +00:00
|
|
|
DECL_ACCESSORS(cache_stamp, Object)
|
2012-03-09 11:11:55 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSDate)
|
2012-03-09 11:11:55 +00:00
|
|
|
|
2016-01-05 11:05:41 +00:00
|
|
|
// Returns the time value (UTC) identifying the current time.
|
|
|
|
static double CurrentTimeValue(Isolate* isolate);
|
|
|
|
|
2012-03-09 12:07:29 +00:00
|
|
|
// Returns the date field with the specified index.
|
|
|
|
// See FieldIndex for the list of date fields.
|
2012-05-09 14:34:27 +00:00
|
|
|
static Object* GetField(Object* date, Smi* index);
|
2012-03-09 12:07:29 +00:00
|
|
|
|
2016-01-12 10:47:27 +00:00
|
|
|
static Handle<Object> SetValue(Handle<JSDate> date, double v);
|
|
|
|
|
2012-03-09 12:07:29 +00:00
|
|
|
void SetValue(Object* value, bool is_value_nan);
|
|
|
|
|
2012-03-09 11:11:55 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSDate)
|
|
|
|
DECL_VERIFIER(JSDate)
|
2012-10-12 11:41:14 +00:00
|
|
|
|
2012-03-09 12:07:29 +00:00
|
|
|
// The order is important. It must be kept in sync with date macros
|
|
|
|
// in macros.py.
|
|
|
|
enum FieldIndex {
|
|
|
|
kDateValue,
|
|
|
|
kYear,
|
|
|
|
kMonth,
|
|
|
|
kDay,
|
|
|
|
kWeekday,
|
|
|
|
kHour,
|
|
|
|
kMinute,
|
|
|
|
kSecond,
|
|
|
|
kFirstUncachedField,
|
|
|
|
kMillisecond = kFirstUncachedField,
|
|
|
|
kDays,
|
|
|
|
kTimeInDay,
|
|
|
|
kFirstUTCField,
|
|
|
|
kYearUTC = kFirstUTCField,
|
|
|
|
kMonthUTC,
|
|
|
|
kDayUTC,
|
|
|
|
kWeekdayUTC,
|
|
|
|
kHourUTC,
|
|
|
|
kMinuteUTC,
|
|
|
|
kSecondUTC,
|
|
|
|
kMillisecondUTC,
|
|
|
|
kDaysUTC,
|
|
|
|
kTimeInDayUTC,
|
|
|
|
kTimezoneOffset
|
|
|
|
};
|
2012-03-09 11:11:55 +00:00
|
|
|
|
|
|
|
// Layout description.
|
|
|
|
static const int kValueOffset = JSObject::kHeaderSize;
|
2012-03-09 12:07:29 +00:00
|
|
|
static const int kYearOffset = kValueOffset + kPointerSize;
|
2012-03-09 11:11:55 +00:00
|
|
|
static const int kMonthOffset = kYearOffset + kPointerSize;
|
|
|
|
static const int kDayOffset = kMonthOffset + kPointerSize;
|
2012-03-09 12:07:29 +00:00
|
|
|
static const int kWeekdayOffset = kDayOffset + kPointerSize;
|
|
|
|
static const int kHourOffset = kWeekdayOffset + kPointerSize;
|
2012-03-09 11:11:55 +00:00
|
|
|
static const int kMinOffset = kHourOffset + kPointerSize;
|
|
|
|
static const int kSecOffset = kMinOffset + kPointerSize;
|
2012-03-09 12:07:29 +00:00
|
|
|
static const int kCacheStampOffset = kSecOffset + kPointerSize;
|
|
|
|
static const int kSize = kCacheStampOffset + kPointerSize;
|
2012-03-09 11:11:55 +00:00
|
|
|
|
|
|
|
private:
|
2012-03-09 12:07:29 +00:00
|
|
|
inline Object* DoGetField(FieldIndex index);
|
|
|
|
|
|
|
|
Object* GetUTCField(FieldIndex index, double value, DateCache* date_cache);
|
|
|
|
|
|
|
|
// Computes and caches the cacheable fields of the date.
|
2014-05-22 15:27:57 +00:00
|
|
|
inline void SetCachedFields(int64_t local_time_ms, DateCache* date_cache);
|
2012-03-09 12:07:29 +00:00
|
|
|
|
|
|
|
|
2012-03-09 11:11:55 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSDate);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-02-02 13:31:52 +00:00
|
|
|
// Representation of message objects used for error reporting through
|
|
|
|
// the API. The messages are formatted in JavaScript so this object is
|
|
|
|
// a real JavaScript object. The information used for formatting the
|
|
|
|
// error messages are not directly accessible from JavaScript to
|
|
|
|
// prevent leaking information to user code called during error
|
|
|
|
// formatting.
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSMessageObject: public JSObject {
|
2011-02-02 13:31:52 +00:00
|
|
|
public:
|
|
|
|
// [type]: the type of error message.
|
2015-05-18 08:34:05 +00:00
|
|
|
inline int type() const;
|
|
|
|
inline void set_type(int value);
|
2011-02-02 13:31:52 +00:00
|
|
|
|
|
|
|
// [arguments]: the arguments for formatting the error message.
|
2015-05-18 08:34:05 +00:00
|
|
|
DECL_ACCESSORS(argument, Object)
|
2011-02-02 13:31:52 +00:00
|
|
|
|
|
|
|
// [script]: the script from which the error message originated.
|
|
|
|
DECL_ACCESSORS(script, Object)
|
|
|
|
|
|
|
|
// [stack_frames]: an array of stack frames for this error object.
|
|
|
|
DECL_ACCESSORS(stack_frames, Object)
|
|
|
|
|
|
|
|
// [start_position]: the start position in the script for the error message.
|
2014-06-20 10:31:17 +00:00
|
|
|
inline int start_position() const;
|
2011-02-02 13:31:52 +00:00
|
|
|
inline void set_start_position(int value);
|
|
|
|
|
|
|
|
// [end_position]: the end position in the script for the error message.
|
2014-06-20 10:31:17 +00:00
|
|
|
inline int end_position() const;
|
2011-02-02 13:31:52 +00:00
|
|
|
inline void set_end_position(int value);
|
|
|
|
|
2016-08-10 09:58:09 +00:00
|
|
|
int GetLineNumber() const;
|
|
|
|
|
|
|
|
// Returns the offset of the given position within the containing line.
|
|
|
|
int GetColumnNumber() const;
|
|
|
|
|
|
|
|
// Returns the source code line containing the given source
|
|
|
|
// position, or the empty string if the position is invalid.
|
|
|
|
Handle<String> GetSourceLine() const;
|
|
|
|
|
2016-12-12 14:47:56 +00:00
|
|
|
inline int error_level() const;
|
|
|
|
inline void set_error_level(int level);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSMessageObject)
|
2011-02-02 13:31:52 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSMessageObject)
|
|
|
|
DECL_VERIFIER(JSMessageObject)
|
2011-02-02 13:31:52 +00:00
|
|
|
|
|
|
|
// Layout description.
|
|
|
|
static const int kTypeOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kArgumentsOffset = kTypeOffset + kPointerSize;
|
|
|
|
static const int kScriptOffset = kArgumentsOffset + kPointerSize;
|
2014-02-11 09:29:51 +00:00
|
|
|
static const int kStackFramesOffset = kScriptOffset + kPointerSize;
|
2011-02-02 13:31:52 +00:00
|
|
|
static const int kStartPositionOffset = kStackFramesOffset + kPointerSize;
|
|
|
|
static const int kEndPositionOffset = kStartPositionOffset + kPointerSize;
|
2016-12-12 14:47:56 +00:00
|
|
|
static const int kErrorLevelOffset = kEndPositionOffset + kPointerSize;
|
|
|
|
static const int kSize = kErrorLevelOffset + kPointerSize;
|
2011-02-02 13:31:52 +00:00
|
|
|
|
|
|
|
typedef FixedBodyDescriptor<HeapObject::kMapOffset,
|
|
|
|
kStackFramesOffset + kPointerSize,
|
|
|
|
kSize> BodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2011-02-02 13:31:52 +00:00
|
|
|
};
|
|
|
|
|
2017-01-02 17:22:30 +00:00
|
|
|
class JSPromise;
|
|
|
|
|
|
|
|
// TODO(caitp): Make this a Struct once properties are no longer accessed from
|
|
|
|
// JS
|
|
|
|
class JSPromiseCapability : public JSObject {
|
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSPromiseCapability)
|
2017-01-02 17:22:30 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(JSPromiseCapability)
|
2017-01-02 17:22:30 +00:00
|
|
|
|
|
|
|
DECL_ACCESSORS(promise, Object)
|
|
|
|
DECL_ACCESSORS(resolve, Object)
|
|
|
|
DECL_ACCESSORS(reject, Object)
|
|
|
|
|
|
|
|
static const int kPromiseOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kResolveOffset = kPromiseOffset + kPointerSize;
|
|
|
|
static const int kRejectOffset = kResolveOffset + kPointerSize;
|
|
|
|
static const int kSize = kRejectOffset + kPointerSize;
|
|
|
|
|
|
|
|
enum InObjectPropertyIndex {
|
|
|
|
kPromiseIndex,
|
|
|
|
kResolveIndex,
|
|
|
|
kRejectIndex,
|
|
|
|
kInObjectPropertyCount // Dummy.
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSPromiseCapability);
|
|
|
|
};
|
|
|
|
|
2016-12-06 18:42:49 +00:00
|
|
|
class JSPromise : public JSObject {
|
|
|
|
public:
|
|
|
|
DECL_INT_ACCESSORS(status)
|
|
|
|
DECL_ACCESSORS(result, Object)
|
|
|
|
|
|
|
|
// There are 3 possible states for these fields --
|
|
|
|
// 1) Undefined -- This is the zero state when there is no callback
|
2016-12-29 20:30:28 +00:00
|
|
|
// or deferred fields registered.
|
|
|
|
//
|
2017-02-13 06:31:11 +00:00
|
|
|
// 2) Object -- There is a single callback directly attached to the
|
2016-12-29 20:30:28 +00:00
|
|
|
// fulfill_reactions, reject_reactions and the deferred fields are
|
|
|
|
// directly attached to the slots. In this state, deferred_promise
|
|
|
|
// is a JSReceiver and deferred_on_{resolve, reject} are Callables.
|
|
|
|
//
|
2016-12-06 18:42:49 +00:00
|
|
|
// 3) FixedArray -- There is more than one callback and deferred
|
2016-12-29 20:30:28 +00:00
|
|
|
// fields attached to a FixedArray.
|
2017-02-13 06:31:11 +00:00
|
|
|
//
|
|
|
|
// The callback can be a Callable or a Symbol.
|
2016-12-29 20:30:28 +00:00
|
|
|
DECL_ACCESSORS(deferred_promise, Object)
|
|
|
|
DECL_ACCESSORS(deferred_on_resolve, Object)
|
|
|
|
DECL_ACCESSORS(deferred_on_reject, Object)
|
2016-12-06 18:42:49 +00:00
|
|
|
DECL_ACCESSORS(fulfill_reactions, Object)
|
|
|
|
DECL_ACCESSORS(reject_reactions, Object)
|
|
|
|
|
2016-12-08 06:12:35 +00:00
|
|
|
DECL_INT_ACCESSORS(flags)
|
|
|
|
|
|
|
|
// [has_handler]: Whether this promise has a reject handler or not.
|
|
|
|
DECL_BOOLEAN_ACCESSORS(has_handler)
|
|
|
|
|
2016-12-23 18:03:33 +00:00
|
|
|
// [handled_hint]: Whether this promise will be handled by a catch
|
|
|
|
// block in an async function.
|
|
|
|
DECL_BOOLEAN_ACCESSORS(handled_hint)
|
|
|
|
|
2016-12-06 18:42:49 +00:00
|
|
|
static const char* Status(int status);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSPromise)
|
2016-12-06 18:42:49 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSPromise)
|
|
|
|
DECL_VERIFIER(JSPromise)
|
2016-12-06 18:42:49 +00:00
|
|
|
|
|
|
|
// Layout description.
|
|
|
|
static const int kStatusOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kResultOffset = kStatusOffset + kPointerSize;
|
2016-12-29 20:30:28 +00:00
|
|
|
static const int kDeferredPromiseOffset = kResultOffset + kPointerSize;
|
|
|
|
static const int kDeferredOnResolveOffset =
|
|
|
|
kDeferredPromiseOffset + kPointerSize;
|
|
|
|
static const int kDeferredOnRejectOffset =
|
|
|
|
kDeferredOnResolveOffset + kPointerSize;
|
|
|
|
static const int kFulfillReactionsOffset =
|
|
|
|
kDeferredOnRejectOffset + kPointerSize;
|
2016-12-06 18:42:49 +00:00
|
|
|
static const int kRejectReactionsOffset =
|
|
|
|
kFulfillReactionsOffset + kPointerSize;
|
2016-12-08 06:12:35 +00:00
|
|
|
static const int kFlagsOffset = kRejectReactionsOffset + kPointerSize;
|
|
|
|
static const int kSize = kFlagsOffset + kPointerSize;
|
2017-05-23 17:54:12 +00:00
|
|
|
static const int kSizeWithEmbedderFields =
|
|
|
|
kSize + v8::Promise::kEmbedderFieldCount * kPointerSize;
|
2016-12-08 06:12:35 +00:00
|
|
|
|
|
|
|
// Flags layout.
|
|
|
|
static const int kHasHandlerBit = 0;
|
2016-12-23 18:03:33 +00:00
|
|
|
static const int kHandledHintBit = 1;
|
2016-12-06 18:42:49 +00:00
|
|
|
};
|
|
|
|
|
2008-09-23 11:45:43 +00:00
|
|
|
// Regular expressions
|
2009-03-11 14:00:55 +00:00
|
|
|
// The regular expression holds a single reference to a FixedArray in
|
|
|
|
// the kDataOffset field.
|
|
|
|
// The FixedArray contains the following data:
|
|
|
|
// - tag : type of regexp implementation (not compiled yet, atom or irregexp)
|
|
|
|
// - reference to the original source string
|
|
|
|
// - reference to the original flag string
|
|
|
|
// If it is an atom regexp
|
|
|
|
// - a reference to a literal string to search for
|
|
|
|
// If it is an irregexp regexp:
|
2014-09-10 12:38:12 +00:00
|
|
|
// - a reference to code for Latin1 inputs (bytecode or compiled), or a smi
|
2017-05-22 08:54:28 +00:00
|
|
|
// used for tracking the last usage (used for regexp code flushing).
|
2011-07-05 06:19:53 +00:00
|
|
|
// - a reference to code for UC16 inputs (bytecode or compiled), or a smi
|
2017-05-22 08:54:28 +00:00
|
|
|
// used for tracking the last usage (used for regexp code flushing).
|
2009-03-11 14:00:55 +00:00
|
|
|
// - max number of registers used by irregexp implementations.
|
|
|
|
// - number of capture registers (output values) of the regexp.
|
2015-11-25 14:21:38 +00:00
|
|
|
class JSRegExp: public JSObject {
|
2008-09-23 11:45:43 +00:00
|
|
|
public:
|
2008-11-25 11:07:48 +00:00
|
|
|
// Meaning of Type:
|
|
|
|
// NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet.
|
|
|
|
// ATOM: A simple string to match against using an indexOf operation.
|
|
|
|
// IRREGEXP: Compiled with Irregexp.
|
2009-02-25 08:08:01 +00:00
|
|
|
enum Type { NOT_COMPILED, ATOM, IRREGEXP };
|
2014-09-19 07:36:05 +00:00
|
|
|
enum Flag {
|
2015-11-25 13:46:09 +00:00
|
|
|
kNone = 0,
|
|
|
|
kGlobal = 1 << 0,
|
|
|
|
kIgnoreCase = 1 << 1,
|
|
|
|
kMultiline = 1 << 2,
|
|
|
|
kSticky = 1 << 3,
|
|
|
|
kUnicode = 1 << 4,
|
2017-03-31 09:20:13 +00:00
|
|
|
kDotAll = 1 << 5,
|
2017-04-25 09:35:22 +00:00
|
|
|
// Update FlagCount when adding new flags.
|
2008-10-24 08:40:02 +00:00
|
|
|
};
|
2015-11-25 13:46:09 +00:00
|
|
|
typedef base::Flags<Flag> Flags;
|
2008-09-23 11:45:43 +00:00
|
|
|
|
2017-04-25 09:35:22 +00:00
|
|
|
static int FlagCount() { return FLAG_harmony_regexp_dotall ? 6 : 5; }
|
|
|
|
|
2008-09-23 11:45:43 +00:00
|
|
|
DECL_ACCESSORS(data, Object)
|
2015-11-05 19:10:07 +00:00
|
|
|
DECL_ACCESSORS(flags, Object)
|
|
|
|
DECL_ACCESSORS(source, Object)
|
2008-09-23 11:45:43 +00:00
|
|
|
|
2016-09-26 07:40:24 +00:00
|
|
|
V8_EXPORT_PRIVATE static MaybeHandle<JSRegExp> New(Handle<String> source,
|
|
|
|
Flags flags);
|
2015-11-25 09:22:39 +00:00
|
|
|
static Handle<JSRegExp> Copy(Handle<JSRegExp> regexp);
|
2015-11-19 16:11:00 +00:00
|
|
|
|
2015-11-25 13:46:09 +00:00
|
|
|
static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp,
|
|
|
|
Handle<String> source, Flags flags);
|
2015-11-19 16:11:00 +00:00
|
|
|
static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp,
|
|
|
|
Handle<String> source,
|
|
|
|
Handle<String> flags_string);
|
|
|
|
|
2008-10-24 08:40:02 +00:00
|
|
|
inline Type TypeTag();
|
2017-03-28 09:09:42 +00:00
|
|
|
// Number of captures (without the match itself).
|
2009-03-13 10:22:38 +00:00
|
|
|
inline int CaptureCount();
|
2008-11-25 11:07:48 +00:00
|
|
|
inline Flags GetFlags();
|
|
|
|
inline String* Pattern();
|
2017-03-27 11:18:31 +00:00
|
|
|
inline Object* CaptureNameMap();
|
2008-10-24 08:40:02 +00:00
|
|
|
inline Object* DataAt(int index);
|
2009-03-11 14:00:55 +00:00
|
|
|
// Set implementation data after the object has been prepared.
|
|
|
|
inline void SetDataAt(int index, Object* value);
|
2011-07-05 06:19:53 +00:00
|
|
|
|
2016-10-10 13:56:46 +00:00
|
|
|
inline void SetLastIndex(int index);
|
|
|
|
inline Object* LastIndex();
|
|
|
|
|
2014-09-10 12:38:12 +00:00
|
|
|
static int code_index(bool is_latin1) {
|
|
|
|
if (is_latin1) {
|
|
|
|
return kIrregexpLatin1CodeIndex;
|
2009-07-07 09:29:41 +00:00
|
|
|
} else {
|
|
|
|
return kIrregexpUC16CodeIndex;
|
|
|
|
}
|
2009-07-07 08:11:19 +00:00
|
|
|
}
|
2008-10-24 08:40:02 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSRegExp)
|
2008-09-23 11:45:43 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSRegExp)
|
|
|
|
DECL_VERIFIER(JSRegExp)
|
2008-09-23 11:45:43 +00:00
|
|
|
|
2008-10-24 08:40:02 +00:00
|
|
|
static const int kDataOffset = JSObject::kHeaderSize;
|
2015-11-05 19:10:07 +00:00
|
|
|
static const int kSourceOffset = kDataOffset + kPointerSize;
|
|
|
|
static const int kFlagsOffset = kSourceOffset + kPointerSize;
|
|
|
|
static const int kSize = kFlagsOffset + kPointerSize;
|
2008-10-24 08:40:02 +00:00
|
|
|
|
2009-03-11 14:00:55 +00:00
|
|
|
// Indices in the data array.
|
2008-10-24 08:40:02 +00:00
|
|
|
static const int kTagIndex = 0;
|
|
|
|
static const int kSourceIndex = kTagIndex + 1;
|
|
|
|
static const int kFlagsIndex = kSourceIndex + 1;
|
2009-03-11 14:00:55 +00:00
|
|
|
static const int kDataIndex = kFlagsIndex + 1;
|
|
|
|
// The data fields are used in different ways depending on the
|
|
|
|
// value of the tag.
|
|
|
|
// Atom regexps (literal strings).
|
|
|
|
static const int kAtomPatternIndex = kDataIndex;
|
|
|
|
|
|
|
|
static const int kAtomDataSize = kAtomPatternIndex + 1;
|
|
|
|
|
2014-09-10 12:38:12 +00:00
|
|
|
// Irregexp compiled code or bytecode for Latin1. If compilation
|
2009-09-02 08:36:26 +00:00
|
|
|
// fails, this fields hold an exception object that should be
|
|
|
|
// thrown if the regexp is used again.
|
2014-09-10 12:38:12 +00:00
|
|
|
static const int kIrregexpLatin1CodeIndex = kDataIndex;
|
2009-09-02 08:36:26 +00:00
|
|
|
// Irregexp compiled code or bytecode for UC16. If compilation
|
|
|
|
// fails, this fields hold an exception object that should be
|
|
|
|
// thrown if the regexp is used again.
|
2009-03-11 14:00:55 +00:00
|
|
|
static const int kIrregexpUC16CodeIndex = kDataIndex + 1;
|
2014-09-10 12:38:12 +00:00
|
|
|
// Maximal number of registers used by either Latin1 or UC16.
|
2009-03-11 14:00:55 +00:00
|
|
|
// Only used to check that there is enough stack space
|
2017-07-05 08:05:36 +00:00
|
|
|
static const int kIrregexpMaxRegisterCountIndex = kDataIndex + 2;
|
2009-03-11 14:00:55 +00:00
|
|
|
// Number of captures in the compiled regexp.
|
2017-07-05 08:05:36 +00:00
|
|
|
static const int kIrregexpCaptureCountIndex = kDataIndex + 3;
|
2016-06-15 06:48:31 +00:00
|
|
|
// Maps names of named capture groups (at indices 2i) to their corresponding
|
2017-03-28 09:09:42 +00:00
|
|
|
// (1-based) capture group indices (at indices 2i + 1).
|
2017-07-05 08:05:36 +00:00
|
|
|
static const int kIrregexpCaptureNameMapIndex = kDataIndex + 4;
|
2009-03-11 14:00:55 +00:00
|
|
|
|
2016-06-15 06:48:31 +00:00
|
|
|
static const int kIrregexpDataSize = kIrregexpCaptureNameMapIndex + 1;
|
2010-01-06 11:09:30 +00:00
|
|
|
|
2010-03-26 14:19:47 +00:00
|
|
|
// In-object fields.
|
2015-11-05 19:10:07 +00:00
|
|
|
static const int kLastIndexFieldIndex = 0;
|
|
|
|
static const int kInObjectFieldCount = 1;
|
2011-07-05 06:19:53 +00:00
|
|
|
|
|
|
|
// The uninitialized value for a regexp code object.
|
|
|
|
static const int kUninitializedValue = -1;
|
2008-10-24 08:40:02 +00:00
|
|
|
};
|
|
|
|
|
2015-11-25 13:46:09 +00:00
|
|
|
DEFINE_OPERATORS_FOR_FLAGS(JSRegExp::Flags)
|
|
|
|
|
2017-04-18 12:46:39 +00:00
|
|
|
class TypeFeedbackInfo : public Tuple3 {
|
2012-02-20 12:57:23 +00:00
|
|
|
public:
|
|
|
|
inline int ic_total_count();
|
|
|
|
inline void set_ic_total_count(int count);
|
|
|
|
|
2012-03-27 12:19:50 +00:00
|
|
|
inline int ic_with_type_info_count();
|
2014-08-05 17:06:01 +00:00
|
|
|
inline void change_ic_with_type_info_count(int delta);
|
|
|
|
|
|
|
|
inline int ic_generic_count();
|
|
|
|
inline void change_ic_generic_count(int delta);
|
2012-08-23 21:08:58 +00:00
|
|
|
|
|
|
|
inline void initialize_storage();
|
|
|
|
|
|
|
|
inline void change_own_type_change_checksum();
|
|
|
|
inline int own_type_change_checksum();
|
|
|
|
|
|
|
|
inline void set_inlined_type_change_checksum(int checksum);
|
|
|
|
inline bool matches_inlined_type_change_checksum(int checksum);
|
2012-02-20 12:57:23 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(TypeFeedbackInfo)
|
2012-02-20 12:57:23 +00:00
|
|
|
|
2017-04-18 12:46:39 +00:00
|
|
|
static const int kStorage1Offset = kValue1Offset;
|
|
|
|
static const int kStorage2Offset = kValue2Offset;
|
|
|
|
static const int kStorage3Offset = kValue3Offset;
|
2014-02-10 21:38:17 +00:00
|
|
|
|
2012-02-20 12:57:23 +00:00
|
|
|
private:
|
2012-08-23 21:08:58 +00:00
|
|
|
static const int kTypeChangeChecksumBits = 7;
|
|
|
|
|
|
|
|
class ICTotalCountField: public BitField<int, 0,
|
|
|
|
kSmiValueSize - kTypeChangeChecksumBits> {}; // NOLINT
|
|
|
|
class OwnTypeChangeChecksum: public BitField<int,
|
|
|
|
kSmiValueSize - kTypeChangeChecksumBits,
|
|
|
|
kTypeChangeChecksumBits> {}; // NOLINT
|
|
|
|
class ICsWithTypeInfoCountField: public BitField<int, 0,
|
|
|
|
kSmiValueSize - kTypeChangeChecksumBits> {}; // NOLINT
|
|
|
|
class InlinedTypeChangeChecksum: public BitField<int,
|
|
|
|
kSmiValueSize - kTypeChangeChecksumBits,
|
|
|
|
kTypeChangeChecksumBits> {}; // NOLINT
|
|
|
|
|
2012-02-20 12:57:23 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(TypeFeedbackInfo);
|
|
|
|
};
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class AllocationSite: public Struct {
|
2013-01-08 09:03:16 +00:00
|
|
|
public:
|
2013-07-08 10:02:16 +00:00
|
|
|
static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024;
|
2013-11-27 14:03:40 +00:00
|
|
|
static const double kPretenureRatio;
|
|
|
|
static const int kPretenureMinimumCreated = 100;
|
|
|
|
|
|
|
|
// Values for pretenure decision field.
|
2014-01-13 10:28:01 +00:00
|
|
|
enum PretenureDecision {
|
2013-11-27 14:03:40 +00:00
|
|
|
kUndecided = 0,
|
|
|
|
kDontTenure = 1,
|
2014-06-03 07:55:38 +00:00
|
|
|
kMaybeTenure = 2,
|
|
|
|
kTenure = 3,
|
|
|
|
kZombie = 4,
|
2014-01-13 10:28:01 +00:00
|
|
|
kLastPretenureDecisionValue = kZombie
|
2013-11-27 14:03:40 +00:00
|
|
|
};
|
2013-07-08 10:02:16 +00:00
|
|
|
|
2014-06-03 07:55:38 +00:00
|
|
|
const char* PretenureDecisionName(PretenureDecision decision);
|
|
|
|
|
2013-07-08 15:00:12 +00:00
|
|
|
DECL_ACCESSORS(transition_info, Object)
|
2013-09-24 10:30:41 +00:00
|
|
|
// nested_site threads a list of sites that represent nested literals
|
|
|
|
// walked in a particular order. So [[1, 2], 1, 2] will have one
|
|
|
|
// nested_site, but [[1, 2], 3, [4]] will have a list of two.
|
|
|
|
DECL_ACCESSORS(nested_site, Object)
|
2015-09-28 13:10:13 +00:00
|
|
|
DECL_INT_ACCESSORS(pretenure_data)
|
|
|
|
DECL_INT_ACCESSORS(pretenure_create_count)
|
2013-09-19 14:13:34 +00:00
|
|
|
DECL_ACCESSORS(dependent_code, DependentCode)
|
2013-07-17 11:50:24 +00:00
|
|
|
DECL_ACCESSORS(weak_next, Object)
|
2013-01-08 09:03:16 +00:00
|
|
|
|
2013-09-19 14:13:34 +00:00
|
|
|
inline void Initialize();
|
2013-01-08 09:03:16 +00:00
|
|
|
|
2013-10-16 08:10:36 +00:00
|
|
|
// This method is expensive, it should only be called for reporting.
|
|
|
|
bool IsNestedSite();
|
|
|
|
|
2014-01-13 10:28:01 +00:00
|
|
|
// transition_info bitfields, for constructed array transition info.
|
2013-11-14 12:05:09 +00:00
|
|
|
class ElementsKindBits: public BitField<ElementsKind, 0, 15> {};
|
|
|
|
class UnusedBits: public BitField<int, 15, 14> {};
|
|
|
|
class DoNotInlineBit: public BitField<bool, 29, 1> {};
|
|
|
|
|
2014-01-13 10:28:01 +00:00
|
|
|
// Bitfields for pretenure_data
|
2014-06-03 07:55:38 +00:00
|
|
|
class MementoFoundCountBits: public BitField<int, 0, 26> {};
|
|
|
|
class PretenureDecisionBits: public BitField<PretenureDecision, 26, 3> {};
|
2014-02-17 12:15:16 +00:00
|
|
|
class DeoptDependentCodeBit: public BitField<bool, 29, 1> {};
|
2014-01-13 10:28:01 +00:00
|
|
|
STATIC_ASSERT(PretenureDecisionBits::kMax >= kLastPretenureDecisionValue);
|
|
|
|
|
2013-12-18 21:23:56 +00:00
|
|
|
// Increments the mementos found counter and returns true when the first
|
|
|
|
// memento was found for a given allocation site.
|
2016-01-12 11:45:46 +00:00
|
|
|
inline bool IncrementMementoFoundCount(int increment = 1);
|
2013-11-27 14:03:40 +00:00
|
|
|
|
|
|
|
inline void IncrementMementoCreateCount();
|
|
|
|
|
2014-01-10 12:11:54 +00:00
|
|
|
PretenureFlag GetPretenureMode();
|
|
|
|
|
|
|
|
void ResetPretenureDecision();
|
2013-11-27 14:03:40 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline PretenureDecision pretenure_decision();
|
|
|
|
inline void set_pretenure_decision(PretenureDecision decision);
|
2014-02-17 12:15:16 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool deopt_dependent_code();
|
|
|
|
inline void set_deopt_dependent_code(bool deopt);
|
2014-01-13 10:28:01 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline int memento_found_count();
|
2014-01-13 10:28:01 +00:00
|
|
|
inline void set_memento_found_count(int count);
|
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline int memento_create_count();
|
|
|
|
inline void set_memento_create_count(int count);
|
2014-01-13 10:28:01 +00:00
|
|
|
|
2013-11-27 14:03:40 +00:00
|
|
|
// The pretenuring decision is made during gc, and the zombie state allows
|
|
|
|
// us to recognize when an allocation site is just being kept alive because
|
|
|
|
// a later traversal of new space may discover AllocationMementos that point
|
|
|
|
// to this AllocationSite.
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool IsZombie();
|
2013-11-27 14:03:40 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool IsMaybeTenure();
|
2014-06-03 11:59:47 +00:00
|
|
|
|
2013-11-27 14:03:40 +00:00
|
|
|
inline void MarkZombie();
|
|
|
|
|
2014-06-03 07:55:38 +00:00
|
|
|
inline bool MakePretenureDecision(PretenureDecision current_decision,
|
|
|
|
double ratio,
|
|
|
|
bool maximum_size_scavenge);
|
|
|
|
|
|
|
|
inline bool DigestPretenuringFeedback(bool maximum_size_scavenge);
|
2013-11-27 14:03:40 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline ElementsKind GetElementsKind();
|
|
|
|
inline void SetElementsKind(ElementsKind kind);
|
2013-01-08 09:03:16 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool CanInlineCall();
|
|
|
|
inline void SetDoNotInlineCall();
|
2013-11-14 12:05:09 +00:00
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool SitePointsToLiteral();
|
2013-07-08 10:02:16 +00:00
|
|
|
|
2016-08-25 11:39:27 +00:00
|
|
|
template <AllocationSiteUpdateMode update_or_check =
|
|
|
|
AllocationSiteUpdateMode::kUpdate>
|
|
|
|
static bool DigestTransitionFeedback(Handle<AllocationSite> site,
|
2014-03-25 15:33:22 +00:00
|
|
|
ElementsKind to_kind);
|
2013-11-14 12:05:09 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(AllocationSite)
|
|
|
|
DECL_VERIFIER(AllocationSite)
|
2013-07-08 10:02:16 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(AllocationSite)
|
2017-06-20 09:57:21 +00:00
|
|
|
static inline bool ShouldTrack(ElementsKind boilerplate_elements_kind);
|
|
|
|
static bool ShouldTrack(ElementsKind from, ElementsKind to);
|
2013-08-28 08:39:43 +00:00
|
|
|
static inline bool CanTrack(InstanceType type);
|
2013-01-17 08:41:27 +00:00
|
|
|
|
2013-07-17 11:50:24 +00:00
|
|
|
static const int kTransitionInfoOffset = HeapObject::kHeaderSize;
|
2013-09-24 10:30:41 +00:00
|
|
|
static const int kNestedSiteOffset = kTransitionInfoOffset + kPointerSize;
|
2014-01-13 10:28:01 +00:00
|
|
|
static const int kPretenureDataOffset = kNestedSiteOffset + kPointerSize;
|
|
|
|
static const int kPretenureCreateCountOffset =
|
|
|
|
kPretenureDataOffset + kPointerSize;
|
2013-11-22 07:34:21 +00:00
|
|
|
static const int kDependentCodeOffset =
|
2014-01-13 10:28:01 +00:00
|
|
|
kPretenureCreateCountOffset + kPointerSize;
|
2013-09-19 14:13:34 +00:00
|
|
|
static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize;
|
2013-07-17 11:50:24 +00:00
|
|
|
static const int kSize = kWeakNextOffset + kPointerSize;
|
|
|
|
|
2013-11-19 10:17:33 +00:00
|
|
|
// During mark compact we need to take special care for the dependent code
|
|
|
|
// field.
|
|
|
|
static const int kPointerFieldsBeginOffset = kTransitionInfoOffset;
|
2015-02-12 13:21:06 +00:00
|
|
|
static const int kPointerFieldsEndOffset = kWeakNextOffset;
|
2013-11-19 10:17:33 +00:00
|
|
|
|
2017-06-14 09:46:34 +00:00
|
|
|
// Ignores weakness.
|
2016-02-22 13:47:39 +00:00
|
|
|
typedef FixedBodyDescriptor<HeapObject::kHeaderSize, kSize, kSize>
|
|
|
|
BodyDescriptor;
|
2013-07-17 11:50:24 +00:00
|
|
|
|
2017-06-14 09:46:34 +00:00
|
|
|
// Respects weakness.
|
|
|
|
typedef FixedBodyDescriptor<kPointerFieldsBeginOffset,
|
|
|
|
kPointerFieldsEndOffset, kSize>
|
|
|
|
BodyDescriptorWeak;
|
|
|
|
|
2013-07-08 10:02:16 +00:00
|
|
|
private:
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool PretenuringDecisionMade();
|
2013-11-27 14:03:40 +00:00
|
|
|
|
2013-07-08 10:02:16 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class AllocationMemento: public Struct {
|
2013-07-08 10:02:16 +00:00
|
|
|
public:
|
|
|
|
static const int kAllocationSiteOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kSize = kAllocationSiteOffset + kPointerSize;
|
|
|
|
|
|
|
|
DECL_ACCESSORS(allocation_site, Object)
|
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool IsValid();
|
|
|
|
inline AllocationSite* GetAllocationSite();
|
Reland of "[heap] Parallel newspace evacuation, semispace copy, and compaction \o/"
This reverts commit 85ba94f28ce4b5d64e4c148efb1fee85bdb6579b.
All parallelism can be turned off using --predictable, or --noparallel-compaction.
This patch completely parallelizes
- semispace copy: from space -> to space (within newspace)
- newspace evacuation: newspace -> oldspace
- oldspace compaction: oldspace -> oldspace
Previously newspace has been handled sequentially (semispace copy, newspace
evacuation) before compacting oldspace in parallel. However, on a high level
there are no dependencies between those two actions, hence we parallelize them
altogether. We base the number of evacuation tasks on the overall set of
to-be-processed pages (newspace + oldspace compaction pages).
Some low-level details:
- The hard cap on number of tasks has been lifted
- We cache store buffer entries locally before merging them back into the global
StoreBuffer in a finalization phase.
- We cache AllocationSite operations locally before merging them back into the
global pretenuring storage in a finalization phase.
- AllocationSite might be compacted while they would be needed for newspace
evacuation. To mitigate any problems we defer checking allocation sites for
newspace till merging locally buffered data.
CQ_EXTRA_TRYBOTS=tryserver.v8:v8_linux_arm64_gc_stress_dbg,v8_linux_gc_stress_dbg,v8_mac_gc_stress_dbg,v8_linux64_asan_rel,v8_linux64_tsan_rel,v8_mac64_asan_rel
BUG=chromium:524425
LOG=N
R=hpayer@chromium.org, ulan@chromium.org
Review URL: https://codereview.chromium.org/1640563004
Cr-Commit-Position: refs/heads/master@{#33552}
2016-01-27 13:23:54 +00:00
|
|
|
inline Address GetAllocationSiteUnchecked();
|
2013-07-08 10:02:16 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(AllocationMemento)
|
|
|
|
DECL_VERIFIER(AllocationMemento)
|
2013-07-08 10:02:16 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(AllocationMemento)
|
2013-01-08 09:03:16 +00:00
|
|
|
|
|
|
|
private:
|
2013-07-19 13:30:49 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationMemento);
|
2013-01-08 09:03:16 +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.
|
|
|
|
class Relocatable BASE_EMBEDDED {
|
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
|
|
|
template <typename T>
|
2013-08-20 10:52:23 +00:00
|
|
|
class VectorIterator {
|
2008-10-09 08:08:04 +00:00
|
|
|
public:
|
2008-10-10 08:33:06 +00:00
|
|
|
VectorIterator(T* d, int l) : data_(Vector<const T>(d, l)), index_(0) { }
|
|
|
|
explicit VectorIterator(Vector<const T> data) : data_(data), index_(0) { }
|
2008-10-09 08:08:04 +00:00
|
|
|
T GetNext() { return data_[index_++]; }
|
|
|
|
bool has_more() { return index_ < data_.length(); }
|
|
|
|
private:
|
2008-10-10 08:33:06 +00:00
|
|
|
Vector<const T> data_;
|
2008-10-09 08:08:04 +00:00
|
|
|
int index_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
DECL_ACCESSORS(to_string, String)
|
|
|
|
|
|
|
|
// [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.
|
|
|
|
DECL_ACCESSORS(type_of, String)
|
|
|
|
|
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.
|
|
|
|
MUST_USE_RESULT static inline Handle<Object> ToNumber(Handle<Oddball> input);
|
|
|
|
|
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;
|
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;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2010-08-11 14:30:14 +00:00
|
|
|
|
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;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2010-08-11 14:30:14 +00:00
|
|
|
|
2009-06-30 10:05:36 +00:00
|
|
|
private:
|
2013-06-12 15:03:44 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Cell);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-03-18 12:54:02 +00:00
|
|
|
class PropertyCell : public HeapObject {
|
2013-06-12 15:03:44 +00:00
|
|
|
public:
|
2017-06-27 11:57:13 +00:00
|
|
|
// [name]: the name of the global property.
|
|
|
|
DECL_ACCESSORS(name, Name)
|
2015-06-02 10:29:12 +00:00
|
|
|
// [property_details]: details of the global property.
|
|
|
|
DECL_ACCESSORS(property_details_raw, Object)
|
2015-03-18 11:43:51 +00:00
|
|
|
// [value]: value of the global property.
|
|
|
|
DECL_ACCESSORS(value, Object)
|
2013-06-26 16:17:12 +00:00
|
|
|
// [dependent_code]: dependent code that depends on the type of the global
|
|
|
|
// property.
|
|
|
|
DECL_ACCESSORS(dependent_code, DependentCode)
|
|
|
|
|
2015-08-13 11:49:01 +00:00
|
|
|
inline PropertyDetails property_details();
|
|
|
|
inline void set_property_details(PropertyDetails details);
|
2015-06-02 10:29:12 +00:00
|
|
|
|
2015-04-27 14:01:15 +00:00
|
|
|
PropertyCellConstantType GetConstantType();
|
|
|
|
|
2013-10-21 13:55:24 +00:00
|
|
|
// Computes the new type of the cell's contents for the given value, but
|
2015-03-17 13:27:25 +00:00
|
|
|
// without actually modifying the details.
|
|
|
|
static PropertyCellType UpdatedType(Handle<PropertyCell> cell,
|
|
|
|
Handle<Object> value,
|
|
|
|
PropertyDetails details);
|
2016-07-07 12:32:15 +00:00
|
|
|
// Prepares property cell at given entry for receiving given value.
|
|
|
|
// As a result the old cell could be invalidated and/or dependent code could
|
|
|
|
// be deoptimized. Returns the prepared property cell.
|
|
|
|
static Handle<PropertyCell> PrepareForValue(
|
|
|
|
Handle<GlobalDictionary> dictionary, int entry, Handle<Object> value,
|
|
|
|
PropertyDetails details);
|
2015-03-17 13:27:25 +00:00
|
|
|
|
2015-06-01 16:24:59 +00:00
|
|
|
static Handle<PropertyCell> InvalidateEntry(
|
|
|
|
Handle<GlobalDictionary> dictionary, int entry);
|
2013-10-21 13:55:24 +00:00
|
|
|
|
2015-04-22 10:35:23 +00:00
|
|
|
static void SetValueWithInvalidation(Handle<PropertyCell> cell,
|
|
|
|
Handle<Object> new_value);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(PropertyCell)
|
2013-06-12 15:03:44 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(PropertyCell)
|
|
|
|
DECL_VERIFIER(PropertyCell)
|
2013-06-12 15:03:44 +00:00
|
|
|
|
|
|
|
// Layout description.
|
2015-06-02 10:29:12 +00:00
|
|
|
static const int kDetailsOffset = HeapObject::kHeaderSize;
|
2017-06-27 11:57:13 +00:00
|
|
|
static const int kNameOffset = kDetailsOffset + kPointerSize;
|
|
|
|
static const int kValueOffset = kNameOffset + kPointerSize;
|
2015-03-17 13:27:25 +00:00
|
|
|
static const int kDependentCodeOffset = kValueOffset + kPointerSize;
|
2013-06-26 16:17:12 +00:00
|
|
|
static const int kSize = kDependentCodeOffset + kPointerSize;
|
|
|
|
|
2017-06-27 11:57:13 +00:00
|
|
|
typedef FixedBodyDescriptor<kNameOffset, kSize, kSize> BodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2013-06-26 16:17:12 +00:00
|
|
|
|
2013-06-12 15:03:44 +00:00
|
|
|
private:
|
2013-06-14 16:06:12 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(PropertyCell);
|
2009-06-30 10:05:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-10-14 14:43:45 +00:00
|
|
|
class WeakCell : public HeapObject {
|
|
|
|
public:
|
2014-10-21 09:42:16 +00:00
|
|
|
inline Object* value() const;
|
2014-10-14 14:43:45 +00:00
|
|
|
|
|
|
|
// This should not be called by anyone except GC.
|
2014-10-21 09:42:16 +00:00
|
|
|
inline void clear();
|
2014-10-14 14:43:45 +00:00
|
|
|
|
|
|
|
// This should not be called by anyone except allocator.
|
|
|
|
inline void initialize(HeapObject* value);
|
|
|
|
|
2014-10-21 09:42:16 +00:00
|
|
|
inline bool cleared() const;
|
|
|
|
|
2014-10-14 14:43:45 +00:00
|
|
|
DECL_ACCESSORS(next, Object)
|
|
|
|
|
2015-12-08 20:50:50 +00:00
|
|
|
inline void clear_next(Object* the_hole_value);
|
2015-06-24 14:26:31 +00:00
|
|
|
|
|
|
|
inline bool next_cleared();
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(WeakCell)
|
2014-10-14 14:43:45 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(WeakCell)
|
|
|
|
DECL_VERIFIER(WeakCell)
|
2014-10-14 14:43:45 +00:00
|
|
|
|
|
|
|
// Layout description.
|
|
|
|
static const int kValueOffset = HeapObject::kHeaderSize;
|
|
|
|
static const int kNextOffset = kValueOffset + kPointerSize;
|
|
|
|
static const int kSize = kNextOffset + kPointerSize;
|
|
|
|
|
|
|
|
typedef FixedBodyDescriptor<kValueOffset, kSize, kSize> BodyDescriptor;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(WeakCell);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-05-13 10:58:25 +00:00
|
|
|
// The JSProxy describes EcmaScript Harmony proxies
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSProxy: public JSReceiver {
|
2011-05-13 10:58:25 +00:00
|
|
|
public:
|
2015-12-22 16:36:47 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<JSProxy> New(Isolate* isolate,
|
|
|
|
Handle<Object>,
|
|
|
|
Handle<Object>);
|
|
|
|
|
2011-05-13 10:58:25 +00:00
|
|
|
// [handler]: The handler property.
|
|
|
|
DECL_ACCESSORS(handler, Object)
|
2015-11-13 14:13:50 +00:00
|
|
|
// [target]: The target property.
|
2015-12-04 10:55:21 +00:00
|
|
|
DECL_ACCESSORS(target, JSReceiver)
|
2011-09-22 13:54:53 +00:00
|
|
|
// [hash]: The hash code property (undefined if not initialized yet).
|
|
|
|
DECL_ACCESSORS(hash, Object)
|
|
|
|
|
2015-11-27 12:16:32 +00:00
|
|
|
static MaybeHandle<Context> GetFunctionRealm(Handle<JSProxy> proxy);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSProxy)
|
2011-05-13 10:58:25 +00:00
|
|
|
|
2015-12-04 10:55:21 +00:00
|
|
|
INLINE(bool IsRevoked() const);
|
|
|
|
static void Revoke(Handle<JSProxy> proxy);
|
2015-11-24 14:15:58 +00:00
|
|
|
|
2015-11-16 11:59:33 +00:00
|
|
|
// ES6 9.5.1
|
2015-11-13 14:13:50 +00:00
|
|
|
static MaybeHandle<Object> GetPrototype(Handle<JSProxy> receiver);
|
|
|
|
|
2015-12-01 15:59:34 +00:00
|
|
|
// ES6 9.5.2
|
|
|
|
MUST_USE_RESULT static Maybe<bool> SetPrototype(Handle<JSProxy> proxy,
|
|
|
|
Handle<Object> value,
|
|
|
|
bool from_javascript,
|
|
|
|
ShouldThrow should_throw);
|
2015-11-24 14:15:58 +00:00
|
|
|
// ES6 9.5.3
|
|
|
|
MUST_USE_RESULT static Maybe<bool> IsExtensible(Handle<JSProxy> proxy);
|
|
|
|
|
2017-06-06 15:55:33 +00:00
|
|
|
// ES6, #sec-isarray. NOT to be confused with %_IsArray.
|
|
|
|
MUST_USE_RESULT static Maybe<bool> IsArray(Handle<JSProxy> proxy);
|
|
|
|
|
2015-11-24 14:15:58 +00:00
|
|
|
// ES6 9.5.4 (when passed DONT_THROW)
|
|
|
|
MUST_USE_RESULT static Maybe<bool> PreventExtensions(
|
|
|
|
Handle<JSProxy> proxy, ShouldThrow should_throw);
|
|
|
|
|
2015-11-16 11:59:33 +00:00
|
|
|
// ES6 9.5.5
|
2015-12-09 18:06:49 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> GetOwnPropertyDescriptor(
|
|
|
|
Isolate* isolate, Handle<JSProxy> proxy, Handle<Name> name,
|
|
|
|
PropertyDescriptor* desc);
|
2015-11-16 11:59:33 +00:00
|
|
|
|
2015-11-19 09:21:07 +00:00
|
|
|
// ES6 9.5.6
|
2015-12-09 18:06:49 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> DefineOwnProperty(
|
|
|
|
Isolate* isolate, Handle<JSProxy> object, Handle<Object> key,
|
|
|
|
PropertyDescriptor* desc, ShouldThrow should_throw);
|
2015-11-19 09:21:07 +00:00
|
|
|
|
2015-11-30 09:20:24 +00:00
|
|
|
// ES6 9.5.7
|
|
|
|
MUST_USE_RESULT static Maybe<bool> HasProperty(Isolate* isolate,
|
|
|
|
Handle<JSProxy> proxy,
|
|
|
|
Handle<Name> name);
|
|
|
|
|
2015-12-01 14:04:16 +00:00
|
|
|
// ES6 9.5.8
|
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> GetProperty(
|
|
|
|
Isolate* isolate, Handle<JSProxy> proxy, Handle<Name> name,
|
2016-04-28 08:24:34 +00:00
|
|
|
Handle<Object> receiver, bool* was_found);
|
2015-12-01 14:04:16 +00:00
|
|
|
|
|
|
|
// ES6 9.5.9
|
|
|
|
MUST_USE_RESULT static Maybe<bool> SetProperty(Handle<JSProxy> proxy,
|
|
|
|
Handle<Name> name,
|
|
|
|
Handle<Object> value,
|
|
|
|
Handle<Object> receiver,
|
|
|
|
LanguageMode language_mode);
|
|
|
|
|
2015-11-26 09:34:11 +00:00
|
|
|
// ES6 9.5.10 (when passed SLOPPY)
|
|
|
|
MUST_USE_RESULT static Maybe<bool> DeletePropertyOrElement(
|
|
|
|
Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode);
|
|
|
|
|
2015-11-28 15:02:59 +00:00
|
|
|
// ES6 9.5.12
|
2015-12-09 18:06:49 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> OwnPropertyKeys(
|
|
|
|
Isolate* isolate, Handle<JSReceiver> receiver, Handle<JSProxy> proxy,
|
|
|
|
PropertyFilter filter, KeyAccumulator* accumulator);
|
2015-11-28 15:02:59 +00:00
|
|
|
|
2015-11-19 09:21:07 +00:00
|
|
|
MUST_USE_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes(
|
|
|
|
LookupIterator* it);
|
|
|
|
|
2011-05-13 10:58:25 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSProxy)
|
|
|
|
DECL_VERIFIER(JSProxy)
|
2011-05-13 10:58:25 +00:00
|
|
|
|
2017-06-06 15:55:33 +00:00
|
|
|
static const int kMaxIterationLimit = 100 * 1024;
|
|
|
|
|
2016-01-12 15:43:41 +00:00
|
|
|
// Layout description.
|
|
|
|
static const int kTargetOffset = JSReceiver::kHeaderSize;
|
2015-11-12 22:11:53 +00:00
|
|
|
static const int kHandlerOffset = kTargetOffset + kPointerSize;
|
2011-09-22 13:54:53 +00:00
|
|
|
static const int kHashOffset = kHandlerOffset + kPointerSize;
|
2015-11-12 22:11:53 +00:00
|
|
|
static const int kSize = kHashOffset + kPointerSize;
|
2011-05-13 10:58:25 +00:00
|
|
|
|
2016-01-12 15:43:41 +00:00
|
|
|
typedef FixedBodyDescriptor<JSReceiver::kPropertiesOffset, kSize, kSize>
|
|
|
|
BodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2011-05-13 10:58:25 +00:00
|
|
|
|
2016-06-07 13:51:11 +00:00
|
|
|
static Object* GetIdentityHash(Handle<JSProxy> receiver);
|
2015-11-13 14:13:50 +00:00
|
|
|
|
2016-06-07 13:51:11 +00:00
|
|
|
static Smi* GetOrCreateIdentityHash(Isolate* isolate, Handle<JSProxy> proxy);
|
2015-11-13 14:13:50 +00:00
|
|
|
|
2016-02-18 08:48:33 +00:00
|
|
|
static Maybe<bool> SetPrivateProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
2016-01-18 12:41:09 +00:00
|
|
|
Handle<Symbol> private_name,
|
|
|
|
PropertyDescriptor* desc,
|
|
|
|
ShouldThrow should_throw);
|
|
|
|
|
2016-02-18 08:48:33 +00:00
|
|
|
private:
|
2011-05-13 10:58:25 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-07-10 10:54:47 +00:00
|
|
|
class JSCollection : public JSObject {
|
2011-10-25 14:14:56 +00:00
|
|
|
public:
|
2014-07-10 10:54:47 +00:00
|
|
|
// [table]: the backing hash table
|
2011-10-25 14:14:56 +00:00
|
|
|
DECL_ACCESSORS(table, Object)
|
|
|
|
|
2014-07-10 10:54:47 +00:00
|
|
|
static const int kTableOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kSize = kTableOffset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSCollection);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// The JSSet describes EcmaScript Harmony sets
|
2017-04-06 08:32:57 +00:00
|
|
|
// TODO(marja): When moving JSSet out of objects.h, move JSSetIterator (from
|
|
|
|
// objects/hash-table.h) into the same file.
|
2014-07-10 10:54:47 +00:00
|
|
|
class JSSet : public JSCollection {
|
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSSet)
|
2011-10-25 14:14:56 +00:00
|
|
|
|
2015-08-26 12:46:10 +00:00
|
|
|
static void Initialize(Handle<JSSet> set, Isolate* isolate);
|
|
|
|
static void Clear(Handle<JSSet> set);
|
|
|
|
|
2012-12-13 10:17:37 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSSet)
|
|
|
|
DECL_VERIFIER(JSSet)
|
2011-10-25 14:14:56 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSSet);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// The JSMap describes EcmaScript Harmony maps
|
2017-04-06 08:32:57 +00:00
|
|
|
// TODO(marja): When moving JSMap out of objects.h, move JSMapIterator (from
|
|
|
|
// objects/hash-table.h) into the same file.
|
2014-07-10 10:54:47 +00:00
|
|
|
class JSMap : public JSCollection {
|
2011-10-25 14:14:56 +00:00
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSMap)
|
2011-10-25 14:14:56 +00:00
|
|
|
|
2015-08-26 12:46:10 +00:00
|
|
|
static void Initialize(Handle<JSMap> map, Isolate* isolate);
|
|
|
|
static void Clear(Handle<JSMap> map);
|
|
|
|
|
2012-12-13 10:17:37 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSMap)
|
|
|
|
DECL_VERIFIER(JSMap)
|
2011-10-25 14:14:56 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSMap);
|
|
|
|
};
|
|
|
|
|
2016-10-18 02:42:42 +00:00
|
|
|
class JSArrayIterator : public JSObject {
|
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSArrayIterator)
|
|
|
|
DECL_VERIFIER(JSArrayIterator)
|
2016-10-18 02:42:42 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSArrayIterator)
|
2016-10-18 02:42:42 +00:00
|
|
|
|
2017-03-17 13:26:05 +00:00
|
|
|
// [object]: the [[IteratedObject]] inobject property.
|
2016-10-18 02:42:42 +00:00
|
|
|
DECL_ACCESSORS(object, Object)
|
|
|
|
|
2017-03-17 13:26:05 +00:00
|
|
|
// [index]: The [[ArrayIteratorNextIndex]] inobject property.
|
2016-10-18 02:42:42 +00:00
|
|
|
DECL_ACCESSORS(index, Object)
|
|
|
|
|
|
|
|
// [map]: The Map of the [[IteratedObject]] field at the time the iterator is
|
|
|
|
// allocated.
|
|
|
|
DECL_ACCESSORS(object_map, Object)
|
|
|
|
|
2016-11-14 15:58:48 +00:00
|
|
|
// Return the ElementsKind that a JSArrayIterator's [[IteratedObject]] is
|
|
|
|
// expected to have, based on its instance type.
|
|
|
|
static ElementsKind ElementsKindForInstanceType(InstanceType instance_type);
|
|
|
|
|
2016-10-18 02:42:42 +00:00
|
|
|
static const int kIteratedObjectOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kNextIndexOffset = kIteratedObjectOffset + kPointerSize;
|
|
|
|
static const int kIteratedObjectMapOffset = kNextIndexOffset + kPointerSize;
|
|
|
|
static const int kSize = kIteratedObjectMapOffset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayIterator);
|
|
|
|
};
|
|
|
|
|
2017-02-24 17:48:49 +00:00
|
|
|
// The [Async-from-Sync Iterator] object
|
|
|
|
// (proposal-async-iteration/#sec-async-from-sync-iterator-objects)
|
|
|
|
// An object which wraps an ordinary Iterator and converts it to behave
|
|
|
|
// according to the Async Iterator protocol.
|
|
|
|
// (See https://tc39.github.io/proposal-async-iteration/#sec-iteration)
|
|
|
|
class JSAsyncFromSyncIterator : public JSObject {
|
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSAsyncFromSyncIterator)
|
|
|
|
DECL_PRINTER(JSAsyncFromSyncIterator)
|
|
|
|
DECL_VERIFIER(JSAsyncFromSyncIterator)
|
2017-02-24 17:48:49 +00:00
|
|
|
|
|
|
|
// Async-from-Sync Iterator instances are ordinary objects that inherit
|
|
|
|
// properties from the %AsyncFromSyncIteratorPrototype% intrinsic object.
|
|
|
|
// Async-from-Sync Iterator instances are initially created with the internal
|
|
|
|
// slots listed in Table 4.
|
|
|
|
// (proposal-async-iteration/#table-async-from-sync-iterator-internal-slots)
|
|
|
|
DECL_ACCESSORS(sync_iterator, JSReceiver)
|
|
|
|
|
|
|
|
// Offsets of object fields.
|
|
|
|
static const int kSyncIteratorOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kSize = kSyncIteratorOffset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSAsyncFromSyncIterator);
|
|
|
|
};
|
|
|
|
|
2016-09-21 14:17:42 +00:00
|
|
|
class JSStringIterator : public JSObject {
|
|
|
|
public:
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSStringIterator)
|
|
|
|
DECL_VERIFIER(JSStringIterator)
|
2016-09-21 14:17:42 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSStringIterator)
|
2016-09-21 14:17:42 +00:00
|
|
|
|
2017-03-17 13:26:05 +00:00
|
|
|
// [string]: the [[IteratedString]] inobject property.
|
2016-09-21 14:17:42 +00:00
|
|
|
DECL_ACCESSORS(string, String)
|
|
|
|
|
2017-03-17 13:26:05 +00:00
|
|
|
// [index]: The [[StringIteratorNextIndex]] inobject property.
|
2016-09-21 14:17:42 +00:00
|
|
|
inline int index() const;
|
|
|
|
inline void set_index(int value);
|
|
|
|
|
|
|
|
static const int kStringOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kNextIndexOffset = kStringOffset + kPointerSize;
|
|
|
|
static const int kSize = kNextIndexOffset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSStringIterator);
|
|
|
|
};
|
2011-10-25 14:14:56 +00:00
|
|
|
|
2013-07-22 08:32:24 +00:00
|
|
|
// Base class for both JSWeakMap and JSWeakSet
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSWeakCollection: public JSObject {
|
2011-08-03 11:55:13 +00:00
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSWeakCollection)
|
2016-07-13 14:53:55 +00:00
|
|
|
|
2011-08-03 11:55:13 +00:00
|
|
|
// [table]: the backing hash table mapping keys to values.
|
2011-10-04 15:54:57 +00:00
|
|
|
DECL_ACCESSORS(table, Object)
|
2011-08-03 11:55:13 +00:00
|
|
|
|
2011-08-03 12:48:30 +00:00
|
|
|
// [next]: linked list of encountered weak maps during GC.
|
|
|
|
DECL_ACCESSORS(next, Object)
|
|
|
|
|
2015-08-26 13:18:46 +00:00
|
|
|
static void Initialize(Handle<JSWeakCollection> collection, Isolate* isolate);
|
|
|
|
static void Set(Handle<JSWeakCollection> collection, Handle<Object> key,
|
2017-06-15 21:35:42 +00:00
|
|
|
Handle<Object> value, int32_t hash);
|
|
|
|
static bool Delete(Handle<JSWeakCollection> collection, Handle<Object> key,
|
|
|
|
int32_t hash);
|
2017-02-07 07:46:21 +00:00
|
|
|
static Handle<JSArray> GetEntries(Handle<JSWeakCollection> holder,
|
|
|
|
int max_entries);
|
2015-08-26 13:18:46 +00:00
|
|
|
|
2013-07-22 08:32:24 +00:00
|
|
|
static const int kTableOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kNextOffset = kTableOffset + kPointerSize;
|
|
|
|
static const int kSize = kNextOffset + kPointerSize;
|
|
|
|
|
2015-11-25 15:22:24 +00:00
|
|
|
// Visiting policy defines whether the table and next collection fields
|
|
|
|
// should be visited or not.
|
2017-06-14 09:46:34 +00:00
|
|
|
enum BodyVisitingPolicy { kIgnoreWeakness, kRespectWeakness };
|
2015-11-25 15:22:24 +00:00
|
|
|
|
|
|
|
// Iterates the function object according to the visiting policy.
|
|
|
|
template <BodyVisitingPolicy>
|
|
|
|
class BodyDescriptorImpl;
|
|
|
|
|
|
|
|
// Visit the whole object.
|
2017-06-14 09:46:34 +00:00
|
|
|
typedef BodyDescriptorImpl<kIgnoreWeakness> BodyDescriptor;
|
2015-11-25 15:22:24 +00:00
|
|
|
|
|
|
|
// Don't visit table and next collection fields.
|
2017-06-14 09:46:34 +00:00
|
|
|
typedef BodyDescriptorImpl<kRespectWeakness> BodyDescriptorWeak;
|
2015-11-13 12:32:08 +00:00
|
|
|
|
2013-07-22 08:32:24 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakCollection);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// The JSWeakMap describes EcmaScript Harmony weak maps
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSWeakMap: public JSWeakCollection {
|
2013-07-22 08:32:24 +00:00
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSWeakMap)
|
2011-08-03 11:55:13 +00:00
|
|
|
|
2012-12-13 10:17:37 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSWeakMap)
|
|
|
|
DECL_VERIFIER(JSWeakMap)
|
2011-08-03 11:55:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakMap);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-07-22 08:32:24 +00:00
|
|
|
// The JSWeakSet describes EcmaScript Harmony weak sets
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSWeakSet: public JSWeakCollection {
|
2013-07-22 08:32:24 +00:00
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSWeakSet)
|
2013-07-22 08:32:24 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSWeakSet)
|
|
|
|
DECL_VERIFIER(JSWeakSet)
|
2013-07-22 08:32:24 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakSet);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-05-22 13:43:38 +00:00
|
|
|
// Whether a JSArrayBuffer is a SharedArrayBuffer or not.
|
|
|
|
enum class SharedFlag { kNotShared, kShared };
|
|
|
|
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSArrayBuffer: public JSObject {
|
2013-03-28 12:50:18 +00:00
|
|
|
public:
|
2013-04-22 11:29:52 +00:00
|
|
|
// [backing_store]: backing memory for this array
|
2013-03-28 12:50:18 +00:00
|
|
|
DECL_ACCESSORS(backing_store, void)
|
|
|
|
|
|
|
|
// [byte_length]: length in bytes
|
|
|
|
DECL_ACCESSORS(byte_length, Object)
|
|
|
|
|
2017-05-17 21:22:05 +00:00
|
|
|
// [allocation_base]: the start of the memory allocation for this array,
|
|
|
|
// normally equal to backing_store
|
|
|
|
DECL_ACCESSORS(allocation_base, void)
|
|
|
|
|
|
|
|
// [allocation_length]: the size of the memory allocation for this array,
|
|
|
|
// normally equal to byte_length
|
|
|
|
inline size_t allocation_length() const;
|
|
|
|
inline void set_allocation_length(size_t value);
|
|
|
|
|
2015-04-28 09:40:35 +00:00
|
|
|
inline uint32_t bit_field() const;
|
|
|
|
inline void set_bit_field(uint32_t bits);
|
2013-05-23 10:01:42 +00:00
|
|
|
|
2017-03-28 13:03:16 +00:00
|
|
|
// [is_external]: true indicates that the embedder is in charge of freeing the
|
|
|
|
// backing_store, while is_external == false means that v8 will free the
|
|
|
|
// memory block once all ArrayBuffers referencing it are collected by the GC.
|
2013-05-23 10:01:42 +00:00
|
|
|
inline bool is_external();
|
|
|
|
inline void set_is_external(bool value);
|
|
|
|
|
2014-10-29 10:36:36 +00:00
|
|
|
inline bool is_neuterable();
|
|
|
|
inline void set_is_neuterable(bool value);
|
|
|
|
|
2015-04-27 09:28:16 +00:00
|
|
|
inline bool was_neutered();
|
|
|
|
inline void set_was_neutered(bool value);
|
|
|
|
|
2015-05-22 13:43:38 +00:00
|
|
|
inline bool is_shared();
|
|
|
|
inline void set_is_shared(bool value);
|
|
|
|
|
2017-05-19 19:54:43 +00:00
|
|
|
inline bool has_guard_region() const;
|
2016-11-17 18:48:08 +00:00
|
|
|
inline void set_has_guard_region(bool value);
|
|
|
|
|
2017-05-04 17:21:56 +00:00
|
|
|
// TODO(gdeepti): This flag is introduced to disable asm.js optimizations in
|
|
|
|
// js-typer-lowering.cc, remove when the asm.js case is fixed.
|
|
|
|
inline bool is_wasm_buffer();
|
|
|
|
inline void set_is_wasm_buffer(bool value);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSArrayBuffer)
|
2013-03-28 12:50:18 +00:00
|
|
|
|
2013-06-07 15:02:20 +00:00
|
|
|
void Neuter();
|
|
|
|
|
2017-05-19 19:54:43 +00:00
|
|
|
inline ArrayBuffer::Allocator::AllocationMode allocation_mode() const;
|
|
|
|
|
2017-05-17 21:22:05 +00:00
|
|
|
void FreeBackingStore();
|
|
|
|
|
2016-10-17 10:01:42 +00:00
|
|
|
V8_EXPORT_PRIVATE static void Setup(
|
|
|
|
Handle<JSArrayBuffer> array_buffer, Isolate* isolate, bool is_external,
|
|
|
|
void* data, size_t allocated_length,
|
|
|
|
SharedFlag shared = SharedFlag::kNotShared);
|
2015-08-26 13:59:35 +00:00
|
|
|
|
2017-05-17 21:22:05 +00:00
|
|
|
V8_EXPORT_PRIVATE static void Setup(
|
|
|
|
Handle<JSArrayBuffer> array_buffer, Isolate* isolate, bool is_external,
|
|
|
|
void* allocation_base, size_t allocation_length, void* data,
|
|
|
|
size_t byte_length, SharedFlag shared = SharedFlag::kNotShared);
|
|
|
|
|
2017-01-19 16:23:07 +00:00
|
|
|
// Returns false if array buffer contents could not be allocated.
|
|
|
|
// In this case, |array_buffer| will not be set up.
|
|
|
|
static bool SetupAllocatingData(
|
|
|
|
Handle<JSArrayBuffer> array_buffer, Isolate* isolate,
|
|
|
|
size_t allocated_length, bool initialize = true,
|
|
|
|
SharedFlag shared = SharedFlag::kNotShared) WARN_UNUSED_RESULT;
|
2015-08-26 13:59:35 +00:00
|
|
|
|
2013-03-28 12:50:18 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSArrayBuffer)
|
|
|
|
DECL_VERIFIER(JSArrayBuffer)
|
2013-03-28 12:50:18 +00:00
|
|
|
|
2015-09-16 17:27:40 +00:00
|
|
|
static const int kByteLengthOffset = JSObject::kHeaderSize;
|
2017-05-17 21:22:05 +00:00
|
|
|
// The rest of the fields are not JSObjects, so they are not iterated over in
|
|
|
|
// objects-body-descriptors-inl.h.
|
2015-09-16 17:27:40 +00:00
|
|
|
static const int kBackingStoreOffset = kByteLengthOffset + kPointerSize;
|
2017-05-17 21:22:05 +00:00
|
|
|
static const int kAllocationBaseOffset = kBackingStoreOffset + kPointerSize;
|
|
|
|
static const int kAllocationLengthOffset =
|
|
|
|
kAllocationBaseOffset + kPointerSize;
|
|
|
|
static const int kBitFieldSlot = kAllocationLengthOffset + kSizetSize;
|
2015-04-28 20:00:44 +00:00
|
|
|
#if V8_TARGET_LITTLE_ENDIAN || !V8_HOST_ARCH_64_BIT
|
|
|
|
static const int kBitFieldOffset = kBitFieldSlot;
|
|
|
|
#else
|
|
|
|
static const int kBitFieldOffset = kBitFieldSlot + kIntSize;
|
|
|
|
#endif
|
2015-04-30 10:57:44 +00:00
|
|
|
static const int kSize = kBitFieldSlot + kPointerSize;
|
2013-06-07 10:52:11 +00:00
|
|
|
|
2017-03-17 13:26:05 +00:00
|
|
|
static const int kSizeWithEmbedderFields =
|
|
|
|
kSize + v8::ArrayBuffer::kEmbedderFieldCount * kPointerSize;
|
2013-03-28 12:50:18 +00:00
|
|
|
|
2015-11-13 12:32:08 +00:00
|
|
|
// Iterates all fields in the object including internal ones except
|
|
|
|
// kBackingStoreOffset and kBitFieldSlot.
|
|
|
|
class BodyDescriptor;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2015-09-16 17:27:40 +00:00
|
|
|
|
2015-04-28 09:40:35 +00:00
|
|
|
class IsExternal : public BitField<bool, 1, 1> {};
|
2015-04-28 11:25:25 +00:00
|
|
|
class IsNeuterable : public BitField<bool, 2, 1> {};
|
|
|
|
class WasNeutered : public BitField<bool, 3, 1> {};
|
2015-05-22 13:43:38 +00:00
|
|
|
class IsShared : public BitField<bool, 4, 1> {};
|
2016-11-17 18:48:08 +00:00
|
|
|
class HasGuardRegion : public BitField<bool, 5, 1> {};
|
2017-05-04 17:21:56 +00:00
|
|
|
class IsWasmBuffer : public BitField<bool, 6, 1> {};
|
2013-05-23 10:01:42 +00:00
|
|
|
|
2015-04-27 09:28:16 +00:00
|
|
|
private:
|
2013-03-28 12:50:18 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBuffer);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSArrayBufferView: public JSObject {
|
2013-04-16 14:16:30 +00:00
|
|
|
public:
|
|
|
|
// [buffer]: ArrayBuffer that this typed array views.
|
|
|
|
DECL_ACCESSORS(buffer, Object)
|
|
|
|
|
2015-05-04 19:45:13 +00:00
|
|
|
// [byte_offset]: offset of typed array in bytes.
|
2013-04-16 14:16:30 +00:00
|
|
|
DECL_ACCESSORS(byte_offset, Object)
|
|
|
|
|
|
|
|
// [byte_length]: length of typed array in bytes.
|
|
|
|
DECL_ACCESSORS(byte_length, Object)
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSArrayBufferView)
|
2013-06-21 13:02:38 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(JSArrayBufferView)
|
2013-06-21 13:02:38 +00:00
|
|
|
|
2015-04-27 09:28:16 +00:00
|
|
|
inline bool WasNeutered() const;
|
|
|
|
|
2013-06-21 13:02:38 +00:00
|
|
|
static const int kBufferOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kByteOffsetOffset = kBufferOffset + kPointerSize;
|
|
|
|
static const int kByteLengthOffset = kByteOffsetOffset + kPointerSize;
|
2015-04-27 09:28:16 +00:00
|
|
|
static const int kViewSize = kByteLengthOffset + kPointerSize;
|
2015-04-23 13:02:53 +00:00
|
|
|
|
2015-04-24 06:46:38 +00:00
|
|
|
private:
|
2015-04-27 09:28:16 +00:00
|
|
|
#ifdef VERIFY_HEAP
|
|
|
|
DECL_ACCESSORS(raw_byte_offset, Object)
|
|
|
|
DECL_ACCESSORS(raw_byte_length, Object)
|
|
|
|
#endif
|
|
|
|
|
2013-06-21 13:02:38 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBufferView);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSTypedArray: public JSArrayBufferView {
|
2013-06-21 13:02:38 +00:00
|
|
|
public:
|
|
|
|
// [length]: length of typed array in elements.
|
|
|
|
DECL_ACCESSORS(length, Object)
|
2015-06-02 10:42:16 +00:00
|
|
|
inline uint32_t length_value() const;
|
2013-06-21 13:02:38 +00:00
|
|
|
|
2016-11-29 00:07:33 +00:00
|
|
|
// ES6 9.4.5.3
|
|
|
|
MUST_USE_RESULT static Maybe<bool> DefineOwnProperty(
|
|
|
|
Isolate* isolate, Handle<JSTypedArray> o, Handle<Object> key,
|
|
|
|
PropertyDescriptor* desc, ShouldThrow should_throw);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSTypedArray)
|
2013-04-16 14:16:30 +00:00
|
|
|
|
2013-04-29 11:09:03 +00:00
|
|
|
ExternalArrayType type();
|
2016-10-17 10:01:42 +00:00
|
|
|
V8_EXPORT_PRIVATE size_t element_size();
|
2013-04-29 11:09:03 +00:00
|
|
|
|
2014-03-26 12:50:13 +00:00
|
|
|
Handle<JSArrayBuffer> GetBuffer();
|
|
|
|
|
2017-02-25 02:54:54 +00:00
|
|
|
static inline MaybeHandle<JSTypedArray> Validate(Isolate* isolate,
|
|
|
|
Handle<Object> receiver,
|
|
|
|
const char* method_name);
|
2017-05-17 15:27:37 +00:00
|
|
|
// ES7 section 22.2.4.6 Create ( constructor, argumentList )
|
|
|
|
static MaybeHandle<JSTypedArray> Create(Isolate* isolate,
|
2017-05-26 14:48:34 +00:00
|
|
|
Handle<Object> default_ctor, int argc,
|
|
|
|
Handle<Object>* argv,
|
2017-05-17 15:27:37 +00:00
|
|
|
const char* method_name);
|
|
|
|
// ES7 section 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
|
|
|
|
static MaybeHandle<JSTypedArray> SpeciesCreate(Isolate* isolate,
|
|
|
|
Handle<JSTypedArray> exemplar,
|
|
|
|
int argc, Handle<Object>* argv,
|
|
|
|
const char* method_name);
|
2017-02-25 02:54:54 +00:00
|
|
|
|
2013-04-16 14:16:30 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSTypedArray)
|
|
|
|
DECL_VERIFIER(JSTypedArray)
|
2013-04-16 14:16:30 +00:00
|
|
|
|
2013-06-21 13:02:38 +00:00
|
|
|
static const int kLengthOffset = kViewSize + kPointerSize;
|
|
|
|
static const int kSize = kLengthOffset + kPointerSize;
|
2013-04-16 14:16:30 +00:00
|
|
|
|
2017-03-17 13:26:05 +00:00
|
|
|
static const int kSizeWithEmbedderFields =
|
|
|
|
kSize + v8::ArrayBufferView::kEmbedderFieldCount * kPointerSize;
|
2013-07-05 10:12:36 +00:00
|
|
|
|
2013-04-16 14:16:30 +00:00
|
|
|
private:
|
2014-03-26 12:50:13 +00:00
|
|
|
static Handle<JSArrayBuffer> MaterializeArrayBuffer(
|
|
|
|
Handle<JSTypedArray> typed_array);
|
2015-04-27 09:28:16 +00:00
|
|
|
#ifdef VERIFY_HEAP
|
|
|
|
DECL_ACCESSORS(raw_length, Object)
|
|
|
|
#endif
|
2014-03-26 12:50:13 +00:00
|
|
|
|
2013-04-16 14:16:30 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSTypedArray);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSDataView: public JSArrayBufferView {
|
2013-06-21 13:02:38 +00:00
|
|
|
public:
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSDataView)
|
2013-06-21 13:02:38 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSDataView)
|
|
|
|
DECL_VERIFIER(JSDataView)
|
2013-06-21 13:02:38 +00:00
|
|
|
|
|
|
|
static const int kSize = kViewSize;
|
|
|
|
|
2017-03-17 13:26:05 +00:00
|
|
|
static const int kSizeWithEmbedderFields =
|
|
|
|
kSize + v8::ArrayBufferView::kEmbedderFieldCount * kPointerSize;
|
2013-07-05 10:12:36 +00:00
|
|
|
|
2013-06-21 13:02:38 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSDataView);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
inline void set_foreign_address(Address value);
|
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;
|
2017-06-14 09:46:34 +00:00
|
|
|
// No weak fields.
|
|
|
|
typedef BodyDescriptor BodyDescriptorWeak;
|
2015-11-13 12:32:08 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
2011-05-19 11:47:34 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Foreign);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// The JSArray describes JavaScript Arrays
|
|
|
|
// Such an array can be in one of two modes:
|
|
|
|
// - fast, backing storage is a FixedArray and length <= elements.length();
|
|
|
|
// Please note: push and pop can be used to grow and shrink the array.
|
|
|
|
// - slow, backing storage is a HashTable with numbers as keys.
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSArray: public JSObject {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
// [length]: The length property.
|
|
|
|
DECL_ACCESSORS(length, Object)
|
|
|
|
|
2010-01-29 11:46:55 +00:00
|
|
|
// Overload the length setter to skip write barrier when the length
|
|
|
|
// is set to a smi. This matches the set function on FixedArray.
|
|
|
|
inline void set_length(Smi* length);
|
|
|
|
|
2014-11-14 19:42:03 +00:00
|
|
|
static bool HasReadOnlyLength(Handle<JSArray> array);
|
2014-05-22 08:09:57 +00:00
|
|
|
static bool WouldChangeReadOnlyLength(Handle<JSArray> array, uint32_t index);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Initialize the array with the given capacity. The function may
|
|
|
|
// fail due to out-of-memory situations, but only if the requested
|
|
|
|
// capacity is non-zero.
|
2014-03-18 11:38:27 +00:00
|
|
|
static void Initialize(Handle<JSArray> array, int capacity, int length = 0);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-04-15 21:02:14 +00:00
|
|
|
// If the JSArray has fast elements, and new_length would result in
|
|
|
|
// normalization, returns true.
|
2015-06-25 15:04:46 +00:00
|
|
|
bool SetLengthWouldNormalize(uint32_t new_length);
|
2015-06-19 14:56:57 +00:00
|
|
|
static inline bool SetLengthWouldNormalize(Heap* heap, uint32_t new_length);
|
2015-04-15 21:02:14 +00:00
|
|
|
|
2011-12-14 12:46:32 +00:00
|
|
|
// Initializes the array to a certain length.
|
2015-06-19 14:56:57 +00:00
|
|
|
inline bool AllowsSetLength();
|
|
|
|
|
|
|
|
static void SetLength(Handle<JSArray> array, uint32_t length);
|
2011-12-14 12:46:32 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Set the content of the array to the content of storage.
|
2014-03-21 08:30:42 +00:00
|
|
|
static inline void SetContent(Handle<JSArray> array,
|
|
|
|
Handle<FixedArrayBase> storage);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-12-09 18:06:49 +00:00
|
|
|
// ES6 9.4.2.1
|
|
|
|
MUST_USE_RESULT static Maybe<bool> DefineOwnProperty(
|
|
|
|
Isolate* isolate, Handle<JSArray> o, Handle<Object> name,
|
|
|
|
PropertyDescriptor* desc, ShouldThrow should_throw);
|
2015-10-13 14:38:16 +00:00
|
|
|
|
2015-10-15 16:03:20 +00:00
|
|
|
static bool AnythingToArrayLength(Isolate* isolate,
|
|
|
|
Handle<Object> length_object,
|
|
|
|
uint32_t* output);
|
2015-12-09 18:06:49 +00:00
|
|
|
MUST_USE_RESULT static Maybe<bool> ArraySetLength(Isolate* isolate,
|
|
|
|
Handle<JSArray> a,
|
|
|
|
PropertyDescriptor* desc,
|
|
|
|
ShouldThrow should_throw);
|
2015-10-13 14:38:16 +00:00
|
|
|
|
Make array __proto__ manipulations not disturb the species protector
Previously, the species protector was invalidated whenever the __proto__ of
an Array instance was manipulated. Then, if the map's new_target_is_base field
remained set, it was correct to conclude that GetPrototypeOf(array) was
%ArrayPrototype%. However, this choice caused the popular D3 framework to
invalidate the species protector, causing many functions to become slower.
This patch eliminates that aspect of the species protector. Instead, the check
is to look at the instance->map()->prototype(). It is valid to look directly
at the map's prototype slot, ignoring hidden prototypes and proxies, because
- This is only called on Array instances, so the receiver cannot be a Proxy.
- For hidden prototypes, any inaccuracy would only result in conservatively
taking the slow path.
Theoretically, this patch could make methods applied to arrays from other
contexts slower. However, the slowdown would only affect a particular array
instance and not have a global spill-over effect. Further, the slowdown could
be addressed by tracking, either in the instance's map or in the actual
prototype object, whether it is a %ArrayPrototype% from any context, in a way
which is cheap to query, and use that rather than comparing to the currently
executing native context.
In interactive testing, this patch led the OnShape CAD system to experience
faster load times (110+s -> 40s).
BUG=chromium:606207
LOG=Y
Review-Url: https://codereview.chromium.org/1936393002
Cr-Commit-Position: refs/heads/master@{#36033}
2016-05-04 16:47:34 +00:00
|
|
|
// Checks whether the Array has the current realm's Array.prototype as its
|
|
|
|
// prototype. This function is best-effort and only gives a conservative
|
|
|
|
// approximation, erring on the side of false, in particular with respect
|
|
|
|
// to Proxies and objects with a hidden prototype.
|
|
|
|
inline bool HasArrayPrototype(Isolate* isolate);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(JSArray)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(JSArray)
|
|
|
|
DECL_VERIFIER(JSArray)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-09-23 09:05:12 +00:00
|
|
|
// Number of element slots to pre-allocate for an empty array.
|
|
|
|
static const int kPreallocatedArrayElements = 4;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Layout description.
|
|
|
|
static const int kLengthOffset = JSObject::kHeaderSize;
|
|
|
|
static const int kSize = kLengthOffset + kPointerSize;
|
|
|
|
|
2017-05-10 05:48:21 +00:00
|
|
|
// Max. number of elements being copied in Array builtins.
|
2017-05-17 14:39:34 +00:00
|
|
|
static const int kMaxCopyElements = 100;
|
2017-05-10 05:48:21 +00:00
|
|
|
|
2015-10-15 10:55:12 +00:00
|
|
|
static const int kInitialMaxFastElementArray =
|
2016-09-06 12:58:59 +00:00
|
|
|
(kMaxRegularHeapObjectSize - FixedArray::kHeaderSize - kSize -
|
2016-09-01 20:09:48 +00:00
|
|
|
AllocationMemento::kSize) /
|
2015-10-15 10:55:12 +00:00
|
|
|
kPointerSize;
|
2015-10-07 09:13:54 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSArray);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-04-26 10:10:36 +00:00
|
|
|
Handle<Object> CacheInitialJSArrayMaps(Handle<Context> native_context,
|
|
|
|
Handle<Map> initial_map);
|
2013-04-25 16:00:32 +00:00
|
|
|
|
|
|
|
|
2010-04-13 09:31:03 +00:00
|
|
|
// JSRegExpResult is just a JSArray with a specific initial map.
|
|
|
|
// This initial map adds in-object properties for "index" and "input"
|
|
|
|
// properties, as assigned by RegExp.prototype.exec, which allows
|
|
|
|
// faster creation of RegExp exec results.
|
|
|
|
// This class just holds constants used when creating the result.
|
|
|
|
// After creation the result must be treated as a JSArray in all regards.
|
2013-08-20 10:52:23 +00:00
|
|
|
class JSRegExpResult: public JSArray {
|
2010-04-13 09:31:03 +00:00
|
|
|
public:
|
|
|
|
// Offsets of object fields.
|
|
|
|
static const int kIndexOffset = JSArray::kSize;
|
|
|
|
static const int kInputOffset = kIndexOffset + kPointerSize;
|
|
|
|
static const int kSize = kInputOffset + kPointerSize;
|
|
|
|
// Indices of in-object properties.
|
|
|
|
static const int kIndexIndex = 0;
|
|
|
|
static const int kInputIndex = 1;
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(JSRegExpResult);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-01-18 15:08:36 +00:00
|
|
|
// An accessor must have a getter, but can have no setter.
|
|
|
|
//
|
|
|
|
// When setting a property, V8 searches accessors in prototypes.
|
|
|
|
// If an accessor was found and it does not have a setter,
|
|
|
|
// the request is ignored.
|
|
|
|
//
|
|
|
|
// If the accessor in the prototype has the READ_ONLY property attribute, then
|
|
|
|
// a new value is added to the derived object when the property is set.
|
|
|
|
// This shadows the accessor in the prototype.
|
2013-08-20 10:52:23 +00:00
|
|
|
class AccessorInfo: public Struct {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(name, Object)
|
2015-09-28 13:10:13 +00:00
|
|
|
DECL_INT_ACCESSORS(flag)
|
2012-06-08 07:45:11 +00:00
|
|
|
DECL_ACCESSORS(expected_receiver_type, Object)
|
2016-04-20 08:01:08 +00:00
|
|
|
// This directly points at a foreign C function to be used from the runtime.
|
2016-01-18 15:08:36 +00:00
|
|
|
DECL_ACCESSORS(getter, Object)
|
|
|
|
DECL_ACCESSORS(setter, Object)
|
2016-04-20 08:01:08 +00:00
|
|
|
// This either points at the same as above, or a trampoline in case we are
|
|
|
|
// running with the simulator. Use these entries from generated code.
|
|
|
|
DECL_ACCESSORS(js_getter, Object)
|
2016-01-18 15:08:36 +00:00
|
|
|
DECL_ACCESSORS(data, Object)
|
|
|
|
|
2016-04-20 08:01:08 +00:00
|
|
|
static Address redirect(Isolate* isolate, Address address,
|
|
|
|
AccessorComponent component);
|
|
|
|
Address redirected_getter() const;
|
|
|
|
|
2016-01-18 15:08:36 +00:00
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(AccessorInfo)
|
2016-01-18 15:08:36 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
inline bool all_can_read();
|
|
|
|
inline void set_all_can_read(bool value);
|
|
|
|
|
|
|
|
inline bool all_can_write();
|
|
|
|
inline void set_all_can_write(bool value);
|
|
|
|
|
2015-05-18 12:36:49 +00:00
|
|
|
inline bool is_special_data_property();
|
|
|
|
inline void set_is_special_data_property(bool value);
|
|
|
|
|
2016-10-28 14:39:33 +00:00
|
|
|
inline bool replace_on_access();
|
|
|
|
inline void set_replace_on_access(bool value);
|
|
|
|
|
2016-05-06 14:10:12 +00:00
|
|
|
inline bool is_sloppy();
|
|
|
|
inline void set_is_sloppy(bool value);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
inline PropertyAttributes property_attributes();
|
|
|
|
inline void set_property_attributes(PropertyAttributes attributes);
|
|
|
|
|
2012-06-08 07:45:11 +00:00
|
|
|
// Checks whether the given receiver is compatible with this accessor.
|
2015-02-17 15:33:26 +00:00
|
|
|
static bool IsCompatibleReceiverMap(Isolate* isolate,
|
|
|
|
Handle<AccessorInfo> info,
|
|
|
|
Handle<Map> map);
|
2012-06-08 07:45:11 +00:00
|
|
|
inline bool IsCompatibleReceiver(Object* receiver);
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(AccessorInfo)
|
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_VERIFIER(AccessorInfo)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-09-04 07:45:36 +00:00
|
|
|
// Append all descriptors to the array that are not already there.
|
|
|
|
// Return number added.
|
|
|
|
static int AppendUnique(Handle<Object> descriptors,
|
|
|
|
Handle<FixedArray> array,
|
|
|
|
int valid_descriptors);
|
2013-02-12 14:33:08 +00:00
|
|
|
|
|
|
|
static const int kNameOffset = HeapObject::kHeaderSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kFlagOffset = kNameOffset + kPointerSize;
|
2012-06-08 07:45:11 +00:00
|
|
|
static const int kExpectedReceiverTypeOffset = kFlagOffset + kPointerSize;
|
2016-04-20 08:01:08 +00:00
|
|
|
static const int kSetterOffset = kExpectedReceiverTypeOffset + kPointerSize;
|
|
|
|
static const int kGetterOffset = kSetterOffset + kPointerSize;
|
|
|
|
static const int kJsGetterOffset = kGetterOffset + kPointerSize;
|
|
|
|
static const int kDataOffset = kJsGetterOffset + kPointerSize;
|
2016-01-18 15:08:36 +00:00
|
|
|
static const int kSize = kDataOffset + kPointerSize;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
2015-08-13 11:49:01 +00:00
|
|
|
inline bool HasExpectedReceiverType();
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Bit positions in flag.
|
2008-10-30 12:51:06 +00:00
|
|
|
static const int kAllCanReadBit = 0;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kAllCanWriteBit = 1;
|
2015-05-18 12:36:49 +00:00
|
|
|
static const int kSpecialDataProperty = 2;
|
2016-05-06 14:10:12 +00:00
|
|
|
static const int kIsSloppy = 3;
|
2016-10-28 14:39:33 +00:00
|
|
|
static const int kReplaceOnAccess = 4;
|
|
|
|
class AttributesField : public BitField<PropertyAttributes, 5, 3> {};
|
2008-08-13 09:32:07 +00:00
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo);
|
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
|
|
|
|
// * a pointer to a JavaScript function or proxy: a real accessor
|
|
|
|
// * undefined: considered an accessor by the spec, too, strangely enough
|
|
|
|
// * the hole: an accessor which has not been set
|
|
|
|
// * a pointer to a map: a transition used to ensure map sharing
|
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
|
|
|
|
2013-07-02 16:24:23 +00:00
|
|
|
static Handle<AccessorPair> Copy(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
|
|
|
|
2012-03-23 09:51:56 +00:00
|
|
|
// Note: Returns undefined instead in case of a hole.
|
2016-02-09 16:28:02 +00:00
|
|
|
static Handle<Object> GetComponent(Handle<AccessorPair> accessor_pair,
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class AccessCheckInfo: public Struct {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2015-10-23 08:13:24 +00:00
|
|
|
DECL_ACCESSORS(callback, Object)
|
2016-06-27 11:48:04 +00:00
|
|
|
DECL_ACCESSORS(named_interceptor, Object)
|
|
|
|
DECL_ACCESSORS(indexed_interceptor, Object)
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(data, Object)
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(AccessCheckInfo)
|
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(AccessCheckInfo)
|
|
|
|
DECL_VERIFIER(AccessCheckInfo)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-06-27 11:48:04 +00:00
|
|
|
static AccessCheckInfo* Get(Isolate* isolate, Handle<JSObject> receiver);
|
|
|
|
|
2016-06-08 14:42:07 +00:00
|
|
|
static const int kCallbackOffset = HeapObject::kHeaderSize;
|
2016-06-27 11:48:04 +00:00
|
|
|
static const int kNamedInterceptorOffset = kCallbackOffset + kPointerSize;
|
|
|
|
static const int kIndexedInterceptorOffset =
|
|
|
|
kNamedInterceptorOffset + kPointerSize;
|
|
|
|
static const int kDataOffset = kIndexedInterceptorOffset + kPointerSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kSize = kDataOffset + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(AccessCheckInfo);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class InterceptorInfo: public Struct {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(getter, Object)
|
|
|
|
DECL_ACCESSORS(setter, Object)
|
|
|
|
DECL_ACCESSORS(query, Object)
|
2016-09-08 12:51:37 +00:00
|
|
|
DECL_ACCESSORS(descriptor, Object)
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(deleter, Object)
|
|
|
|
DECL_ACCESSORS(enumerator, Object)
|
2016-09-02 09:08:31 +00:00
|
|
|
DECL_ACCESSORS(definer, Object)
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(data, Object)
|
2014-11-27 10:21:32 +00:00
|
|
|
DECL_BOOLEAN_ACCESSORS(can_intercept_symbols)
|
2015-02-09 11:33:36 +00:00
|
|
|
DECL_BOOLEAN_ACCESSORS(all_can_read)
|
2015-03-18 12:50:41 +00:00
|
|
|
DECL_BOOLEAN_ACCESSORS(non_masking)
|
2014-11-27 10:21:32 +00:00
|
|
|
|
|
|
|
inline int flags() const;
|
|
|
|
inline void set_flags(int flags);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(InterceptorInfo)
|
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(InterceptorInfo)
|
|
|
|
DECL_VERIFIER(InterceptorInfo)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-09-23 11:45:43 +00:00
|
|
|
static const int kGetterOffset = HeapObject::kHeaderSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kSetterOffset = kGetterOffset + kPointerSize;
|
|
|
|
static const int kQueryOffset = kSetterOffset + kPointerSize;
|
2016-09-08 12:51:37 +00:00
|
|
|
static const int kDescriptorOffset = kQueryOffset + kPointerSize;
|
|
|
|
static const int kDeleterOffset = kDescriptorOffset + kPointerSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kEnumeratorOffset = kDeleterOffset + kPointerSize;
|
2016-09-02 09:08:31 +00:00
|
|
|
static const int kDefinerOffset = kEnumeratorOffset + kPointerSize;
|
|
|
|
static const int kDataOffset = kDefinerOffset + kPointerSize;
|
2014-11-27 10:21:32 +00:00
|
|
|
static const int kFlagsOffset = kDataOffset + kPointerSize;
|
|
|
|
static const int kSize = kFlagsOffset + kPointerSize;
|
|
|
|
|
|
|
|
static const int kCanInterceptSymbolsBit = 0;
|
2015-02-09 11:33:36 +00:00
|
|
|
static const int kAllCanReadBit = 1;
|
2015-03-18 12:50:41 +00:00
|
|
|
static const int kNonMasking = 2;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(InterceptorInfo);
|
|
|
|
};
|
|
|
|
|
2017-04-18 12:46:39 +00:00
|
|
|
class CallHandlerInfo : public Tuple2 {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(callback, Object)
|
|
|
|
DECL_ACCESSORS(data, Object)
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(CallHandlerInfo)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-04-18 12:46:39 +00:00
|
|
|
static const int kCallbackOffset = kValue1Offset;
|
|
|
|
static const int kDataOffset = kValue2Offset;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(CallHandlerInfo);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TemplateInfo: public Struct {
|
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(tag, Object)
|
2016-02-06 18:10:08 +00:00
|
|
|
DECL_ACCESSORS(serial_number, Object)
|
|
|
|
DECL_INT_ACCESSORS(number_of_properties)
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(property_list, Object)
|
2013-09-04 07:45:36 +00:00
|
|
|
DECL_ACCESSORS(property_accessors, Object)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_VERIFIER(TemplateInfo)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(TemplateInfo)
|
2016-08-16 19:26:18 +00:00
|
|
|
|
2013-09-04 07:45:36 +00:00
|
|
|
static const int kTagOffset = HeapObject::kHeaderSize;
|
2016-02-06 18:10:08 +00:00
|
|
|
static const int kSerialNumberOffset = kTagOffset + kPointerSize;
|
|
|
|
static const int kNumberOfProperties = kSerialNumberOffset + kPointerSize;
|
2015-07-03 15:06:39 +00:00
|
|
|
static const int kPropertyListOffset = kNumberOfProperties + kPointerSize;
|
2013-09-04 07:45:36 +00:00
|
|
|
static const int kPropertyAccessorsOffset =
|
|
|
|
kPropertyListOffset + kPointerSize;
|
2016-10-11 20:18:20 +00:00
|
|
|
static const int kHeaderSize = kPropertyAccessorsOffset + kPointerSize;
|
2012-01-20 16:17:08 +00:00
|
|
|
|
2016-07-28 17:16:33 +00:00
|
|
|
static const int kFastTemplateInstantiationsCacheSize = 1 * KB;
|
|
|
|
|
2017-05-02 11:08:33 +00:00
|
|
|
// While we could grow the slow cache until we run out of memory, we put
|
|
|
|
// a limit on it anyway to not crash for embedders that re-create templates
|
|
|
|
// instead of caching them.
|
|
|
|
static const int kSlowTemplateInstantiationsCacheSize = 1 * MB;
|
|
|
|
|
2012-01-20 16:17:08 +00:00
|
|
|
private:
|
2008-07-03 15:10:15 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(TemplateInfo);
|
|
|
|
};
|
|
|
|
|
2017-07-05 11:36:26 +00:00
|
|
|
// See the api-exposed FunctionTemplate for more information.
|
2013-08-20 10:52:23 +00:00
|
|
|
class FunctionTemplateInfo: public TemplateInfo {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2017-07-05 11:36:26 +00:00
|
|
|
// Handler invoked when calling an instance of this FunctionTemplateInfo.
|
|
|
|
// Either CallInfoHandler or Undefined.
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(call_code, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// ObjectTemplateInfo or Undefined, used for the prototype property of the
|
|
|
|
// resulting JSFunction instance of this FunctionTemplate.
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(prototype_template, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// In the case the prototype_template is Undefined we use the
|
|
|
|
// protoype_provider_template to retrieve the instance prototype. Either
|
|
|
|
// contains an ObjectTemplateInfo or Undefined.
|
2016-11-29 10:13:47 +00:00
|
|
|
DECL_ACCESSORS(prototype_provider_template, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// Used to create protoype chains. The parent_template's prototype is set as
|
|
|
|
// __proto__ of this FunctionTemplate's instance prototype. Is either a
|
|
|
|
// FunctionTemplateInfo or Undefined.
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(parent_template, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// Returns an InterceptorInfo or Undefined for named properties.
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(named_property_handler, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
// Returns an InterceptorInfo or Undefined for indexed properties/elements.
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(indexed_property_handler, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// An ObjectTemplateInfo that is used when instantiating the JSFunction
|
|
|
|
// associated with this FunctionTemplateInfo. Contains either an
|
|
|
|
// ObjectTemplateInfo or Undefined. A default instance_template is assigned
|
|
|
|
// upon first instantiation if it's Undefined.
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(instance_template, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(class_name, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// If the signature is a FunctionTemplateInfo it is used to check whether the
|
|
|
|
// receiver calling the associated JSFunction is a compatible receiver, i.e.
|
|
|
|
// it is an instance of the signare FunctionTemplateInfo or any of the
|
|
|
|
// receiver's prototypes are.
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(signature, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// Either a CallHandlerInfo or Undefined. If an instance_call_handler is
|
|
|
|
// provided the instances created from the associated JSFunction are marked as
|
|
|
|
// callable.
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(instance_call_handler, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_ACCESSORS(access_check_info, Object)
|
2016-06-24 13:51:24 +00:00
|
|
|
DECL_ACCESSORS(shared_function_info, Object)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// Internal field to store a flag bitfield.
|
2015-09-28 13:10:13 +00:00
|
|
|
DECL_INT_ACCESSORS(flag)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-07-05 11:36:26 +00:00
|
|
|
// "length" property of the final JSFunction.
|
|
|
|
DECL_INT_ACCESSORS(length)
|
|
|
|
|
|
|
|
// Either the_hole or a private symbol. Used to cache the result on
|
|
|
|
// the receiver under the the cached_property_name when this
|
|
|
|
// FunctionTemplateInfo is used as a getter.
|
|
|
|
DECL_ACCESSORS(cached_property_name, Object)
|
2012-12-19 10:28:36 +00:00
|
|
|
|
2017-07-05 11:36:26 +00:00
|
|
|
// Begin flag bits ---------------------
|
2008-07-03 15:10:15 +00:00
|
|
|
DECL_BOOLEAN_ACCESSORS(hidden_prototype)
|
|
|
|
DECL_BOOLEAN_ACCESSORS(undetectable)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// If set, object instances created by this function
|
2008-07-03 15:10:15 +00:00
|
|
|
// requires access check.
|
|
|
|
DECL_BOOLEAN_ACCESSORS(needs_access_check)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
2011-07-25 15:01:45 +00:00
|
|
|
DECL_BOOLEAN_ACCESSORS(read_only_prototype)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// If set, do not create a prototype property for the associated
|
|
|
|
// JSFunction. This bit implies that neither the prototype_template nor the
|
|
|
|
// prototype_provoider_template are instantiated.
|
2013-08-26 17:40:03 +00:00
|
|
|
DECL_BOOLEAN_ACCESSORS(remove_prototype)
|
2017-07-05 11:36:26 +00:00
|
|
|
|
|
|
|
// If set, do not attach a serial number to this FunctionTemplate and thus do
|
|
|
|
// not keep an instance boilerplate around.
|
2013-09-09 07:52:52 +00:00
|
|
|
DECL_BOOLEAN_ACCESSORS(do_not_cache)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-07-05 11:36:26 +00:00
|
|
|
// If not set an access may be performed on calling the associated JSFunction.
|
|
|
|
DECL_BOOLEAN_ACCESSORS(accept_any_receiver)
|
|
|
|
// End flag bits ---------------------
|
2016-11-04 13:02:40 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(FunctionTemplateInfo)
|
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(FunctionTemplateInfo)
|
|
|
|
DECL_VERIFIER(FunctionTemplateInfo)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-01-10 16:59:57 +00:00
|
|
|
static const int kInvalidSerialNumber = 0;
|
|
|
|
|
2016-02-06 18:10:08 +00:00
|
|
|
static const int kCallCodeOffset = TemplateInfo::kHeaderSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kPrototypeTemplateOffset =
|
2013-09-04 07:45:36 +00:00
|
|
|
kCallCodeOffset + kPointerSize;
|
2016-11-29 10:13:47 +00:00
|
|
|
static const int kPrototypeProviderTemplateOffset =
|
2008-07-03 15:10:15 +00:00
|
|
|
kPrototypeTemplateOffset + kPointerSize;
|
2016-11-29 10:13:47 +00:00
|
|
|
static const int kParentTemplateOffset =
|
|
|
|
kPrototypeProviderTemplateOffset + kPointerSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kNamedPropertyHandlerOffset =
|
|
|
|
kParentTemplateOffset + kPointerSize;
|
|
|
|
static const int kIndexedPropertyHandlerOffset =
|
|
|
|
kNamedPropertyHandlerOffset + kPointerSize;
|
|
|
|
static const int kInstanceTemplateOffset =
|
|
|
|
kIndexedPropertyHandlerOffset + kPointerSize;
|
|
|
|
static const int kClassNameOffset = kInstanceTemplateOffset + kPointerSize;
|
|
|
|
static const int kSignatureOffset = kClassNameOffset + kPointerSize;
|
2008-09-01 18:22:49 +00:00
|
|
|
static const int kInstanceCallHandlerOffset = kSignatureOffset + kPointerSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kAccessCheckInfoOffset =
|
|
|
|
kInstanceCallHandlerOffset + kPointerSize;
|
2016-06-24 13:51:24 +00:00
|
|
|
static const int kSharedFunctionInfoOffset =
|
|
|
|
kAccessCheckInfoOffset + kPointerSize;
|
|
|
|
static const int kFlagOffset = kSharedFunctionInfoOffset + kPointerSize;
|
2012-12-19 10:28:36 +00:00
|
|
|
static const int kLengthOffset = kFlagOffset + kPointerSize;
|
2016-11-04 13:02:40 +00:00
|
|
|
static const int kCachedPropertyNameOffset = kLengthOffset + kPointerSize;
|
|
|
|
static const int kSize = kCachedPropertyNameOffset + kPointerSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-06-24 13:51:24 +00:00
|
|
|
static Handle<SharedFunctionInfo> GetOrCreateSharedFunctionInfo(
|
|
|
|
Isolate* isolate, Handle<FunctionTemplateInfo> info);
|
2016-07-28 17:16:33 +00:00
|
|
|
// Returns parent function template or null.
|
|
|
|
inline FunctionTemplateInfo* GetParent(Isolate* isolate);
|
2013-11-19 13:38:15 +00:00
|
|
|
// Returns true if |object| is an instance of this function template.
|
2016-06-22 10:23:18 +00:00
|
|
|
inline bool IsTemplateFor(JSObject* object);
|
2013-11-19 13:38:15 +00:00
|
|
|
bool IsTemplateFor(Map* map);
|
2016-06-24 13:51:24 +00:00
|
|
|
inline bool instantiated();
|
2013-11-19 13:38:15 +00:00
|
|
|
|
2016-11-04 13:02:40 +00:00
|
|
|
// Helper function for cached accessors.
|
|
|
|
static MaybeHandle<Name> TryGetCachedPropertyName(Isolate* isolate,
|
|
|
|
Handle<Object> getter);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
|
|
|
// Bit position in the flag, from least significant bit position.
|
|
|
|
static const int kHiddenPrototypeBit = 0;
|
|
|
|
static const int kUndetectableBit = 1;
|
|
|
|
static const int kNeedsAccessCheckBit = 2;
|
2011-07-25 15:01:45 +00:00
|
|
|
static const int kReadOnlyPrototypeBit = 3;
|
2013-08-26 17:40:03 +00:00
|
|
|
static const int kRemovePrototypeBit = 4;
|
2013-09-09 07:52:52 +00:00
|
|
|
static const int kDoNotCacheBit = 5;
|
2016-06-24 13:51:24 +00:00
|
|
|
static const int kAcceptAnyReceiver = 6;
|
2008-08-13 09:32:07 +00:00
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateInfo);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-20 10:52:23 +00:00
|
|
|
class ObjectTemplateInfo: public TemplateInfo {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(constructor, Object)
|
2016-07-01 19:16:53 +00:00
|
|
|
DECL_ACCESSORS(data, Object)
|
2017-03-17 13:26:05 +00:00
|
|
|
DECL_INT_ACCESSORS(embedder_field_count)
|
2016-07-01 19:16:53 +00:00
|
|
|
DECL_BOOLEAN_ACCESSORS(immutable_proto)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(ObjectTemplateInfo)
|
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(ObjectTemplateInfo)
|
|
|
|
DECL_VERIFIER(ObjectTemplateInfo)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
static const int kConstructorOffset = TemplateInfo::kHeaderSize;
|
2017-03-17 13:26:05 +00:00
|
|
|
// LSB is for immutable_proto, higher bits for embedder_field_count
|
2016-07-01 19:16:53 +00:00
|
|
|
static const int kDataOffset = kConstructorOffset + kPointerSize;
|
|
|
|
static const int kSize = kDataOffset + kPointerSize;
|
|
|
|
|
2016-07-28 17:16:33 +00:00
|
|
|
// Starting from given object template's constructor walk up the inheritance
|
|
|
|
// chain till a function template that has an instance template is found.
|
|
|
|
inline ObjectTemplateInfo* GetParent(Isolate* isolate);
|
|
|
|
|
2016-07-01 19:16:53 +00:00
|
|
|
private:
|
|
|
|
class IsImmutablePrototype : public BitField<bool, 0, 1> {};
|
2017-03-17 13:26:05 +00:00
|
|
|
class EmbedderFieldCount
|
2016-07-01 19:16:53 +00:00
|
|
|
: public BitField<int, IsImmutablePrototype::kNext, 29> {};
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2017-04-03 14:58:49 +00:00
|
|
|
class StackFrameInfo : public Struct {
|
|
|
|
public:
|
|
|
|
DECL_INT_ACCESSORS(line_number)
|
|
|
|
DECL_INT_ACCESSORS(column_number)
|
|
|
|
DECL_INT_ACCESSORS(script_id)
|
|
|
|
DECL_ACCESSORS(script_name, Object)
|
|
|
|
DECL_ACCESSORS(script_name_or_source_url, Object)
|
|
|
|
DECL_ACCESSORS(function_name, Object)
|
|
|
|
DECL_BOOLEAN_ACCESSORS(is_eval)
|
|
|
|
DECL_BOOLEAN_ACCESSORS(is_constructor)
|
2017-04-08 22:26:22 +00:00
|
|
|
DECL_BOOLEAN_ACCESSORS(is_wasm)
|
2017-04-03 14:58:49 +00:00
|
|
|
DECL_INT_ACCESSORS(flag)
|
2017-04-20 17:33:03 +00:00
|
|
|
DECL_INT_ACCESSORS(id)
|
2017-04-03 14:58:49 +00:00
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(StackFrameInfo)
|
2017-04-03 14:58:49 +00:00
|
|
|
|
|
|
|
// Dispatched behavior.
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_PRINTER(StackFrameInfo)
|
|
|
|
DECL_VERIFIER(StackFrameInfo)
|
2017-04-03 14:58:49 +00:00
|
|
|
|
|
|
|
static const int kLineNumberIndex = Struct::kHeaderSize;
|
|
|
|
static const int kColumnNumberIndex = kLineNumberIndex + kPointerSize;
|
|
|
|
static const int kScriptIdIndex = kColumnNumberIndex + kPointerSize;
|
|
|
|
static const int kScriptNameIndex = kScriptIdIndex + kPointerSize;
|
|
|
|
static const int kScriptNameOrSourceUrlIndex =
|
|
|
|
kScriptNameIndex + kPointerSize;
|
|
|
|
static const int kFunctionNameIndex =
|
|
|
|
kScriptNameOrSourceUrlIndex + kPointerSize;
|
|
|
|
static const int kFlagIndex = kFunctionNameIndex + kPointerSize;
|
2017-04-20 17:33:03 +00:00
|
|
|
static const int kIdIndex = kFlagIndex + kPointerSize;
|
|
|
|
static const int kSize = kIdIndex + kPointerSize;
|
2017-04-03 14:58:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Bit position in the flag, from least significant bit position.
|
|
|
|
static const int kIsEvalBit = 0;
|
|
|
|
static const int kIsConstructorBit = 1;
|
2017-04-08 22:26:22 +00:00
|
|
|
static const int kIsWasmBit = 2;
|
2017-04-03 14:58:49 +00:00
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(StackFrameInfo);
|
|
|
|
};
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-04-12 18:33:20 +00:00
|
|
|
class SourcePositionTableWithFrameCache : public Tuple2 {
|
|
|
|
public:
|
|
|
|
DECL_ACCESSORS(source_position_table, ByteArray)
|
|
|
|
DECL_ACCESSORS(stack_frame_cache, UnseededNumberDictionary)
|
|
|
|
|
2017-06-29 13:14:20 +00:00
|
|
|
DECL_CAST(SourcePositionTableWithFrameCache)
|
2017-04-12 18:33:20 +00:00
|
|
|
|
|
|
|
static const int kSourcePositionTableIndex = Struct::kHeaderSize;
|
|
|
|
static const int kStackFrameCacheIndex =
|
|
|
|
kSourcePositionTableIndex + kPointerSize;
|
|
|
|
static const int kSize = kStackFrameCacheIndex + kPointerSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(SourcePositionTableWithFrameCache);
|
|
|
|
};
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Abstract base class for visiting, and optionally modifying, the
|
|
|
|
// pointers contained in Objects. Used in GC and serialization/deserialization.
|
2017-04-25 13:32:18 +00:00
|
|
|
// TODO(ulan): move to src/visitors.h
|
2008-07-03 15:10:15 +00:00
|
|
|
class ObjectVisitor BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
virtual ~ObjectVisitor() {}
|
|
|
|
|
|
|
|
// Visits a contiguous arrays of pointers in the half-open range
|
|
|
|
// [start, end). Any or all of the values may be modified on return.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitPointers(HeapObject* host, Object** start,
|
|
|
|
Object** end) = 0;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-10-23 10:47:51 +00:00
|
|
|
// Handy shorthand for visiting a single pointer.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitPointer(HeapObject* host, Object** p) {
|
|
|
|
VisitPointers(host, p, p + 1);
|
|
|
|
}
|
2013-10-23 10:47:51 +00:00
|
|
|
|
2014-03-26 15:14:51 +00:00
|
|
|
// Visit weak next_code_link in Code object.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitNextCodeLink(Code* host, Object** p) {
|
|
|
|
VisitPointers(host, p, p + 1);
|
|
|
|
}
|
2014-03-26 15:14:51 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// To allow lazy clearing of inline caches the visitor has
|
|
|
|
// a rich interface for iterating over Code objects..
|
|
|
|
|
|
|
|
// Visits a code target in the instruction stream.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitCodeTarget(Code* host, RelocInfo* rinfo);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-08-20 07:10:18 +00:00
|
|
|
// Visits a code entry in a JS function.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitCodeEntry(JSFunction* host, Address entry_address);
|
2010-08-20 07:10:18 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Visits a global property cell reference in the instruction stream.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitCellPointer(Code* host, RelocInfo* rinfo);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Visits a runtime entry in the instruction stream.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitRuntimeEntry(Code* host, RelocInfo* rinfo) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Visits a debug call target in the instruction stream.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitDebugTarget(Code* host, RelocInfo* rinfo);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-11-08 12:18:11 +00:00
|
|
|
// Visits the byte sequence in a function's prologue that contains information
|
|
|
|
// about the code's age.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitCodeAgeSequence(Code* host, RelocInfo* rinfo);
|
2012-11-08 12:18:11 +00:00
|
|
|
|
2011-09-28 17:45:58 +00:00
|
|
|
// Visit pointer embedded into a code object.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitEmbeddedPointer(Code* host, RelocInfo* rinfo);
|
2011-09-28 17:45:58 +00:00
|
|
|
|
2013-10-23 10:47:51 +00:00
|
|
|
// Visits an external reference embedded into a code object.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitExternalReference(Code* host, RelocInfo* rinfo) {}
|
2011-11-11 12:28:42 +00:00
|
|
|
|
2015-03-18 13:38:32 +00:00
|
|
|
// Visits an external reference.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitExternalReference(Foreign* host, Address* p) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-03-18 13:38:32 +00:00
|
|
|
// Visits an (encoded) internal reference.
|
2017-04-25 14:18:52 +00:00
|
|
|
virtual void VisitInternalReference(Code* host, RelocInfo* rinfo) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
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_
|