// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
+
+ if (is_strong(language_mode())) {
+ __ ldr(scratch,
+ FieldMemOperand(r0, JSFunction::kPrototypeOrInitialMapOffset));
+ __ push(r0);
+ __ push(scratch);
+ // TODO(conradw): It would be more efficient to define the properties with
+ // the right attributes the first time round.
+ // Freeze the prototype.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ // Freeze the constructor.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ }
}
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
+
+ if (is_strong(language_mode())) {
+ __ Ldr(scratch,
+ FieldMemOperand(x0, JSFunction::kPrototypeOrInitialMapOffset));
+ __ push(x0);
+ __ Push(scratch);
+ // TODO(conradw): It would be more efficient to define the properties with
+ // the right attributes the first time round.
+ // Freeze the prototype.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ // Freeze the constructor.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ }
}
if (is_strong(language_mode())) {
// TODO(conradw): It would be more efficient to define the properties with
// the right attributes the first time round.
+ // Freeze the prototype.
+ proto =
+ NewNode(javascript()->CallRuntime(Runtime::kObjectFreeze, 1), proto);
+ // Freezing the prototype should never deopt.
+ PrepareFrameState(proto, BailoutId::None());
+ // Freeze the constructor.
literal =
NewNode(javascript()->CallRuntime(Runtime::kObjectFreeze, 1), literal);
- // Freezing the class object should never deopt.
+ // Freezing the constructor should never deopt.
PrepareFrameState(literal, BailoutId::None());
}
// Verify that compilation exactly consumed the number of store ic slots
// that the ClassLiteral node had to offer.
DCHECK(!FLAG_vector_stores || store_slot_index == lit->slot_count());
-
- if (is_strong(language_mode())) {
- // TODO(conradw): It would be more efficient to define the properties with
- // the right attributes the first time round.
- __ Push(result_register());
- __ CallRuntime(Runtime::kObjectFreeze, 1);
- }
}
context()->Plug(result_register());
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
+
+ if (is_strong(language_mode())) {
+ __ mov(scratch,
+ FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset));
+ __ push(eax);
+ __ Push(scratch);
+ // TODO(conradw): It would be more efficient to define the properties with
+ // the right attributes the first time round.
+ // Freeze the prototype.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ // Freeze the constructor.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ }
}
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
+
+ if (is_strong(language_mode())) {
+ __ lw(scratch,
+ FieldMemOperand(v0, JSFunction::kPrototypeOrInitialMapOffset));
+ __ Push(v0, scratch);
+ // TODO(conradw): It would be more efficient to define the properties with
+ // the right attributes the first time round.
+ // Freeze the prototype.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ // Freeze the constructor.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ }
}
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
+
+ if (is_strong(language_mode())) {
+ __ ld(scratch,
+ FieldMemOperand(v0, JSFunction::kPrototypeOrInitialMapOffset));
+ __ Push(v0, scratch);
+ // TODO(conradw): It would be more efficient to define the properties with
+ // the right attributes the first time round.
+ // Freeze the prototype.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ // Freeze the constructor.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ }
}
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
+
+ if (is_strong(language_mode())) {
+ __ LoadP(scratch,
+ FieldMemOperand(r3, JSFunction::kPrototypeOrInitialMapOffset));
+ __ Push(r3, scratch);
+ // TODO(conradw): It would be more efficient to define the properties with
+ // the right attributes the first time round.
+ // Freeze the prototype.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ // Freeze the constructor.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ }
}
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
+
+ if (is_strong(language_mode())) {
+ __ movp(scratch,
+ FieldOperand(rax, JSFunction::kPrototypeOrInitialMapOffset));
+ __ Push(rax);
+ __ Push(scratch);
+ // TODO(conradw): It would be more efficient to define the properties with
+ // the right attributes the first time round.
+ // Freeze the prototype.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ // Freeze the constructor.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ }
}
// constructor
__ CallRuntime(Runtime::kToFastProperties, 1);
+
+ if (is_strong(language_mode())) {
+ __ mov(scratch,
+ FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset));
+ __ push(eax);
+ __ push(scratch);
+ // TODO(conradw): It would be more efficient to define the properties with
+ // the right attributes the first time round.
+ // Freeze the prototype.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ // Freeze the constructor.
+ __ CallRuntime(Runtime::kObjectFreeze, 1);
+ }
}
function getClass() {
class Foo {
static get bar() { return 0 }
+ get bar() { return 0 }
}
return Foo;
}
function getClassExpr() {
- return (class { static get bar() { return 0 } });
+ return (class { static get bar() { return 0 } get bar() { return 0 } });
}
function getClassStrong() {
"use strong";
class Foo {
static get bar() { return 0 }
+ get bar() { return 0 }
}
return Foo;
}
function getClassExprStrong() {
"use strong";
- return (class { static get bar() { return 0 } });
+ return (class { static get bar() { return 0 } get bar() { return 0 } });
}
function addProperty(o) {
Object.defineProperty(o, "bar", { value: 1 });
}
-assertDoesNotThrow(function(){addProperty(getClass())});
-assertDoesNotThrow(function(){convertPropertyToData(getClass())});
-assertDoesNotThrow(function(){addProperty(getClassExpr())});
-assertDoesNotThrow(function(){convertPropertyToData(getClassExpr())});
+function testWeakClass(classFunc) {
+ assertDoesNotThrow(function(){addProperty(classFunc())});
+ assertDoesNotThrow(function(){addProperty(classFunc().prototype)});
+ assertDoesNotThrow(function(){convertPropertyToData(classFunc())});
+ assertDoesNotThrow(function(){convertPropertyToData(classFunc().prototype)});
+}
+
+function testStrongClass(classFunc) {
+ assertThrows(function(){addProperty(classFunc())}, TypeError);
+ assertThrows(function(){addProperty(classFunc().prototype)}, TypeError);
+ assertThrows(function(){convertPropertyToData(classFunc())}, TypeError);
+ assertThrows(function(){convertPropertyToData(classFunc().prototype)},
+ TypeError);
+}
+
+testWeakClass(getClass);
+testWeakClass(getClassExpr);
-assertThrows(function(){addProperty(getClassStrong())}, TypeError);
-assertThrows(function(){convertPropertyToData(getClassStrong())}, TypeError);
-assertThrows(function(){addProperty(getClassExprStrong())}, TypeError);
-assertThrows(function(){convertPropertyToData(getClassExprStrong())},
- TypeError);
+testStrongClass(getClassStrong);
+testStrongClass(getClassExprStrong);
// Check strong classes don't freeze their parents.
(function() {
- "use strong";
let parent = getClass();
- class Foo extends parent {
- static get bar() { return 0 }
+ let classFunc = function() {
+ "use strong";
+ class Foo extends parent {
+ static get bar() { return 0 }
+ get bar() { return 0 }
+ }
+ return Foo;
}
- assertThrows(function(){addProperty(Foo)}, TypeError);
- assertThrows(function(){convertPropertyToData(Foo)}, TypeError);
+ testStrongClass(classFunc);
assertDoesNotThrow(function(){addProperty(parent)});
assertDoesNotThrow(function(){convertPropertyToData(parent)});
})();
(function() {
let parent = getClassStrong();
- class Foo extends parent {
- static get bar() { return 0 }
+ let classFunc = function() {
+ class Foo extends parent {
+ static get bar() { return 0 }
+ get bar() { return 0 }
+ }
+ return Foo;
}
assertThrows(function(){addProperty(parent)}, TypeError);
assertThrows(function(){convertPropertyToData(parent)}, TypeError);
- assertDoesNotThrow(function(){addProperty(Foo)});
- assertDoesNotThrow(function(){convertPropertyToData(Foo)});
+ testWeakClass(classFunc);
})();