Bug 142882 - Extending null should set __proto__ to null
Summary: Extending null should set __proto__ to null
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords:
Depends on:
Blocks: 140491
  Show dependency treegraph
 
Reported: 2015-03-19 15:41 PDT by Ryosuke Niwa
Modified: 2015-03-30 19:00 PDT (History)
8 users (show)

See Also:


Attachments
Fixes the bug (8.56 KB, patch)
2015-03-27 23:00 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews105 for mac-mavericks-wk2 (571.55 KB, application/zip)
2015-03-27 23:36 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews100 for mac-mavericks (534.64 KB, application/zip)
2015-03-27 23:47 PDT, Build Bot
no flags Details
Fixes the bug (14.46 KB, patch)
2015-03-28 01:32 PDT, Ryosuke Niwa
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2015-03-19 15:41:00 PDT
new (class A extends null {}).__proto__ should evalute to null according to the spec.
Function.prototype.isPrototypeOf(A) should still be true.
Comment 1 Ryosuke Niwa 2015-03-20 14:30:00 PDT
@@ -2899,6 +2903,9 @@ RegisterID* ClassExprNode::emitBytecode(BytecodeGenerator& generator, RegisterID
     prototype = generator.emitGetById(generator.newTemporary(), constructor.get(), generator.propertyNames().prototype);
 
     if (superclass) {
+        RefPtr<RegisterID> protoParent = generator.newTemporary();
+        generator.emitLoad(protoParent.get(), jsNull());
+
         RefPtr<RegisterID> tempRegister = generator.newTemporary();
         RefPtr<Label> superclassIsNullLabel = generator.newLabel();
         generator.emitJumpIfTrue(generator.emitUnaryOp(op_eq_null, tempRegister.get(), superclass.get()), superclassIsNullLabel.get());
@@ -2908,8 +2915,6 @@ RegisterID* ClassExprNode::emitBytecode(BytecodeGenerator& generator, RegisterID
         generator.emitJumpIfTrue(generator.emitIsObject(tempRegister.get(), superclass.get()), superclassIsObjectLabel.get());
         generator.emitThrowTypeError(ASCIILiteral("The superclass is not an object."));
         generator.emitLabel(superclassIsObjectLabel.get());
-
-        RefPtr<RegisterID> protoParent = generator.newTemporary();
         generator.emitGetById(protoParent.get(), superclass.get(), generator.propertyNames().prototype);
 
         RefPtr<Label> protoParentIsObjectOrNullLabel = generator.newLabel();
@@ -2918,9 +2923,9 @@ RegisterID* ClassExprNode::emitBytecode(BytecodeGenerator& generator, RegisterID
         generator.emitLabel(protoParentIsObjectOrNullLabel.get());
 
         generator.emitDirectPutById(constructor.get(), generator.propertyNames().underscoreProto, superclass.get(), PropertyNode::Unknown);
+        generator.emitLabel(superclassIsNullLabel.get());
         generator.emitDirectPutById(prototype.get(), generator.propertyNames().underscoreProto, protoParent.get(), PropertyNode::Unknown);
 
-        generator.emitLabel(superclassIsNullLabel.get());
         emitPutHomeObject(generator, constructor.get(), prototype.get());
     }
Comment 2 Ryosuke Niwa 2015-03-27 23:00:28 PDT
Created attachment 249644 [details]
Fixes the bug
Comment 3 Build Bot 2015-03-27 23:36:24 PDT
Comment on attachment 249644 [details]
Fixes the bug

Attachment 249644 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5684121242173440

New failing tests:
js/class-syntax-super.html
js/class-syntax-call.html
Comment 4 Build Bot 2015-03-27 23:36:28 PDT
Created attachment 249645 [details]
Archive of layout-test-results from ews105 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 5 Build Bot 2015-03-27 23:47:49 PDT
Comment on attachment 249644 [details]
Fixes the bug

Attachment 249644 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5383994296238080

New failing tests:
js/class-syntax-super.html
js/class-syntax-call.html
Comment 6 Build Bot 2015-03-27 23:47:53 PDT
Created attachment 249647 [details]
Archive of layout-test-results from ews100 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 7 Ryosuke Niwa 2015-03-28 01:32:11 PDT
Created attachment 249656 [details]
Fixes the bug
Comment 8 Geoffrey Garen 2015-03-30 15:51:03 PDT
Comment on attachment 249656 [details]
Fixes the bug

r=me
Comment 9 Benjamin Poulain 2015-03-30 15:57:29 PDT
View in context: https://bugs.webkit.org/attachment.cgi?id=249656&action=review

> LayoutTests/js/script-tests/class-syntax-extends.js:72
> +shouldBe('Object.getPrototypeOf((class extends null { constructor () { super(); } }).prototype)', 'null');

You should also have coverage for extending undefined.

> LayoutTests/js/script-tests/class-syntax-extends.js:74
> +shouldThrow('new (class extends null { constructor () { super(); } })', '"TypeError: undefined is not an object (evaluating \'super()\')"');

+ add a test case where the constructor return a new, completely different, object.
Comment 10 Ryosuke Niwa 2015-03-30 19:00:15 PDT
Committed r182171: <http://trac.webkit.org/changeset/182171>