2012-01-26 21:47:57 +00:00
|
|
|
// Copyright 2012 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_CONTEXTS_H_
|
|
|
|
#define V8_CONTEXTS_H_
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/objects.h"
|
2010-08-30 07:10:40 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-01-20 13:01:55 +00:00
|
|
|
class RegExpMatchInfo;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
enum ContextLookupFlags {
|
2015-10-12 14:30:46 +00:00
|
|
|
FOLLOW_CONTEXT_CHAIN = 1 << 0,
|
|
|
|
FOLLOW_PROTOTYPE_CHAIN = 1 << 1,
|
|
|
|
STOP_AT_DECLARATION_SCOPE = 1 << 2,
|
|
|
|
SKIP_WITH_CONTEXT = 1 << 3,
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
DONT_FOLLOW_CHAINS = 0,
|
2015-10-12 14:30:46 +00:00
|
|
|
FOLLOW_CHAINS = FOLLOW_CONTEXT_CHAIN | FOLLOW_PROTOTYPE_CHAIN,
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Heap-allocated activation contexts.
|
|
|
|
//
|
|
|
|
// Contexts are implemented as FixedArray objects; the Context
|
|
|
|
// class is a convenience interface casted on a FixedArray object.
|
|
|
|
//
|
|
|
|
// Note: Context must have no virtual functions and Context objects
|
|
|
|
// must always be allocated via Heap::AllocateContext() or
|
|
|
|
// Factory::NewContext.
|
|
|
|
|
2017-04-13 12:57:06 +00:00
|
|
|
#define NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \
|
|
|
|
V(ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, JSFunction, \
|
|
|
|
async_function_await_caught) \
|
|
|
|
V(ASYNC_FUNCTION_AWAIT_UNCAUGHT_INDEX, JSFunction, \
|
|
|
|
async_function_await_uncaught) \
|
|
|
|
V(ASYNC_FUNCTION_PROMISE_CREATE_INDEX, JSFunction, \
|
|
|
|
async_function_promise_create) \
|
|
|
|
V(ASYNC_FUNCTION_PROMISE_RELEASE_INDEX, JSFunction, \
|
|
|
|
async_function_promise_release) \
|
|
|
|
V(IS_ARRAYLIKE, JSFunction, is_arraylike) \
|
|
|
|
V(GENERATOR_NEXT_INTERNAL, JSFunction, generator_next_internal) \
|
|
|
|
V(MAKE_ERROR_INDEX, JSFunction, make_error) \
|
|
|
|
V(MAKE_RANGE_ERROR_INDEX, JSFunction, make_range_error) \
|
|
|
|
V(MAKE_SYNTAX_ERROR_INDEX, JSFunction, make_syntax_error) \
|
|
|
|
V(MAKE_TYPE_ERROR_INDEX, JSFunction, make_type_error) \
|
|
|
|
V(MAKE_URI_ERROR_INDEX, JSFunction, make_uri_error) \
|
|
|
|
V(OBJECT_CREATE, JSFunction, object_create) \
|
|
|
|
V(OBJECT_DEFINE_PROPERTIES, JSFunction, object_define_properties) \
|
|
|
|
V(OBJECT_DEFINE_PROPERTY, JSFunction, object_define_property) \
|
|
|
|
V(OBJECT_GET_PROTOTYPE_OF, JSFunction, object_get_prototype_of) \
|
|
|
|
V(OBJECT_IS_EXTENSIBLE, JSFunction, object_is_extensible) \
|
|
|
|
V(OBJECT_IS_FROZEN, JSFunction, object_is_frozen) \
|
|
|
|
V(OBJECT_IS_SEALED, JSFunction, object_is_sealed) \
|
|
|
|
V(OBJECT_KEYS, JSFunction, object_keys) \
|
|
|
|
V(REGEXP_INTERNAL_MATCH, JSFunction, regexp_internal_match) \
|
|
|
|
V(REFLECT_APPLY_INDEX, JSFunction, reflect_apply) \
|
|
|
|
V(REFLECT_CONSTRUCT_INDEX, JSFunction, reflect_construct) \
|
|
|
|
V(REFLECT_DEFINE_PROPERTY_INDEX, JSFunction, reflect_define_property) \
|
|
|
|
V(REFLECT_DELETE_PROPERTY_INDEX, JSFunction, reflect_delete_property) \
|
|
|
|
V(SPREAD_ARGUMENTS_INDEX, JSFunction, spread_arguments) \
|
|
|
|
V(SPREAD_ITERABLE_INDEX, JSFunction, spread_iterable) \
|
|
|
|
V(TYPED_ARRAY_CONSTRUCT_BY_ARRAY_BUFFER_INDEX, JSFunction, \
|
|
|
|
typed_array_construct_by_array_buffer) \
|
|
|
|
V(TYPED_ARRAY_CONSTRUCT_BY_ARRAY_LIKE_INDEX, JSFunction, \
|
|
|
|
typed_array_construct_by_array_like) \
|
|
|
|
V(TYPED_ARRAY_CONSTRUCT_BY_LENGTH_INDEX, JSFunction, \
|
|
|
|
typed_array_construct_by_length) \
|
|
|
|
V(MATH_FLOOR_INDEX, JSFunction, math_floor) \
|
|
|
|
V(MATH_POW_INDEX, JSFunction, math_pow) \
|
|
|
|
V(NEW_PROMISE_CAPABILITY_INDEX, JSFunction, new_promise_capability) \
|
|
|
|
V(PROMISE_INTERNAL_CONSTRUCTOR_INDEX, JSFunction, \
|
|
|
|
promise_internal_constructor) \
|
|
|
|
V(PROMISE_INTERNAL_REJECT_INDEX, JSFunction, promise_internal_reject) \
|
|
|
|
V(IS_PROMISE_INDEX, JSFunction, is_promise) \
|
|
|
|
V(PROMISE_RESOLVE_INDEX, JSFunction, promise_resolve) \
|
|
|
|
V(PROMISE_THEN_INDEX, JSFunction, promise_then) \
|
|
|
|
V(PROMISE_HANDLE_INDEX, JSFunction, promise_handle) \
|
|
|
|
V(PROMISE_HANDLE_REJECT_INDEX, JSFunction, promise_handle_reject) \
|
|
|
|
V(ASYNC_GENERATOR_AWAIT_CAUGHT, JSFunction, async_generator_await_caught) \
|
2017-04-24 20:49:00 +00:00
|
|
|
V(ASYNC_GENERATOR_AWAIT_UNCAUGHT, JSFunction, async_generator_await_uncaught)
|
2015-08-27 10:18:21 +00:00
|
|
|
|
2017-06-19 15:17:22 +00:00
|
|
|
#define NATIVE_CONTEXT_IMPORTED_FIELDS(V) \
|
|
|
|
V(ARRAY_CONCAT_INDEX, JSFunction, array_concat) \
|
|
|
|
V(ARRAY_POP_INDEX, JSFunction, array_pop) \
|
|
|
|
V(ARRAY_PUSH_INDEX, JSFunction, array_push) \
|
|
|
|
V(ARRAY_SHIFT_INDEX, JSFunction, array_shift) \
|
|
|
|
V(ARRAY_SPLICE_INDEX, JSFunction, array_splice) \
|
|
|
|
V(ARRAY_SLICE_INDEX, JSFunction, array_slice) \
|
|
|
|
V(ARRAY_UNSHIFT_INDEX, JSFunction, array_unshift) \
|
|
|
|
V(ARRAY_ENTRIES_ITERATOR_INDEX, JSFunction, array_entries_iterator) \
|
|
|
|
V(ARRAY_FOR_EACH_ITERATOR_INDEX, JSFunction, array_for_each_iterator) \
|
|
|
|
V(ARRAY_KEYS_ITERATOR_INDEX, JSFunction, array_keys_iterator) \
|
|
|
|
V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \
|
|
|
|
V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \
|
|
|
|
V(ERROR_FUNCTION_INDEX, JSFunction, error_function) \
|
|
|
|
V(ERROR_TO_STRING, JSFunction, error_to_string) \
|
|
|
|
V(EVAL_ERROR_FUNCTION_INDEX, JSFunction, eval_error_function) \
|
|
|
|
V(GLOBAL_EVAL_FUN_INDEX, JSFunction, global_eval_fun) \
|
|
|
|
V(GLOBAL_PROXY_FUNCTION_INDEX, JSFunction, global_proxy_function) \
|
|
|
|
V(MAP_DELETE_INDEX, JSFunction, map_delete) \
|
|
|
|
V(MAP_GET_INDEX, JSFunction, map_get) \
|
|
|
|
V(MAP_HAS_INDEX, JSFunction, map_has) \
|
|
|
|
V(MAP_SET_INDEX, JSFunction, map_set) \
|
|
|
|
V(FUNCTION_HAS_INSTANCE_INDEX, JSFunction, function_has_instance) \
|
|
|
|
V(OBJECT_VALUE_OF, JSFunction, object_value_of) \
|
|
|
|
V(OBJECT_TO_STRING, JSFunction, object_to_string) \
|
|
|
|
V(PROMISE_CATCH_INDEX, JSFunction, promise_catch) \
|
|
|
|
V(PROMISE_FUNCTION_INDEX, JSFunction, promise_function) \
|
|
|
|
V(RANGE_ERROR_FUNCTION_INDEX, JSFunction, range_error_function) \
|
|
|
|
V(REFERENCE_ERROR_FUNCTION_INDEX, JSFunction, reference_error_function) \
|
|
|
|
V(SET_ADD_INDEX, JSFunction, set_add) \
|
|
|
|
V(SET_DELETE_INDEX, JSFunction, set_delete) \
|
|
|
|
V(SET_HAS_INDEX, JSFunction, set_has) \
|
|
|
|
V(SYNTAX_ERROR_FUNCTION_INDEX, JSFunction, syntax_error_function) \
|
|
|
|
V(TYPE_ERROR_FUNCTION_INDEX, JSFunction, type_error_function) \
|
|
|
|
V(URI_ERROR_FUNCTION_INDEX, JSFunction, uri_error_function) \
|
|
|
|
V(WASM_COMPILE_ERROR_FUNCTION_INDEX, JSFunction, \
|
|
|
|
wasm_compile_error_function) \
|
|
|
|
V(WASM_LINK_ERROR_FUNCTION_INDEX, JSFunction, wasm_link_error_function) \
|
2016-10-13 16:17:44 +00:00
|
|
|
V(WASM_RUNTIME_ERROR_FUNCTION_INDEX, JSFunction, wasm_runtime_error_function)
|
2015-08-24 07:15:01 +00:00
|
|
|
|
2016-10-18 02:42:42 +00:00
|
|
|
#define NATIVE_CONTEXT_JS_ARRAY_ITERATOR_MAPS(V) \
|
2016-12-06 13:09:38 +00:00
|
|
|
V(TYPED_ARRAY_KEY_ITERATOR_MAP_INDEX, Map, typed_array_key_iterator_map) \
|
2016-10-18 02:42:42 +00:00
|
|
|
V(FAST_ARRAY_KEY_ITERATOR_MAP_INDEX, Map, fast_array_key_iterator_map) \
|
|
|
|
V(GENERIC_ARRAY_KEY_ITERATOR_MAP_INDEX, Map, array_key_iterator_map) \
|
|
|
|
\
|
|
|
|
V(UINT8_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
uint8_array_key_value_iterator_map) \
|
|
|
|
V(INT8_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
int8_array_key_value_iterator_map) \
|
|
|
|
V(UINT16_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
uint16_array_key_value_iterator_map) \
|
|
|
|
V(INT16_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
int16_array_key_value_iterator_map) \
|
|
|
|
V(UINT32_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
uint32_array_key_value_iterator_map) \
|
|
|
|
V(INT32_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
int32_array_key_value_iterator_map) \
|
|
|
|
V(FLOAT32_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
float32_array_key_value_iterator_map) \
|
|
|
|
V(FLOAT64_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
float64_array_key_value_iterator_map) \
|
|
|
|
V(UINT8_CLAMPED_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
uint8_clamped_array_key_value_iterator_map) \
|
|
|
|
\
|
|
|
|
V(FAST_SMI_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_smi_array_key_value_iterator_map) \
|
|
|
|
V(FAST_HOLEY_SMI_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_holey_smi_array_key_value_iterator_map) \
|
|
|
|
V(FAST_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_array_key_value_iterator_map) \
|
|
|
|
V(FAST_HOLEY_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_holey_array_key_value_iterator_map) \
|
|
|
|
V(FAST_DOUBLE_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_double_array_key_value_iterator_map) \
|
|
|
|
V(FAST_HOLEY_DOUBLE_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_holey_double_array_key_value_iterator_map) \
|
|
|
|
V(GENERIC_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
array_key_value_iterator_map) \
|
|
|
|
\
|
|
|
|
V(UINT8_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, uint8_array_value_iterator_map) \
|
|
|
|
V(INT8_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, int8_array_value_iterator_map) \
|
|
|
|
V(UINT16_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
uint16_array_value_iterator_map) \
|
|
|
|
V(INT16_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, int16_array_value_iterator_map) \
|
|
|
|
V(UINT32_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
uint32_array_value_iterator_map) \
|
|
|
|
V(INT32_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, int32_array_value_iterator_map) \
|
|
|
|
V(FLOAT32_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
float32_array_value_iterator_map) \
|
|
|
|
V(FLOAT64_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
float64_array_value_iterator_map) \
|
|
|
|
V(UINT8_CLAMPED_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
uint8_clamped_array_value_iterator_map) \
|
|
|
|
\
|
|
|
|
V(FAST_SMI_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_smi_array_value_iterator_map) \
|
|
|
|
V(FAST_HOLEY_SMI_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_holey_smi_array_value_iterator_map) \
|
|
|
|
V(FAST_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, fast_array_value_iterator_map) \
|
|
|
|
V(FAST_HOLEY_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_holey_array_value_iterator_map) \
|
|
|
|
V(FAST_DOUBLE_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_double_array_value_iterator_map) \
|
|
|
|
V(FAST_HOLEY_DOUBLE_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, \
|
|
|
|
fast_holey_double_array_value_iterator_map) \
|
|
|
|
V(GENERIC_ARRAY_VALUE_ITERATOR_MAP_INDEX, Map, array_value_iterator_map)
|
|
|
|
|
2014-07-07 13:27:37 +00:00
|
|
|
#define NATIVE_CONTEXT_FIELDS(V) \
|
|
|
|
V(GLOBAL_PROXY_INDEX, JSObject, global_proxy_object) \
|
2015-08-14 15:12:34 +00:00
|
|
|
V(EMBEDDER_DATA_INDEX, FixedArray, embedder_data) \
|
2015-08-24 07:15:01 +00:00
|
|
|
/* Below is alpha-sorted */ \
|
2016-01-20 19:04:06 +00:00
|
|
|
V(ACCESSOR_PROPERTY_DESCRIPTOR_MAP_INDEX, Map, \
|
|
|
|
accessor_property_descriptor_map) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings) \
|
2017-11-08 23:33:46 +00:00
|
|
|
V(ALLOW_WASM_EVAL_INDEX, Object, allow_wasm_eval) \
|
2014-07-07 13:27:37 +00:00
|
|
|
V(ARRAY_BUFFER_FUN_INDEX, JSFunction, array_buffer_fun) \
|
2015-04-30 13:46:27 +00:00
|
|
|
V(ARRAY_BUFFER_MAP_INDEX, Map, array_buffer_map) \
|
2017-04-06 13:09:38 +00:00
|
|
|
V(ARRAY_BUFFER_NOINIT_FUN_INDEX, JSFunction, array_buffer_noinit_fun) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(ARRAY_FUNCTION_INDEX, JSFunction, array_function) \
|
2017-02-24 17:48:49 +00:00
|
|
|
V(ASYNC_FROM_SYNC_ITERATOR_MAP_INDEX, Map, async_from_sync_iterator_map) \
|
2017-01-20 19:36:28 +00:00
|
|
|
V(ASYNC_FUNCTION_AWAIT_REJECT_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
async_function_await_reject_shared_fun) \
|
|
|
|
V(ASYNC_FUNCTION_AWAIT_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
async_function_await_resolve_shared_fun) \
|
2016-05-17 00:26:53 +00:00
|
|
|
V(ASYNC_FUNCTION_FUNCTION_INDEX, JSFunction, async_function_constructor) \
|
[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(ASYNC_GENERATOR_FUNCTION_FUNCTION_INDEX, JSFunction, \
|
|
|
|
async_generator_function_function) \
|
2017-02-24 17:48:49 +00:00
|
|
|
V(ASYNC_ITERATOR_VALUE_UNWRAP_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
async_iterator_value_unwrap_shared_fun) \
|
[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(ASYNC_GENERATOR_AWAIT_REJECT_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
async_generator_await_reject_shared_fun) \
|
|
|
|
V(ASYNC_GENERATOR_AWAIT_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
async_generator_await_resolve_shared_fun) \
|
2017-08-07 14:13:18 +00:00
|
|
|
V(ASYNC_GENERATOR_YIELD_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
async_generator_yield_resolve_shared_fun) \
|
Reland "[async-iteration] implement spec-change to `yield` in async generators"
Per https://github.com/tc39/proposal-async-iteration/pull/102/files:
AsyncGeneratorResolve no longer unwraps a value component. Instead, the value is
unwrapped before the builtin call via Await, allowing Promise rejections to
affect the generator control flow.
Thus, all `yield <expr>` implicitly become `yield await <expr>`.
Additionally, `return <expr>` becomes `return await <expr>`. Finally, when the
generator is resumed with `.return()`, the parameter passed to .return() is
awaited before generator execution properly continues).
BUG=v8:6187, v8:5855
R=littledan@chromium.org, neis@chromium.org, adamk@chromium.org
TBR=rmcilroy@chromium.org, neis@chromium.org
Cq-Include-Trybots: master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: Id7718028fd555481f9f4ca0dbecfa788e3057c48
Reviewed-on: https://chromium-review.googlesource.com/594500
Reviewed-by: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Cr-Commit-Position: refs/heads/master@{#47058}
2017-08-01 14:45:03 +00:00
|
|
|
V(ASYNC_GENERATOR_RETURN_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
async_generator_return_resolve_shared_fun) \
|
2017-08-09 13:43:29 +00:00
|
|
|
V(ASYNC_GENERATOR_RETURN_CLOSED_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
async_generator_return_closed_resolve_shared_fun) \
|
|
|
|
V(ASYNC_GENERATOR_RETURN_CLOSED_REJECT_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
async_generator_return_closed_reject_shared_fun) \
|
2017-06-13 23:17:05 +00:00
|
|
|
V(ATOMICS_OBJECT, JSObject, atomics_object) \
|
2017-09-20 05:32:15 +00:00
|
|
|
V(BIGINT_FUNCTION_INDEX, JSFunction, bigint_function) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(BOOLEAN_FUNCTION_INDEX, JSFunction, boolean_function) \
|
2015-10-02 16:51:20 +00:00
|
|
|
V(BOUND_FUNCTION_WITH_CONSTRUCTOR_MAP_INDEX, Map, \
|
|
|
|
bound_function_with_constructor_map) \
|
|
|
|
V(BOUND_FUNCTION_WITHOUT_CONSTRUCTOR_MAP_INDEX, Map, \
|
|
|
|
bound_function_without_constructor_map) \
|
2014-07-07 13:27:37 +00:00
|
|
|
V(CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, JSFunction, \
|
|
|
|
call_as_constructor_delegate) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate) \
|
2016-08-01 14:26:53 +00:00
|
|
|
V(CALLSITE_FUNCTION_INDEX, JSFunction, callsite_function) \
|
2014-07-07 13:27:37 +00:00
|
|
|
V(CONTEXT_EXTENSION_FUNCTION_INDEX, JSFunction, context_extension_function) \
|
2016-01-20 19:04:06 +00:00
|
|
|
V(DATA_PROPERTY_DESCRIPTOR_MAP_INDEX, Map, data_property_descriptor_map) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \
|
2015-12-07 16:35:03 +00:00
|
|
|
V(DATE_FUNCTION_INDEX, JSFunction, date_function) \
|
2017-04-12 11:24:44 +00:00
|
|
|
V(DEBUG_CONTEXT_ID_INDEX, Object, debug_context_id) \
|
2014-07-07 13:27:37 +00:00
|
|
|
V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object, \
|
|
|
|
error_message_for_code_gen_from_strings) \
|
2015-11-06 08:07:52 +00:00
|
|
|
V(ERRORS_THROWN_INDEX, Smi, errors_thrown) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(EXTRAS_EXPORTS_OBJECT_INDEX, JSObject, extras_binding_object) \
|
2017-02-03 07:12:33 +00:00
|
|
|
V(EXTRAS_UTILS_OBJECT_INDEX, Object, extras_utils_object) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(FAST_ALIASED_ARGUMENTS_MAP_INDEX, Map, fast_aliased_arguments_map) \
|
2016-12-05 17:48:07 +00:00
|
|
|
V(FAST_TEMPLATE_INSTANTIATIONS_CACHE_INDEX, FixedArray, \
|
|
|
|
fast_template_instantiations_cache) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(FLOAT32_ARRAY_FUN_INDEX, JSFunction, float32_array_fun) \
|
|
|
|
V(FLOAT64_ARRAY_FUN_INDEX, JSFunction, float64_array_fun) \
|
2015-12-07 16:35:03 +00:00
|
|
|
V(FUNCTION_FUNCTION_INDEX, JSFunction, function_function) \
|
|
|
|
V(GENERATOR_FUNCTION_FUNCTION_INDEX, JSFunction, \
|
|
|
|
generator_function_function) \
|
2014-07-07 13:27:37 +00:00
|
|
|
V(GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, generator_object_prototype_map) \
|
[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(ASYNC_GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, \
|
|
|
|
async_generator_object_prototype_map) \
|
2016-11-15 14:41:27 +00:00
|
|
|
V(INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX, JSObject, \
|
|
|
|
initial_array_iterator_prototype) \
|
|
|
|
V(INITIAL_ARRAY_ITERATOR_PROTOTYPE_MAP_INDEX, Map, \
|
|
|
|
initial_array_iterator_prototype_map) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(INITIAL_ARRAY_PROTOTYPE_INDEX, JSObject, initial_array_prototype) \
|
2017-07-04 13:46:27 +00:00
|
|
|
V(INITIAL_ERROR_PROTOTYPE_INDEX, JSObject, initial_error_prototype) \
|
2016-05-18 09:15:40 +00:00
|
|
|
V(INITIAL_GENERATOR_PROTOTYPE_INDEX, JSObject, initial_generator_prototype) \
|
[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(INITIAL_ASYNC_GENERATOR_PROTOTYPE_INDEX, JSObject, \
|
|
|
|
initial_async_generator_prototype) \
|
2016-09-21 14:17:42 +00:00
|
|
|
V(INITIAL_ITERATOR_PROTOTYPE_INDEX, JSObject, initial_iterator_prototype) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(INITIAL_OBJECT_PROTOTYPE_INDEX, JSObject, initial_object_prototype) \
|
2017-10-30 15:51:26 +00:00
|
|
|
V(INITIAL_STRING_PROTOTYPE_INDEX, JSObject, initial_string_prototype) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(INT16_ARRAY_FUN_INDEX, JSFunction, int16_array_fun) \
|
|
|
|
V(INT32_ARRAY_FUN_INDEX, JSFunction, int32_array_fun) \
|
|
|
|
V(INT8_ARRAY_FUN_INDEX, JSFunction, int8_array_fun) \
|
|
|
|
V(INTERNAL_ARRAY_FUNCTION_INDEX, JSFunction, internal_array_function) \
|
2014-07-07 13:27:37 +00:00
|
|
|
V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map) \
|
2017-01-12 17:58:19 +00:00
|
|
|
V(INTL_DATE_TIME_FORMAT_FUNCTION_INDEX, JSFunction, \
|
|
|
|
intl_date_time_format_function) \
|
|
|
|
V(INTL_NUMBER_FORMAT_FUNCTION_INDEX, JSFunction, \
|
|
|
|
intl_number_format_function) \
|
|
|
|
V(INTL_COLLATOR_FUNCTION_INDEX, JSFunction, intl_collator_function) \
|
2017-08-18 16:51:52 +00:00
|
|
|
V(INTL_PLURAL_RULES_FUNCTION_INDEX, JSFunction, intl_plural_rules_function) \
|
2017-01-12 17:58:19 +00:00
|
|
|
V(INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX, JSFunction, \
|
|
|
|
intl_v8_break_iterator_function) \
|
2017-06-30 11:26:14 +00:00
|
|
|
V(JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX, Map, \
|
2015-12-11 06:50:46 +00:00
|
|
|
js_array_fast_smi_elements_map_index) \
|
2017-06-30 11:26:14 +00:00
|
|
|
V(JS_ARRAY_HOLEY_SMI_ELEMENTS_MAP_INDEX, Map, \
|
2015-12-11 06:50:46 +00:00
|
|
|
js_array_fast_holey_smi_elements_map_index) \
|
2017-06-30 11:26:14 +00:00
|
|
|
V(JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX, Map, js_array_fast_elements_map_index) \
|
|
|
|
V(JS_ARRAY_HOLEY_ELEMENTS_MAP_INDEX, Map, \
|
2015-12-11 06:50:46 +00:00
|
|
|
js_array_fast_holey_elements_map_index) \
|
2017-06-30 11:26:14 +00:00
|
|
|
V(JS_ARRAY_PACKED_DOUBLE_ELEMENTS_MAP_INDEX, Map, \
|
2015-12-11 06:50:46 +00:00
|
|
|
js_array_fast_double_elements_map_index) \
|
2017-06-30 11:26:14 +00:00
|
|
|
V(JS_ARRAY_HOLEY_DOUBLE_ELEMENTS_MAP_INDEX, Map, \
|
2015-12-11 06:50:46 +00:00
|
|
|
js_array_fast_holey_double_elements_map_index) \
|
2015-06-01 23:16:27 +00:00
|
|
|
V(JS_MAP_FUN_INDEX, JSFunction, js_map_fun) \
|
2015-05-26 17:36:48 +00:00
|
|
|
V(JS_MAP_MAP_INDEX, Map, js_map_map) \
|
2016-10-07 19:37:04 +00:00
|
|
|
V(JS_MODULE_NAMESPACE_MAP, Map, js_module_namespace_map) \
|
2015-06-01 23:16:27 +00:00
|
|
|
V(JS_SET_FUN_INDEX, JSFunction, js_set_fun) \
|
2015-05-26 17:36:48 +00:00
|
|
|
V(JS_SET_MAP_INDEX, Map, js_set_map) \
|
2015-12-07 16:35:03 +00:00
|
|
|
V(JS_WEAK_MAP_FUN_INDEX, JSFunction, js_weak_map_fun) \
|
|
|
|
V(JS_WEAK_SET_FUN_INDEX, JSFunction, js_weak_set_fun) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(MAP_CACHE_INDEX, Object, map_cache) \
|
2017-07-10 06:46:56 +00:00
|
|
|
V(MAP_KEY_ITERATOR_MAP_INDEX, Map, map_key_iterator_map) \
|
|
|
|
V(MAP_KEY_VALUE_ITERATOR_MAP_INDEX, Map, map_key_value_iterator_map) \
|
|
|
|
V(MAP_VALUE_ITERATOR_MAP_INDEX, Map, map_value_iterator_map) \
|
2016-10-11 06:46:56 +00:00
|
|
|
V(MATH_RANDOM_INDEX_INDEX, Smi, math_random_index) \
|
|
|
|
V(MATH_RANDOM_CACHE_INDEX, Object, math_random_cache) \
|
2016-08-01 14:28:06 +00:00
|
|
|
V(MESSAGE_LISTENERS_INDEX, TemplateList, message_listeners) \
|
2015-05-21 06:15:33 +00:00
|
|
|
V(NATIVES_UTILS_OBJECT_INDEX, Object, natives_utils_object) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(NORMALIZED_MAP_CACHE_INDEX, Object, normalized_map_cache) \
|
|
|
|
V(NUMBER_FUNCTION_INDEX, JSFunction, number_function) \
|
|
|
|
V(OBJECT_FUNCTION_INDEX, JSFunction, object_function) \
|
2015-09-23 13:49:09 +00:00
|
|
|
V(OBJECT_FUNCTION_PROTOTYPE_MAP_INDEX, Map, object_function_prototype_map) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(OPAQUE_REFERENCE_FUNCTION_INDEX, JSFunction, opaque_reference_function) \
|
2015-12-08 16:04:08 +00:00
|
|
|
V(PROXY_CALLABLE_MAP_INDEX, Map, proxy_callable_map) \
|
|
|
|
V(PROXY_CONSTRUCTOR_MAP_INDEX, Map, proxy_constructor_map) \
|
2015-11-19 16:11:00 +00:00
|
|
|
V(PROXY_FUNCTION_INDEX, JSFunction, proxy_function) \
|
2015-12-08 16:04:08 +00:00
|
|
|
V(PROXY_MAP_INDEX, Map, proxy_map) \
|
2017-01-02 17:22:30 +00:00
|
|
|
V(PROMISE_GET_CAPABILITIES_EXECUTOR_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
promise_get_capabilities_executor_shared_fun) \
|
2016-11-10 16:04:15 +00:00
|
|
|
V(PROMISE_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
promise_resolve_shared_fun) \
|
|
|
|
V(PROMISE_REJECT_SHARED_FUN, SharedFunctionInfo, promise_reject_shared_fun) \
|
2017-02-17 22:10:28 +00:00
|
|
|
V(PROMISE_THEN_FINALLY_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
promise_then_finally_shared_fun) \
|
|
|
|
V(PROMISE_CATCH_FINALLY_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
promise_catch_finally_shared_fun) \
|
|
|
|
V(PROMISE_VALUE_THUNK_FINALLY_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
promise_value_thunk_finally_shared_fun) \
|
|
|
|
V(PROMISE_THROWER_FINALLY_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
promise_thrower_finally_shared_fun) \
|
Reland "[builtins] port Promise.all to CSA"
Simplifies the implementation of IteratorClose in IteratorBuiltinsAssembler, and makes clear that it is only invoked when an exception occurs. Adds exception handling support to GetIterator, IteratorStep, and IteratorCloseOnException.
Moves the Promise.all resolveElement closure and it's caller to
builtins-promise-gen.cc.
Instead of creating an internal array (and copying its elements into a
result
array), a single JSArray is allocated, and appended with
BuildAppendJSArray(),
falling back to %CreateDataProperty(), and elements are updated in the
resolve
closure the same way. This should always be unobservable.
This CL increases the size of snapshot_blob.bin on an x64.release build
by 8.51kb
BUG=v8:5343
R=cbruni@chromium.org, gsathysa@chromium.org, jgruber@chromium.org, hpayer@chromium.org, tebbi@chromium.org
Change-Id: I29c4a529154ef49ad65555ce6ddc2c5b7c9de6b3
Reviewed-on: https://chromium-review.googlesource.com/508473
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45946}
2017-06-13 17:14:57 +00:00
|
|
|
V(PROMISE_ALL_RESOLVE_ELEMENT_SHARED_FUN, SharedFunctionInfo, \
|
|
|
|
promise_all_resolve_element_shared_fun) \
|
2016-12-08 06:12:35 +00:00
|
|
|
V(PROMISE_PROTOTYPE_MAP_INDEX, Map, promise_prototype_map) \
|
2016-10-10 13:56:46 +00:00
|
|
|
V(REGEXP_EXEC_FUNCTION_INDEX, JSFunction, regexp_exec_function) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(REGEXP_FUNCTION_INDEX, JSFunction, regexp_function) \
|
2016-10-14 11:46:43 +00:00
|
|
|
V(REGEXP_LAST_MATCH_INFO_INDEX, RegExpMatchInfo, regexp_last_match_info) \
|
|
|
|
V(REGEXP_INTERNAL_MATCH_INFO_INDEX, RegExpMatchInfo, \
|
|
|
|
regexp_internal_match_info) \
|
2016-10-13 11:27:25 +00:00
|
|
|
V(REGEXP_PROTOTYPE_MAP_INDEX, Map, regexp_prototype_map) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(REGEXP_RESULT_MAP_INDEX, Map, regexp_result_map) \
|
|
|
|
V(SCRIPT_CONTEXT_TABLE_INDEX, ScriptContextTable, script_context_table) \
|
|
|
|
V(SCRIPT_FUNCTION_INDEX, JSFunction, script_function) \
|
|
|
|
V(SECURITY_TOKEN_INDEX, Object, security_token) \
|
2015-12-09 08:54:47 +00:00
|
|
|
V(SELF_WEAK_CELL_INDEX, WeakCell, self_weak_cell) \
|
2017-07-10 06:46:56 +00:00
|
|
|
V(SET_VALUE_ITERATOR_MAP_INDEX, Map, set_value_iterator_map) \
|
|
|
|
V(SET_KEY_VALUE_ITERATOR_MAP_INDEX, Map, set_key_value_iterator_map) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(SHARED_ARRAY_BUFFER_FUN_INDEX, JSFunction, shared_array_buffer_fun) \
|
|
|
|
V(SLOPPY_ARGUMENTS_MAP_INDEX, Map, sloppy_arguments_map) \
|
|
|
|
V(SLOW_ALIASED_ARGUMENTS_MAP_INDEX, Map, slow_aliased_arguments_map) \
|
2017-06-12 15:47:14 +00:00
|
|
|
V(STRICT_ARGUMENTS_MAP_INDEX, Map, strict_arguments_map) \
|
2016-12-05 17:48:07 +00:00
|
|
|
V(SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP, Map, \
|
|
|
|
slow_object_with_null_prototype_map) \
|
2017-04-27 14:48:32 +00:00
|
|
|
V(SLOW_OBJECT_WITH_OBJECT_PROTOTYPE_MAP, Map, \
|
|
|
|
slow_object_with_object_prototype_map) \
|
2017-11-07 09:35:59 +00:00
|
|
|
V(SLOW_TEMPLATE_INSTANTIATIONS_CACHE_INDEX, NumberDictionary, \
|
2016-12-05 17:48:07 +00:00
|
|
|
slow_template_instantiations_cache) \
|
2017-06-12 15:47:14 +00:00
|
|
|
/* All *_FUNCTION_MAP_INDEX definitions used by Context::FunctionMapIndex */ \
|
|
|
|
/* must remain together. */ \
|
|
|
|
V(SLOPPY_FUNCTION_MAP_INDEX, Map, sloppy_function_map) \
|
2017-07-13 09:33:22 +00:00
|
|
|
V(SLOPPY_FUNCTION_WITH_NAME_MAP_INDEX, Map, sloppy_function_with_name_map) \
|
2017-06-12 15:47:14 +00:00
|
|
|
V(SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \
|
|
|
|
sloppy_function_without_prototype_map) \
|
|
|
|
V(SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map, \
|
|
|
|
sloppy_function_with_readonly_prototype_map) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map) \
|
2017-07-13 09:33:22 +00:00
|
|
|
V(STRICT_FUNCTION_WITH_NAME_MAP_INDEX, Map, strict_function_with_name_map) \
|
2017-07-03 13:40:13 +00:00
|
|
|
V(STRICT_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map, \
|
|
|
|
strict_function_with_readonly_prototype_map) \
|
2017-07-13 09:33:22 +00:00
|
|
|
V(STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \
|
|
|
|
strict_function_without_prototype_map) \
|
|
|
|
V(METHOD_WITH_NAME_MAP_INDEX, Map, method_with_name_map) \
|
|
|
|
V(METHOD_WITH_HOME_OBJECT_MAP_INDEX, Map, method_with_home_object_map) \
|
|
|
|
V(METHOD_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map, \
|
|
|
|
method_with_name_and_home_object_map) \
|
|
|
|
V(ASYNC_FUNCTION_MAP_INDEX, Map, async_function_map) \
|
|
|
|
V(ASYNC_FUNCTION_WITH_NAME_MAP_INDEX, Map, async_function_with_name_map) \
|
|
|
|
V(ASYNC_FUNCTION_WITH_HOME_OBJECT_MAP_INDEX, Map, \
|
|
|
|
async_function_with_home_object_map) \
|
|
|
|
V(ASYNC_FUNCTION_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map, \
|
|
|
|
async_function_with_name_and_home_object_map) \
|
2017-01-03 21:38:22 +00:00
|
|
|
V(GENERATOR_FUNCTION_MAP_INDEX, Map, generator_function_map) \
|
2017-07-13 09:33:22 +00:00
|
|
|
V(GENERATOR_FUNCTION_WITH_NAME_MAP_INDEX, Map, \
|
|
|
|
generator_function_with_name_map) \
|
|
|
|
V(GENERATOR_FUNCTION_WITH_HOME_OBJECT_MAP_INDEX, Map, \
|
|
|
|
generator_function_with_home_object_map) \
|
|
|
|
V(GENERATOR_FUNCTION_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map, \
|
|
|
|
generator_function_with_name_and_home_object_map) \
|
[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(ASYNC_GENERATOR_FUNCTION_MAP_INDEX, Map, async_generator_function_map) \
|
2017-07-13 09:33:22 +00:00
|
|
|
V(ASYNC_GENERATOR_FUNCTION_WITH_NAME_MAP_INDEX, Map, \
|
|
|
|
async_generator_function_with_name_map) \
|
|
|
|
V(ASYNC_GENERATOR_FUNCTION_WITH_HOME_OBJECT_MAP_INDEX, Map, \
|
|
|
|
async_generator_function_with_home_object_map) \
|
|
|
|
V(ASYNC_GENERATOR_FUNCTION_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map, \
|
|
|
|
async_generator_function_with_name_and_home_object_map) \
|
2016-12-07 10:34:15 +00:00
|
|
|
V(CLASS_FUNCTION_MAP_INDEX, Map, class_function_map) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(STRING_FUNCTION_INDEX, JSFunction, string_function) \
|
|
|
|
V(STRING_FUNCTION_PROTOTYPE_MAP_INDEX, Map, string_function_prototype_map) \
|
2016-12-05 17:48:07 +00:00
|
|
|
V(STRING_ITERATOR_MAP_INDEX, Map, string_iterator_map) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(SYMBOL_FUNCTION_INDEX, JSFunction, symbol_function) \
|
2017-01-18 19:13:49 +00:00
|
|
|
V(NATIVE_FUNCTION_MAP_INDEX, Map, native_function_map) \
|
2016-12-05 17:48:07 +00:00
|
|
|
V(WASM_INSTANCE_CONSTRUCTOR_INDEX, JSFunction, wasm_instance_constructor) \
|
|
|
|
V(WASM_MEMORY_CONSTRUCTOR_INDEX, JSFunction, wasm_memory_constructor) \
|
|
|
|
V(WASM_MODULE_CONSTRUCTOR_INDEX, JSFunction, wasm_module_constructor) \
|
|
|
|
V(WASM_TABLE_CONSTRUCTOR_INDEX, JSFunction, wasm_table_constructor) \
|
2017-09-22 09:57:29 +00:00
|
|
|
V(TEMPLATE_MAP_INDEX, HeapObject, template_map) \
|
2016-06-08 07:40:11 +00:00
|
|
|
V(TYPED_ARRAY_FUN_INDEX, JSFunction, typed_array_function) \
|
|
|
|
V(TYPED_ARRAY_PROTOTYPE_INDEX, JSObject, typed_array_prototype) \
|
2015-08-24 07:15:01 +00:00
|
|
|
V(UINT16_ARRAY_FUN_INDEX, JSFunction, uint16_array_fun) \
|
|
|
|
V(UINT32_ARRAY_FUN_INDEX, JSFunction, uint32_array_fun) \
|
|
|
|
V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun) \
|
|
|
|
V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun) \
|
2015-08-26 11:16:38 +00:00
|
|
|
NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \
|
2016-10-18 02:42:42 +00:00
|
|
|
NATIVE_CONTEXT_IMPORTED_FIELDS(V) \
|
|
|
|
NATIVE_CONTEXT_JS_ARRAY_ITERATOR_MAPS(V)
|
2014-11-07 16:29:13 +00:00
|
|
|
|
2014-11-12 11:34:09 +00:00
|
|
|
// A table of all script contexts. Every loaded top-level script with top-level
|
|
|
|
// lexical declarations contributes its ScriptContext into this table.
|
2014-11-07 16:29:13 +00:00
|
|
|
//
|
|
|
|
// The table is a fixed array, its first slot is the current used count and
|
2014-11-12 11:34:09 +00:00
|
|
|
// the subsequent slots 1..used contain ScriptContexts.
|
|
|
|
class ScriptContextTable : public FixedArray {
|
2014-11-07 16:29:13 +00:00
|
|
|
public:
|
|
|
|
// Conversions.
|
2015-09-01 09:25:19 +00:00
|
|
|
static inline ScriptContextTable* cast(Object* context);
|
2014-11-07 16:29:13 +00:00
|
|
|
|
|
|
|
struct LookupResult {
|
|
|
|
int context_index;
|
|
|
|
int slot_index;
|
|
|
|
VariableMode mode;
|
|
|
|
InitializationFlag init_flag;
|
|
|
|
MaybeAssignedFlag maybe_assigned_flag;
|
|
|
|
};
|
|
|
|
|
2015-09-01 09:25:19 +00:00
|
|
|
inline int used() const;
|
|
|
|
inline void set_used(int used);
|
2014-11-07 16:29:13 +00:00
|
|
|
|
2015-09-01 09:25:19 +00:00
|
|
|
static inline Handle<Context> GetContext(Handle<ScriptContextTable> table,
|
|
|
|
int i);
|
2014-11-07 16:29:13 +00:00
|
|
|
|
2014-11-12 11:34:09 +00:00
|
|
|
// Lookup a variable `name` in a ScriptContextTable.
|
2014-11-07 16:29:13 +00:00
|
|
|
// If it returns true, the variable is found and `result` contains
|
|
|
|
// valid information about its location.
|
|
|
|
// If it returns false, `result` is untouched.
|
|
|
|
MUST_USE_RESULT
|
2014-11-12 11:34:09 +00:00
|
|
|
static bool Lookup(Handle<ScriptContextTable> table, Handle<String> name,
|
2014-11-07 16:29:13 +00:00
|
|
|
LookupResult* result);
|
|
|
|
|
|
|
|
MUST_USE_RESULT
|
2014-11-12 11:34:09 +00:00
|
|
|
static Handle<ScriptContextTable> Extend(Handle<ScriptContextTable> table,
|
|
|
|
Handle<Context> script_context);
|
2014-11-07 16:29:13 +00:00
|
|
|
|
2014-11-11 11:16:30 +00:00
|
|
|
static int GetContextOffset(int context_index) {
|
|
|
|
return kFirstContextOffset + context_index * kPointerSize;
|
|
|
|
}
|
|
|
|
|
2014-11-07 16:29:13 +00:00
|
|
|
private:
|
|
|
|
static const int kUsedSlot = 0;
|
2015-09-01 07:06:49 +00:00
|
|
|
static const int kFirstContextSlot = kUsedSlot + 1;
|
2014-11-11 11:16:30 +00:00
|
|
|
static const int kFirstContextOffset =
|
2015-09-01 07:06:49 +00:00
|
|
|
FixedArray::kHeaderSize + kFirstContextSlot * kPointerSize;
|
2014-11-07 16:29:13 +00:00
|
|
|
|
2014-11-12 11:34:09 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(ScriptContextTable);
|
2014-11-07 16:29:13 +00:00
|
|
|
};
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// JSFunctions are pairs (context, function code), sometimes also called
|
|
|
|
// closures. A Context object is used to represent function contexts and
|
|
|
|
// dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak).
|
|
|
|
//
|
|
|
|
// At runtime, the contexts build a stack in parallel to the execution
|
|
|
|
// stack, with the top-most context being the current context. All contexts
|
|
|
|
// have the following slots:
|
|
|
|
//
|
|
|
|
// [ closure ] This is the current function. It is the same for all
|
|
|
|
// contexts inside a function. It provides access to the
|
|
|
|
// incoming context (i.e., the outer context, which may
|
|
|
|
// or may not become the current function's context), and
|
|
|
|
// it provides access to the functions code and thus it's
|
|
|
|
// scope information, which in turn contains the names of
|
|
|
|
// statically allocated context slots. The names are needed
|
|
|
|
// for dynamic lookups in the presence of 'with' or 'eval'.
|
|
|
|
//
|
2016-07-29 09:22:47 +00:00
|
|
|
// [ previous ] A pointer to the previous context.
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2016-09-02 12:42:26 +00:00
|
|
|
// [ extension ] Additional data.
|
|
|
|
//
|
|
|
|
// For script contexts, it contains the respective ScopeInfo.
|
|
|
|
//
|
|
|
|
// For catch contexts, it contains a ContextExtension object
|
|
|
|
// consisting of the ScopeInfo and the name of the catch
|
|
|
|
// variable.
|
|
|
|
//
|
|
|
|
// For module contexts, it contains the module object.
|
|
|
|
//
|
|
|
|
// For block contexts, it contains either the respective
|
|
|
|
// ScopeInfo or a ContextExtension object consisting of the
|
|
|
|
// ScopeInfo and an "extension object" (see below).
|
|
|
|
//
|
|
|
|
// For with contexts, it contains a ContextExtension object
|
|
|
|
// consisting of the ScopeInfo and an "extension object".
|
|
|
|
//
|
|
|
|
// An "extension object" is used to dynamically extend a context
|
|
|
|
// with additional variables, namely in the implementation of the
|
|
|
|
// 'with' construct and the 'eval' construct. For instance,
|
|
|
|
// Context::Lookup also searches the extension object for
|
|
|
|
// properties. (Storing the extension object is the original
|
|
|
|
// purpose of this context slot, hence the name.)
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2016-07-29 09:22:47 +00:00
|
|
|
// [ native_context ] A pointer to the native context.
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
|
|
|
// In addition, function contexts may have statically allocated context slots
|
|
|
|
// to store local variables/functions that are accessed from inner functions
|
|
|
|
// (via static context addresses) or through 'eval' (dynamic context lookups).
|
2014-02-27 13:25:05 +00:00
|
|
|
// The native context contains additional slots for fast access to native
|
|
|
|
// properties.
|
|
|
|
//
|
|
|
|
// Finally, with Harmony scoping, the JSFunction representing a top level
|
2014-11-12 11:34:09 +00:00
|
|
|
// script will have the ScriptContext rather than a FunctionContext.
|
|
|
|
// Script contexts from all top-level scripts are gathered in
|
|
|
|
// ScriptContextTable.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
class Context: public FixedArray {
|
|
|
|
public:
|
|
|
|
// Conversions.
|
2015-09-01 09:25:19 +00:00
|
|
|
static inline Context* cast(Object* context);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// The default context slot layout; indices are FixedArray slot indices.
|
2016-10-18 02:42:42 +00:00
|
|
|
enum Field {
|
2008-07-03 15:10:15 +00:00
|
|
|
// These slots are in all contexts.
|
|
|
|
CLOSURE_INDEX,
|
|
|
|
PREVIOUS_INDEX,
|
2015-11-27 16:59:28 +00:00
|
|
|
// The extension slot is used for either the global object (in native
|
2011-06-16 06:37:49 +00:00
|
|
|
// contexts), eval extension object (function contexts), subject of with
|
2011-10-21 10:26:59 +00:00
|
|
|
// (with contexts), or the variable name (catch contexts), the serialized
|
2012-07-09 08:59:03 +00:00
|
|
|
// scope info (block contexts), or the module instance (module contexts).
|
2008-07-03 15:10:15 +00:00
|
|
|
EXTENSION_INDEX,
|
2015-11-27 16:59:28 +00:00
|
|
|
NATIVE_CONTEXT_INDEX,
|
2011-06-16 06:37:49 +00:00
|
|
|
|
2012-08-17 09:03:08 +00:00
|
|
|
// These slots are only in native contexts.
|
2015-08-14 15:12:34 +00:00
|
|
|
#define NATIVE_CONTEXT_SLOT(index, type, name) index,
|
|
|
|
NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_SLOT)
|
|
|
|
#undef NATIVE_CONTEXT_SLOT
|
2010-10-18 14:59:03 +00:00
|
|
|
|
|
|
|
// Properties from here are treated as weak references by the full GC.
|
|
|
|
// Scavenge treats them as strong references.
|
2017-09-04 16:56:30 +00:00
|
|
|
OPTIMIZED_CODE_LIST, // Weak.
|
|
|
|
DEOPTIMIZED_CODE_LIST, // Weak.
|
|
|
|
NEXT_CONTEXT_LINK, // Weak.
|
2010-10-18 14:59:03 +00:00
|
|
|
|
|
|
|
// Total number of slots.
|
2012-08-17 09:03:08 +00:00
|
|
|
NATIVE_CONTEXT_SLOTS,
|
2017-09-04 16:56:30 +00:00
|
|
|
FIRST_WEAK_SLOT = OPTIMIZED_CODE_LIST,
|
2017-06-30 11:26:14 +00:00
|
|
|
FIRST_JS_ARRAY_MAP_SLOT = JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX,
|
2015-08-14 15:12:34 +00:00
|
|
|
|
|
|
|
MIN_CONTEXT_SLOTS = GLOBAL_PROXY_INDEX,
|
|
|
|
// This slot holds the thrown value in catch contexts.
|
|
|
|
THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS,
|
2016-03-31 05:58:42 +00:00
|
|
|
|
|
|
|
// These slots hold values in debug evaluate contexts.
|
|
|
|
WRAPPED_CONTEXT_INDEX = MIN_CONTEXT_SLOTS,
|
|
|
|
WHITE_LIST_INDEX = MIN_CONTEXT_SLOTS + 1
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2017-06-12 15:47:14 +00:00
|
|
|
// A region of native context entries containing maps for functions created
|
|
|
|
// by Builtins::kFastNewClosure.
|
|
|
|
static const int FIRST_FUNCTION_MAP_INDEX = SLOPPY_FUNCTION_MAP_INDEX;
|
|
|
|
static const int LAST_FUNCTION_MAP_INDEX = CLASS_FUNCTION_MAP_INDEX;
|
|
|
|
|
2017-11-29 11:04:27 +00:00
|
|
|
static const int kNoContext = 0;
|
|
|
|
static const int kInvalidContext = 1;
|
|
|
|
|
2016-12-08 12:44:29 +00:00
|
|
|
void ResetErrorsThrown();
|
2015-11-06 08:07:52 +00:00
|
|
|
void IncrementErrorsThrown();
|
|
|
|
int GetErrorsThrown();
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Direct slot access.
|
2015-09-01 09:25:19 +00:00
|
|
|
inline JSFunction* closure();
|
|
|
|
inline void set_closure(JSFunction* closure);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-09-01 09:25:19 +00:00
|
|
|
inline Context* previous();
|
|
|
|
inline void set_previous(Context* context);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-05-12 08:50:18 +00:00
|
|
|
inline Object* next_context_link();
|
|
|
|
|
2015-09-01 09:25:19 +00:00
|
|
|
inline bool has_extension();
|
2015-11-30 13:23:04 +00:00
|
|
|
inline HeapObject* extension();
|
|
|
|
inline void set_extension(HeapObject* 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
|
|
|
JSObject* extension_object();
|
|
|
|
JSReceiver* extension_receiver();
|
|
|
|
ScopeInfo* scope_info();
|
|
|
|
String* catch_name();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-09-12 12:54:47 +00:00
|
|
|
// Find the module context (assuming there is one) and return the associated
|
|
|
|
// module object.
|
2016-09-16 16:47:07 +00:00
|
|
|
Module* module();
|
2016-09-12 12:54:47 +00:00
|
|
|
|
2011-06-28 15:22:08 +00:00
|
|
|
// Get the context where var declarations will be hoisted to, which
|
|
|
|
// may be the context itself.
|
|
|
|
Context* declaration_context();
|
[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
|
|
|
bool is_declaration_context();
|
2011-06-28 15:22:08 +00:00
|
|
|
|
2016-02-01 07:03:09 +00:00
|
|
|
// Get the next closure's context on the context chain.
|
|
|
|
Context* closure_context();
|
|
|
|
|
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
|
|
|
// Returns a JSGlobalProxy object or null.
|
|
|
|
JSObject* global_proxy();
|
|
|
|
void set_global_proxy(JSObject* global);
|
|
|
|
|
2015-11-27 16:59:28 +00:00
|
|
|
// Get the JSGlobalObject object.
|
2016-09-26 07:40:24 +00:00
|
|
|
V8_EXPORT_PRIVATE JSGlobalObject* global_object();
|
2015-11-27 16:59:28 +00:00
|
|
|
|
2014-11-12 11:34:09 +00:00
|
|
|
// Get the script context by traversing the context chain.
|
|
|
|
Context* script_context();
|
Get rid of static module allocation, do it in code.
Modules now have their own local scope, represented by their own context.
Module instance objects have an accessor for every export that forwards
access to the respective slot from the module's context. (Exports that are
modules themselves, however, are simple data properties.)
All modules have a _hosting_ scope/context, which (currently) is the
(innermost) enclosing global scope. To deal with recursion, nested modules
are hosted by the same scope as global ones.
For every (global or nested) module literal, the hosting context has an
internal slot that points directly to the respective module context. This
enables quick access to (statically resolved) module members by 2-dimensional
access through the hosting context. For example,
module A {
let x;
module B { let y; }
}
module C { let z; }
allocates contexts as follows:
[header| .A | .B | .C | A | C ] (global)
| | |
| | +-- [header| z ] (module)
| |
| +------- [header| y ] (module)
|
+------------ [header| x | B ] (module)
Here, .A, .B, .C are the internal slots pointing to the hosted module
contexts, whereas A, B, C hold the actual instance objects (note that every
module context also points to the respective instance object through its
extension slot in the header).
To deal with arbitrary recursion and aliases between modules,
they are created and initialized in several stages. Each stage applies to
all modules in the hosting global scope, including nested ones.
1. Allocate: for each module _literal_, allocate the module contexts and
respective instance object and wire them up. This happens in the
PushModuleContext runtime function, as generated by AllocateModules
(invoked by VisitDeclarations in the hosting scope).
2. Bind: for each module _declaration_ (i.e. literals as well as aliases),
assign the respective instance object to respective local variables. This
happens in VisitModuleDeclaration, and uses the instance objects created
in the previous stage.
For each module _literal_, this phase also constructs a module descriptor
for the next stage. This happens in VisitModuleLiteral.
3. Populate: invoke the DeclareModules runtime function to populate each
_instance_ object with accessors for it exports. This is generated by
DeclareModules (invoked by VisitDeclarations in the hosting scope again),
and uses the descriptors generated in the previous stage.
4. Initialize: execute the module bodies (and other code) in sequence. This
happens by the separate statements generated for module bodies. To reenter
the module scopes properly, the parser inserted ModuleStatements.
R=mstarzinger@chromium.org,svenpanne@chromium.org
BUG=
Review URL: https://codereview.chromium.org/11093074
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13033 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-11-22 10:25:22 +00:00
|
|
|
|
2015-11-27 16:59:28 +00:00
|
|
|
// Compute the native context.
|
2017-07-19 13:39:05 +00:00
|
|
|
inline Context* native_context() const;
|
2015-11-27 16:59:28 +00:00
|
|
|
inline void set_native_context(Context* context);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-12-07 10:35:50 +00:00
|
|
|
// Predicates for context types. IsNativeContext is also defined on Object
|
2012-08-17 09:03:08 +00:00
|
|
|
// because we frequently have to know if arbitrary objects are natives
|
2011-06-09 11:26:01 +00:00
|
|
|
// contexts.
|
2017-07-19 13:39:05 +00:00
|
|
|
inline bool IsNativeContext() const;
|
|
|
|
inline bool IsFunctionContext() const;
|
|
|
|
inline bool IsCatchContext() const;
|
|
|
|
inline bool IsWithContext() const;
|
|
|
|
inline bool IsDebugEvaluateContext() const;
|
|
|
|
inline bool IsBlockContext() const;
|
|
|
|
inline bool IsModuleContext() const;
|
|
|
|
inline bool IsEvalContext() const;
|
|
|
|
inline bool IsScriptContext() const;
|
|
|
|
|
|
|
|
inline bool HasSameSecurityTokenAs(Context* that) const;
|
2014-05-19 13:45:45 +00:00
|
|
|
|
2013-09-04 13:53:24 +00:00
|
|
|
// The native context also stores a list of all optimized code and a
|
|
|
|
// list of all deoptimized code, which are needed by the deoptimizer.
|
|
|
|
void AddOptimizedCode(Code* code);
|
|
|
|
void SetOptimizedCodeListHead(Object* head);
|
|
|
|
Object* OptimizedCodeListHead();
|
|
|
|
void SetDeoptimizedCodeListHead(Object* head);
|
|
|
|
Object* DeoptimizedCodeListHead();
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2012-09-17 09:58:22 +00:00
|
|
|
Handle<Object> ErrorMessageForCodeGenerationFromStrings();
|
|
|
|
|
2015-08-26 11:16:38 +00:00
|
|
|
static int ImportedFieldIndexForName(Handle<String> name);
|
|
|
|
static int IntrinsicIndexForName(Handle<String> name);
|
2016-09-12 11:35:40 +00:00
|
|
|
static int IntrinsicIndexForName(const unsigned char* name, int length);
|
2015-08-26 11:16:38 +00:00
|
|
|
|
2012-08-17 09:03:08 +00:00
|
|
|
#define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \
|
2015-09-01 09:25:19 +00:00
|
|
|
inline void set_##name(type* value); \
|
2017-07-19 13:39:05 +00:00
|
|
|
inline bool is_##name(type* value) const; \
|
|
|
|
inline type* name() const;
|
2012-08-17 09:03:08 +00:00
|
|
|
NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSORS)
|
|
|
|
#undef NATIVE_CONTEXT_FIELD_ACCESSORS
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-04-16 13:20:50 +00:00
|
|
|
// Lookup the slot called name, starting with the current context.
|
2011-09-21 08:51:44 +00:00
|
|
|
// There are three possibilities:
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2011-09-21 08:51:44 +00:00
|
|
|
// 1) result->IsContext():
|
|
|
|
// The binding was found in a context. *index is always the
|
|
|
|
// non-negative slot index. *attributes is NONE for var and let
|
|
|
|
// declarations, READ_ONLY for const declarations (never ABSENT).
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2011-09-21 08:51:44 +00:00
|
|
|
// 2) result->IsJSObject():
|
|
|
|
// The binding was found as a named property in a context extension
|
|
|
|
// object (i.e., was introduced via eval), as a property on the subject
|
|
|
|
// of with, or as a property of the global object. *index is -1 and
|
|
|
|
// *attributes is not ABSENT.
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2017-06-14 14:18:16 +00:00
|
|
|
// 3) result->IsModule():
|
|
|
|
// The binding was found in module imports or exports.
|
|
|
|
// *attributes is never ABSENT. imports are READ_ONLY.
|
|
|
|
//
|
|
|
|
// 4) result.is_null():
|
2011-09-21 08:51:44 +00:00
|
|
|
// There was no binding found, *index is always -1 and *attributes is
|
|
|
|
// always ABSENT.
|
2016-08-02 20:21:55 +00:00
|
|
|
Handle<Object> Lookup(Handle<String> name, ContextLookupFlags flags,
|
|
|
|
int* index, PropertyAttributes* attributes,
|
2016-08-02 20:36:40 +00:00
|
|
|
InitializationFlag* init_flag,
|
2017-08-04 20:52:16 +00:00
|
|
|
VariableMode* variable_mode,
|
|
|
|
bool* is_sloppy_function_name = nullptr);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Code generation support.
|
|
|
|
static int SlotOffset(int index) {
|
|
|
|
return kHeaderSize + index * kPointerSize - kHeapObjectTag;
|
|
|
|
}
|
2008-10-24 10:59:40 +00:00
|
|
|
|
2017-07-13 09:33:22 +00:00
|
|
|
static inline int FunctionMapIndex(LanguageMode language_mode,
|
2017-10-12 15:37:46 +00:00
|
|
|
FunctionKind kind, bool has_prototype_slot,
|
|
|
|
bool has_shared_name,
|
2017-07-13 09:33:22 +00:00
|
|
|
bool needs_home_object);
|
2013-04-11 16:28:19 +00:00
|
|
|
|
2016-03-01 16:05:38 +00:00
|
|
|
static int ArrayMapIndex(ElementsKind elements_kind) {
|
2015-12-11 06:50:46 +00:00
|
|
|
DCHECK(IsFastElementsKind(elements_kind));
|
2016-03-01 16:05:38 +00:00
|
|
|
return elements_kind + FIRST_JS_ARRAY_MAP_SLOT;
|
2015-12-11 06:50:46 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 13:39:05 +00:00
|
|
|
inline Map* GetInitialJSArrayMap(ElementsKind kind) const;
|
|
|
|
|
2012-08-17 09:03:08 +00:00
|
|
|
static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize;
|
2015-08-26 11:16:38 +00:00
|
|
|
static const int kNotFound = -1;
|
2010-10-18 14:59:03 +00:00
|
|
|
|
|
|
|
// GC support.
|
2017-06-22 13:47:44 +00:00
|
|
|
typedef FixedBodyDescriptor<kHeaderSize, kSize, kSize> BodyDescriptor;
|
2010-10-18 14:59:03 +00:00
|
|
|
|
|
|
|
typedef FixedBodyDescriptor<
|
2017-06-22 13:47:44 +00:00
|
|
|
kHeaderSize, kHeaderSize + FIRST_WEAK_SLOT * kPointerSize, kSize>
|
|
|
|
BodyDescriptorWeak;
|
2010-10-18 14:59:03 +00:00
|
|
|
|
2008-10-24 10:59:40 +00:00
|
|
|
private:
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Bootstrapping-aware type checks.
|
2016-09-26 07:40:24 +00:00
|
|
|
V8_EXPORT_PRIVATE static bool IsBootstrappingOrNativeContext(Isolate* isolate,
|
|
|
|
Object* object);
|
2012-07-09 08:59:03 +00:00
|
|
|
static bool IsBootstrappingOrValidParentContext(Object* object, Context* kid);
|
2008-10-24 10:59:40 +00:00
|
|
|
#endif
|
2012-11-13 12:27:03 +00:00
|
|
|
|
2014-05-27 13:43:29 +00:00
|
|
|
STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize);
|
|
|
|
STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2016-10-18 02:42:42 +00:00
|
|
|
typedef Context::Field ContextField;
|
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#endif // V8_CONTEXTS_H_
|