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

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

Issue 680993003: Classes: Add basic support for properties (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: git rebase Created 6 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
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | test/mjsunit/harmony/classes.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index ba7ef08966cee61afa1dd8c29e7dae2926814be5..fe06fc7dfcf99f99725befe7a18d0d5d2202e014 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -2420,6 +2420,67 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
}
+void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
+ // Constructor is in rax.
+ DCHECK(lit != NULL);
+ __ Push(rax);
+
+ // No access check is needed here since the constructor is created by the
+ // class literal.
+ Register scratch = rbx;
+ __ movp(scratch, FieldOperand(rax, JSFunction::kPrototypeOrInitialMapOffset));
+ __ Push(scratch);
+
+ for (int i = 0; i < lit->properties()->length(); i++) {
+ ObjectLiteral::Property* property = lit->properties()->at(i);
+ Literal* key = property->key()->AsLiteral();
+ Expression* value = property->value();
+ DCHECK(key != NULL);
+
+ if (property->is_static()) {
+ __ Push(Operand(rsp, kPointerSize)); // constructor
+ } else {
+ __ Push(Operand(rsp, 0)); // prototype
+ }
+ VisitForStackValue(key);
+
+ switch (property->kind()) {
+ case ObjectLiteral::Property::CONSTANT:
+ case ObjectLiteral::Property::MATERIALIZED_LITERAL:
+ case ObjectLiteral::Property::COMPUTED:
+ case ObjectLiteral::Property::PROTOTYPE:
+ VisitForStackValue(value);
+ __ Push(Smi::FromInt(NONE));
+ __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
+ break;
+
+ case ObjectLiteral::Property::GETTER:
+ VisitForStackValue(value);
+ __ Push(isolate()->factory()->null_value());
+ __ Push(Smi::FromInt(NONE));
+ __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
+ break;
+
+ case ObjectLiteral::Property::SETTER:
+ __ Push(isolate()->factory()->null_value());
+ VisitForStackValue(value);
+ __ Push(Smi::FromInt(NONE));
+ __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
+ break;
+
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ // prototype
+ __ CallRuntime(Runtime::kToFastProperties, 1);
+
+ // constructor
+ __ CallRuntime(Runtime::kToFastProperties, 1);
+}
+
+
void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr,
Token::Value op,
OverwriteMode mode) {
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | test/mjsunit/harmony/classes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698