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

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

Issue 680993003: Classes: Add basic support for properties (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
Index: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index c033fd5a3e28d06d08b4dff5c9d38d2ad76b521e..3d7ba4d7806febeeafe0e365dd2bf863df6f8d15 100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -2421,6 +2421,67 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
}
+void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
+ // ctor is in eax.
+ DCHECK(lit != NULL);
+ __ push(eax);
+
+ Register scratch = ebx;
+ __ mov(scratch, FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset));
Dmitry Lomov (no reviews) 2014/10/27 21:37:13 Access check comment.
arv (Not doing code reviews) 2014/10/28 09:42:00 Done.
Dmitry Lomov (no reviews) 2014/10/28 10:34:08 Acknowledged.
+ __ 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(esp, kPointerSize)); // constructor
+ } else {
+ __ push(Operand(esp, 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(Immediate(Smi::FromInt(NONE)));
+ __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
+ break;
+
+ case ObjectLiteral::Property::GETTER:
+ VisitForStackValue(value);
+ __ push(Immediate(isolate()->factory()->null_value()));
+ __ push(Immediate(Smi::FromInt(NONE)));
+ __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
+ break;
+
+ case ObjectLiteral::Property::SETTER:
+ __ push(Immediate(isolate()->factory()->null_value()));
+ VisitForStackValue(value);
+ __ push(Immediate(Smi::FromInt(NONE)));
+ __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
+ break;
+
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ // prototype
+ __ CallRuntime(Runtime::kToFastProperties, 1);
+
+ // constructor
+ __ CallRuntime(Runtime::kToFastProperties, 1);
+
+ context()->Plug(eax);
Dmitry Lomov (no reviews) 2014/10/27 21:37:14 Caller plugs context; no need to do it here
arv (Not doing code reviews) 2014/10/28 09:42:00 Done.
Dmitry Lomov (no reviews) 2014/10/28 10:34:08 Acknowledged.
+}
+
+
void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr,
Token::Value op,
OverwriteMode mode) {

Powered by Google App Engine
This is Rietveld 408576698