summaryrefslogtreecommitdiff
path: root/deps/v8/src/runtime/runtime-scopes.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2017-03-21 10:16:54 +0100
committerMichaël Zasso <targos@protonmail.com>2017-03-25 09:44:10 +0100
commitc459d8ea5d402c702948c860d9497b2230ff7e8a (patch)
tree56c282fc4d40e5cb613b47cf7be3ea0526ed5b6f /deps/v8/src/runtime/runtime-scopes.cc
parente0bc5a7361b1d29c3ed034155fd779ce6f44fb13 (diff)
downloadnode-new-c459d8ea5d402c702948c860d9497b2230ff7e8a.tar.gz
deps: update V8 to 5.7.492.69
PR-URL: https://github.com/nodejs/node/pull/11752 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Diffstat (limited to 'deps/v8/src/runtime/runtime-scopes.cc')
-rw-r--r--deps/v8/src/runtime/runtime-scopes.cc95
1 files changed, 59 insertions, 36 deletions
diff --git a/deps/v8/src/runtime/runtime-scopes.cc b/deps/v8/src/runtime/runtime-scopes.cc
index 377799fe04..6dae7dd609 100644
--- a/deps/v8/src/runtime/runtime-scopes.cc
+++ b/deps/v8/src/runtime/runtime-scopes.cc
@@ -88,8 +88,7 @@ Object* DeclareGlobal(
// function.
PropertyDetails old_details = it.property_details();
if (old_details.IsReadOnly() || old_details.IsDontEnum() ||
- (it.state() == LookupIterator::ACCESSOR &&
- it.GetAccessors()->IsAccessorPair())) {
+ (it.state() == LookupIterator::ACCESSOR)) {
// ECMA-262 section 15.1.11 GlobalDeclarationInstantiation 5.d:
// If hasRestrictedGlobal is true, throw a SyntaxError exception.
// ECMA-262 section 18.2.1.3 EvalDeclarationInstantiation 8.a.iv.1.b:
@@ -130,18 +129,18 @@ Object* DeclareGlobal(
return isolate->heap()->undefined_value();
}
-Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> pairs, int flags,
- Handle<TypeFeedbackVector> feedback_vector) {
+Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations,
+ int flags, Handle<TypeFeedbackVector> feedback_vector) {
HandleScope scope(isolate);
Handle<JSGlobalObject> global(isolate->global_object());
Handle<Context> context(isolate->context());
// Traverse the name/value pairs and set the properties.
- int length = pairs->length();
- FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < length, i += 2, {
- FeedbackVectorSlot slot(Smi::cast(pairs->get(i))->value());
- Handle<String> name(feedback_vector->GetName(slot), isolate);
- Handle<Object> initial_value(pairs->get(i + 1), isolate);
+ int length = declarations->length();
+ FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < length, i += 3, {
+ Handle<String> name(String::cast(declarations->get(i)), isolate);
+ FeedbackVectorSlot slot(Smi::cast(declarations->get(i + 1))->value());
+ Handle<Object> initial_value(declarations->get(i + 2), isolate);
bool is_var = initial_value->IsUndefined(isolate);
bool is_function = initial_value->IsSharedFunctionInfo();
@@ -186,11 +185,11 @@ RUNTIME_FUNCTION(Runtime_DeclareGlobals) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
- CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 0);
+ CONVERT_ARG_HANDLE_CHECKED(FixedArray, declarations, 0);
CONVERT_SMI_ARG_CHECKED(flags, 1);
CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, feedback_vector, 2);
- return DeclareGlobals(isolate, pairs, flags, feedback_vector);
+ return DeclareGlobals(isolate, declarations, flags, feedback_vector);
}
// TODO(ishell): merge this with Runtime::kDeclareGlobals once interpreter
@@ -199,13 +198,13 @@ RUNTIME_FUNCTION(Runtime_DeclareGlobalsForInterpreter) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
- CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 0);
+ CONVERT_ARG_HANDLE_CHECKED(FixedArray, declarations, 0);
CONVERT_SMI_ARG_CHECKED(flags, 1);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 2);
Handle<TypeFeedbackVector> feedback_vector(closure->feedback_vector(),
isolate);
- return DeclareGlobals(isolate, pairs, flags, feedback_vector);
+ return DeclareGlobals(isolate, declarations, flags, feedback_vector);
}
RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) {
@@ -224,15 +223,15 @@ namespace {
Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
Handle<Object> value) {
- // Declarations are always made in a function, native, or script context, or
- // a declaration block scope. Since this is called from eval, the context
- // passed is the context of the caller, which may be some nested context and
- // not the declaration context.
+ // Declarations are always made in a function, native, eval, or script
+ // context, or a declaration block scope. Since this is called from eval, the
+ // context passed is the context of the caller, which may be some nested
+ // context and not the declaration context.
Handle<Context> context_arg(isolate->context(), isolate);
Handle<Context> context(context_arg->declaration_context(), isolate);
DCHECK(context->IsFunctionContext() || context->IsNativeContext() ||
- context->IsScriptContext() ||
+ context->IsScriptContext() || context->IsEvalContext() ||
(context->IsBlockContext() && context->has_extension()));
bool is_function = value->IsJSFunction();
@@ -313,6 +312,8 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
}
DCHECK(object->IsJSContextExtensionObject() || object->IsJSGlobalObject());
} else {
+ // Sloppy eval will never have an extension object, as vars are hoisted out,
+ // and lets are known statically.
DCHECK(context->IsFunctionContext());
object =
isolate->factory()->NewJSObject(isolate->context_extension_function());
@@ -352,7 +353,7 @@ std::unique_ptr<Handle<Object>[]> GetCallerArguments(Isolate* isolate,
// Find frame containing arguments passed to the caller.
JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame();
- List<JSFunction*> functions(2);
+ List<SharedFunctionInfo*> functions(2);
frame->GetFunctions(&functions);
if (functions.length() > 1) {
int inlined_jsframe_index = functions.length() - 1;
@@ -377,6 +378,8 @@ std::unique_ptr<Handle<Object>[]> GetCallerArguments(Isolate* isolate,
NewArray<Handle<Object>>(*total_argc));
bool should_deoptimize = false;
for (int i = 0; i < argument_count; i++) {
+ // If we materialize any object, we should deoptimize the frame because we
+ // might alias an object that was eliminated by escape analysis.
should_deoptimize = should_deoptimize || iter->IsMaterializedObject();
Handle<Object> value = iter->GetValue();
param_data[i] = value;
@@ -384,7 +387,7 @@ std::unique_ptr<Handle<Object>[]> GetCallerArguments(Isolate* isolate,
}
if (should_deoptimize) {
- translated_values.StoreMaterializedValuesAndDeopt();
+ translated_values.StoreMaterializedValuesAndDeopt(frame);
}
return param_data;
@@ -407,7 +410,7 @@ std::unique_ptr<Handle<Object>[]> GetCallerArguments(Isolate* isolate,
template <typename T>
Handle<JSObject> NewSloppyArguments(Isolate* isolate, Handle<JSFunction> callee,
T parameters, int argument_count) {
- CHECK(!IsSubclassConstructor(callee->shared()->kind()));
+ CHECK(!IsDerivedConstructor(callee->shared()->kind()));
DCHECK(callee->shared()->has_simple_parameters());
Handle<JSObject> result =
isolate->factory()->NewArgumentsObject(callee, argument_count);
@@ -517,7 +520,7 @@ class ParameterArguments BASE_EMBEDDED {
RUNTIME_FUNCTION(Runtime_NewSloppyArguments_Generic) {
HandleScope scope(isolate);
- DCHECK(args.length() == 1);
+ DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0);
// This generic runtime function can also be used when the caller has been
// inlined, we use the slow but accurate {GetCallerArguments}.
@@ -582,7 +585,7 @@ RUNTIME_FUNCTION(Runtime_NewRestParameter) {
RUNTIME_FUNCTION(Runtime_NewSloppyArguments) {
HandleScope scope(isolate);
- DCHECK(args.length() == 3);
+ DCHECK_EQ(3, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0);
Object** parameters = reinterpret_cast<Object**>(args[1]);
CONVERT_SMI_ARG_CHECKED(argument_count, 2);
@@ -590,26 +593,45 @@ RUNTIME_FUNCTION(Runtime_NewSloppyArguments) {
return *NewSloppyArguments(isolate, callee, argument_getter, argument_count);
}
+RUNTIME_FUNCTION(Runtime_NewArgumentsElements) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ Object** frame = reinterpret_cast<Object**>(args[0]);
+ CONVERT_SMI_ARG_CHECKED(length, 1);
+ Handle<FixedArray> result =
+ isolate->factory()->NewUninitializedFixedArray(length);
+ int const offset = length + 1;
+ DisallowHeapAllocation no_gc;
+ WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
+ for (int index = 0; index < length; ++index) {
+ result->set(index, frame[offset - index], mode);
+ }
+ return *result;
+}
RUNTIME_FUNCTION(Runtime_NewClosure) {
HandleScope scope(isolate);
- DCHECK_EQ(1, args.length());
+ DCHECK_EQ(3, args.length());
CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0);
Handle<Context> context(isolate->context(), isolate);
- return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context,
- NOT_TENURED);
+ Handle<JSFunction> function =
+ isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context,
+ NOT_TENURED);
+ return *function;
}
RUNTIME_FUNCTION(Runtime_NewClosure_Tenured) {
HandleScope scope(isolate);
- DCHECK_EQ(1, args.length());
+ DCHECK_EQ(3, args.length());
CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0);
Handle<Context> context(isolate->context(), isolate);
// The caller ensures that we pretenure closures that are assigned
// directly to properties.
- return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context,
- TENURED);
+ Handle<JSFunction> function =
+ isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context,
+ TENURED);
+ return *function;
}
static Object* FindNameClash(Handle<ScopeInfo> scope_info,
@@ -654,7 +676,7 @@ static Object* FindNameClash(Handle<ScopeInfo> scope_info,
RUNTIME_FUNCTION(Runtime_NewScriptContext) {
HandleScope scope(isolate);
- DCHECK(args.length() == 2);
+ DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1);
@@ -670,8 +692,9 @@ RUNTIME_FUNCTION(Runtime_NewScriptContext) {
// Script contexts have a canonical empty function as their closure, not the
// anonymous closure containing the global code. See
// FullCodeGenerator::PushFunctionArgumentForContextAllocation.
- Handle<JSFunction> closure(
- function->shared()->IsBuiltin() ? *function : native_context->closure());
+ Handle<JSFunction> closure(function->shared()->IsUserJavaScript()
+ ? native_context->closure()
+ : *function);
Handle<Context> result =
isolate->factory()->NewScriptContext(closure, scope_info);
@@ -684,19 +707,19 @@ RUNTIME_FUNCTION(Runtime_NewScriptContext) {
return *result;
}
-
RUNTIME_FUNCTION(Runtime_NewFunctionContext) {
HandleScope scope(isolate);
- DCHECK(args.length() == 1);
+ DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
+ CONVERT_SMI_ARG_CHECKED(scope_type, 1);
DCHECK(function->context() == isolate->context());
int length = function->shared()->scope_info()->ContextLength();
- return *isolate->factory()->NewFunctionContext(length, function);
+ return *isolate->factory()->NewFunctionContext(
+ length, function, static_cast<ScopeType>(scope_type));
}
-
RUNTIME_FUNCTION(Runtime_PushWithContext) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());