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

Unified Diff: src/full-codegen/x64/full-codegen-x64.cc

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Created 4 years, 2 months 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/full-codegen/x64/full-codegen-x64.cc
diff --git a/src/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc
index 50a5af56d1ad4dfb765ad5b114e11fa4bb95de33..275523df3a5496f303a83257433213a766692259 100644
--- a/src/full-codegen/x64/full-codegen-x64.cc
+++ b/src/full-codegen/x64/full-codegen-x64.cc
@@ -1925,6 +1925,33 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
}
+void FullCodeGenerator::EmitClassDefineNameProperty(ClassLiteral* lit) {
+ DCHECK(!lit->constructor()->name().is_null());
+
+ // abort if 'name' is undefined
+ if (lit->constructor()->name()->length() == 0) return;
+
+ Label exit;
+
+ // if "name" is already defined, exit
+ PushOperand(Operand(rsp, 0)); // constructor
+ PushOperand(isolate()->factory()->name_string());
+ CallRuntimeWithOperands(Runtime::kObjectHasOwnProperty);
+ __ CompareRoot(result_register(), Heap::kTrueValueRootIndex);
+ __ j(equal, &exit, Label::kNear);
+
+ // define "name" property
+ PushOperand(Operand(rsp, 0)); // constructor
+ PushOperand(isolate()->factory()->name_string());
+ PushOperand(lit->constructor()->name());
+ PushOperand(Smi::FromInt(DONT_ENUM | READ_ONLY));
+ PushOperand(Smi::FromInt(0)); // NeedsSetFunctionName()
+ CallRuntimeWithOperands(Runtime::kDefineDataPropertyInLiteral);
+
+ __ bind(&exit);
+}
+
+
void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) {
PopOperand(rdx);
Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code();

Powered by Google App Engine
This is Rietveld 408576698