Skip to content

Commit

Permalink
Revert of [es6] Correct Function.prototype.apply, Reflect.construct a…
Browse files Browse the repository at this point in the history
…nd Reflect.apply. (patchset v8#5 id:80001 of https://codereview.chromium.org/1523753002/ )

Reason for revert:
Breaks TSAN somewhow: http://build.chromium.org/p/client.v8/builders/V8%20Linux64%20TSAN/builds/7000

Original issue's description:
> [es6] Correct Function.prototype.apply, Reflect.construct and Reflect.apply.
>
> Introduce a new Apply builtin that forms a correct and optimizable
> foundation for the Function.prototype.apply, Reflect.construct and
> Reflect.apply builtins (which properly does the PrepareForTailCall
> as required by the ES2015 spec).
>
> The new Apply builtin avoids going to the runtime if it is safe to
> just access the backing store elements of the argArray, i.e. if you
> pass a JSArray with no holes, or an unmapped, unmodified sloppy or
> strict arguments object.
>
> mips/mips64 ports by Balazs Kilvady <balazs.kilvady@imgtec.com>
>
> CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_chromium_rel_ng;tryserver.blink:linux_blink_rel
> BUG=v8:4413, v8:4430
> LOG=n
> R=yangguo@chromium.org
>
> Committed: https://chromium.googlesource.com/v8/v8/+/e4d2538911f6cb4b626830ccbb3c1f5746542697

TBR=yangguo@chromium.org,paul.lind@imgtec.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:4413, v8:4430

Review URL: https://codereview.chromium.org/1533803002 .

Cr-Commit-Position: refs/heads/master@{#32928}
  • Loading branch information
bmeurer committed Dec 17, 2015
1 parent e4d2538 commit 567c24d
Show file tree
Hide file tree
Showing 21 changed files with 1,264 additions and 1,979 deletions.
433 changes: 150 additions & 283 deletions src/arm/builtins-arm.cc

Large diffs are not rendered by default.

468 changes: 171 additions & 297 deletions src/arm64/builtins-arm64.cc

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions src/bootstrapper.cc
Expand Up @@ -1865,17 +1865,23 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<JSFunction> apply = InstallFunction(
container, "reflect_apply", JS_OBJECT_TYPE, JSObject::kHeaderSize,
MaybeHandle<JSObject>(), Builtins::kReflectApply);
apply->shared()->DontAdaptArguments();
apply->shared()->set_internal_formal_parameter_count(3);
apply->shared()->set_length(3);
Handle<TypeFeedbackVector> feedback_vector =
TypeFeedbackVector::CreatePushAppliedArgumentsVector(isolate);
apply->shared()->set_feedback_vector(*feedback_vector);
native_context->set_reflect_apply(*apply);
}

{
Handle<JSFunction> construct = InstallFunction(
container, "reflect_construct", JS_OBJECT_TYPE, JSObject::kHeaderSize,
MaybeHandle<JSObject>(), Builtins::kReflectConstruct);
construct->shared()->DontAdaptArguments();
construct->shared()->set_internal_formal_parameter_count(3);
construct->shared()->set_length(2);
Handle<TypeFeedbackVector> feedback_vector =
TypeFeedbackVector::CreatePushAppliedArgumentsVector(isolate);
construct->shared()->set_feedback_vector(*feedback_vector);
native_context->set_reflect_construct(*construct);
}

Expand Down Expand Up @@ -2529,17 +2535,22 @@ bool Genesis::InstallNatives(ContextType context_type) {
Handle<JSFunction> apply =
InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize,
MaybeHandle<JSObject>(), Builtins::kFunctionApply);
Handle<TypeFeedbackVector> feedback_vector =
TypeFeedbackVector::CreatePushAppliedArgumentsVector(isolate());
apply->shared()->set_feedback_vector(*feedback_vector);

// Make sure that Function.prototype.call appears to be compiled.
// The code will never be called, but inline caching for call will
// only work if it appears to be compiled.
apply->shared()->DontAdaptArguments();
call->shared()->DontAdaptArguments();
DCHECK(call->is_compiled());

// Set the expected parameters for apply to 2; required by builtin.
apply->shared()->set_internal_formal_parameter_count(2);

// Set the lengths for the functions to satisfy ECMA-262.
apply->shared()->set_length(2);
call->shared()->set_length(1);
apply->shared()->set_length(2);
}

// Set up the Promise constructor.
Expand Down
4 changes: 0 additions & 4 deletions src/builtins.h
Expand Up @@ -116,8 +116,6 @@ inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) {
V(ConstructProxy, BUILTIN, UNINITIALIZED, kNoExtraICState) \
V(Construct, BUILTIN, UNINITIALIZED, kNoExtraICState) \
\
V(Apply, BUILTIN, UNINITIALIZED, kNoExtraICState) \
\
V(HandleFastApiCall, BUILTIN, UNINITIALIZED, kNoExtraICState) \
\
V(InOptimizationQueue, BUILTIN, UNINITIALIZED, kNoExtraICState) \
Expand Down Expand Up @@ -317,8 +315,6 @@ class Builtins {
static void Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm);
static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm);

static void Generate_Apply(MacroAssembler* masm);

// ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList)
static void Generate_CallFunction(MacroAssembler* masm,
ConvertReceiverMode mode);
Expand Down
11 changes: 8 additions & 3 deletions src/contexts.h
Expand Up @@ -91,9 +91,14 @@ enum BindingFlags {
V(SPREAD_ITERABLE_INDEX, JSFunction, spread_iterable)


#define NATIVE_CONTEXT_JS_BUILTINS(V) \
V(CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX, JSFunction, \
concat_iterable_to_array_builtin)
#define NATIVE_CONTEXT_JS_BUILTINS(V) \
V(APPLY_PREPARE_BUILTIN_INDEX, JSFunction, apply_prepare_builtin) \
V(CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX, JSFunction, \
concat_iterable_to_array_builtin) \
V(REFLECT_APPLY_PREPARE_BUILTIN_INDEX, JSFunction, \
reflect_apply_prepare_builtin) \
V(REFLECT_CONSTRUCT_PREPARE_BUILTIN_INDEX, JSFunction, \
reflect_construct_prepare_builtin)


#define NATIVE_CONTEXT_IMPORTED_FIELDS(V) \
Expand Down

0 comments on commit 567c24d

Please sign in to comment.