Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: src/code-stub-assembler.cc

Issue 2504553003: [es6] Perform the IsConstructor test in GetSuperConstructor. (Closed)
Patch Set: Fix assembler and add unittest Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index c93af865c3418a16a36f2b24ee5f8d55fb7114ae..c12a1e1a3252322e6dcdb84b7624055976894d23 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -2880,6 +2880,13 @@ Node* CodeStubAssembler::IsCallableMap(Node* map) {
Int32Constant(0));
}
+Node* CodeStubAssembler::IsConstructorMap(Node* map) {
+ CSA_ASSERT(this, IsMap(map));
+ return Word32NotEqual(
+ Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsConstructor)),
+ Int32Constant(0));
+}
+
Node* CodeStubAssembler::IsSpecialReceiverInstanceType(Node* instance_type) {
STATIC_ASSERT(JS_GLOBAL_OBJECT_TYPE <= LAST_SPECIAL_RECEIVER_TYPE);
return Int32LessThanOrEqual(instance_type,
@@ -2960,6 +2967,10 @@ Node* CodeStubAssembler::IsUnseededNumberDictionary(Node* object) {
LoadRoot(Heap::kUnseededNumberDictionaryMapRootIndex));
}
+Node* CodeStubAssembler::IsJSFunction(Node* object) {
+ return HasInstanceType(object, JS_FUNCTION_TYPE);
+}
+
Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) {
CSA_ASSERT(this, IsString(string));
// Translate the {index} into a Word.
@@ -7818,6 +7829,33 @@ Node* CodeStubAssembler::Typeof(Node* value, Node* context) {
return result_var.value();
}
+Node* CodeStubAssembler::GetSuperConstructor(Node* active_function,
+ Node* context) {
+ CSA_ASSERT(this, IsJSFunction(active_function));
+
+ Label is_not_constructor(this, Label::kDeferred), out(this);
+ Variable result(this, MachineRepresentation::kTagged);
+
+ Node* map = LoadMap(active_function);
+ Node* prototype = LoadMapPrototype(map);
+ Node* prototype_map = LoadMap(prototype);
+ GotoUnless(IsConstructorMap(prototype_map), &is_not_constructor);
+
+ result.Bind(prototype);
+ Goto(&out);
+
+ Bind(&is_not_constructor);
+ {
+ CallRuntime(Runtime::kThrowNotSuperConstructor, context, prototype,
+ active_function);
+ result.Bind(UndefinedConstant()); // Never reached.
Benedikt Meurer 2016/12/12 18:18:19 Nit: you could just bind the result of the runtime
+ Goto(&out);
+ }
+
+ Bind(&out);
+ return result.value();
+}
+
Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable,
Node* context) {
Label return_runtime(this, Label::kDeferred), end(this);

Powered by Google App Engine
This is Rietveld 408576698