Commit 889d205b authored by bjaideep's avatar bjaideep Committed by Commit bot

PPC/s390: [es2015] Simplify contract between parser and stub for derived constructors.

Port 776d89f9

Original Commit Message:

    Rewrite returns in derived constructors to only replace undefined with
    this, and otherwise just return the value, and let the construct stub
    builtin throw an exception if the result is a primitive instead of a
    JSReceiver.

R=bmeurer@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=chromium:706642
LOG=N

Review-Url: https://codereview.chromium.org/2786413003
Cr-Commit-Position: refs/heads/master@{#44315}
parent 8ed72f91
......@@ -588,8 +588,12 @@ void Generate_JSConstructStubHelper(MacroAssembler* masm, bool is_api_function,
// Check that the result is not a Smi, indicating that the constructor result
// from a derived class is neither undefined nor an Object.
if (check_derived_construct) {
Label dont_throw;
__ JumpIfNotSmi(r3, &dont_throw);
Label do_throw, dont_throw;
__ JumpIfSmi(r3, &do_throw);
STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
__ CompareObjectType(r3, r6, r6, FIRST_JS_RECEIVER_TYPE);
__ bge(&dont_throw);
__ bind(&do_throw);
{
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
__ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject);
......
......@@ -585,8 +585,12 @@ void Generate_JSConstructStubHelper(MacroAssembler* masm, bool is_api_function,
// Check that the result is not a Smi, indicating that the constructor result
// from a derived class is neither undefined nor an Object.
if (check_derived_construct) {
Label dont_throw;
__ JumpIfNotSmi(r2, &dont_throw);
Label do_throw, dont_throw;
__ JumpIfSmi(r2, &do_throw);
STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
__ CompareObjectType(r2, r5, r5, FIRST_JS_RECEIVER_TYPE);
__ bge(&dont_throw);
__ bind(&do_throw);
{
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
__ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment