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

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 639123009: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 2397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 break; 2408 break;
2409 default: 2409 default:
2410 UNREACHABLE(); 2410 UNREACHABLE();
2411 } 2411 }
2412 2412
2413 __ bind(&done); 2413 __ bind(&done);
2414 context()->Plug(eax); 2414 context()->Plug(eax);
2415 } 2415 }
2416 2416
2417 2417
2418 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
2419 // ctor is in eax.
2420 DCHECK(lit != NULL);
2421 __ push(eax);
2422
2423 Register scratch = ebx;
2424 __ mov(scratch, FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset));
Dmitry Lomov (no reviews) 2014/10/18 08:30:33 Loading prototype is an operation that requires ac
2425 __ push(scratch);
2426
2427 AccessorTable accessor_table(zone());
2428 for (int i = 0; i < lit->properties()->length(); i++) {
2429 ObjectLiteral::Property* property = lit->properties()->at(i);
2430 Literal* key = property->key()->AsLiteral();
2431 Expression* value = property->value();
2432 DCHECK(key != NULL);
2433
2434 switch (property->kind()) {
2435 case ObjectLiteral::Property::CONSTANT:
2436 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2437 case ObjectLiteral::Property::COMPUTED:
2438 if (property->is_static()) {
2439 __ push(Operand(esp, kPointerSize)); // constructor
2440 } else {
2441 __ push(Operand(esp, 0)); // prototype
2442 }
2443 VisitForStackValue(key);
2444 VisitForStackValue(value);
2445 __ push(Immediate(Smi::FromInt(SLOPPY))); // Strict mode
2446 __ CallRuntime(Runtime::kSetProperty, 4);
Dmitry Lomov (no reviews) 2014/10/18 08:30:33 You should use StoreIC here (see EmitKeyedProperty
Dmitry Lomov (no reviews) 2014/10/18 09:04:59 s/Keyed/Named/ of course. Maybe given how much run
arv (Not doing code reviews) 2014/10/20 20:22:31 I'm not sure that is correct? We are not doing ass
2447 break;
2448
2449 case ObjectLiteral::Property::GETTER: {
2450 ObjectLiteral::Accessors *accessors =
2451 accessor_table.lookup(key)->second;
2452 accessors->getter = value;
2453 if (property->is_static()) {
2454 __ push(Operand(esp, kPointerSize)); // constructor
2455 } else {
2456 __ push(Operand(esp, 0)); // prototype
2457 }
2458 VisitForStackValue(key);
2459 EmitAccessor(accessors->getter);
2460 EmitAccessor(accessors->setter);
2461 __ push(Immediate(Smi::FromInt(NONE)));
2462 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
2463 break;
2464 }
2465
2466 case ObjectLiteral::Property::SETTER: {
2467 ObjectLiteral::Accessors *accessors =
2468 accessor_table.lookup(key)->second;
2469 accessors->setter = value;
2470 if (property->is_static()) {
2471 __ push(Operand(esp, kPointerSize)); // constructor
2472 } else {
2473 __ push(Operand(esp, 0)); // prototype
2474 }
2475 VisitForStackValue(key);
2476 EmitAccessor(accessors->getter);
2477 EmitAccessor(accessors->setter);
2478 __ push(Immediate(Smi::FromInt(NONE)));
2479 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
2480 break;
2481 }
2482
2483 case ObjectLiteral::Property::PROTOTYPE:
2484 // TODO(arv): Implement
2485
2486 default:
2487 UNREACHABLE();
2488 }
2489 }
2490
2491 // prototype
2492 __ CallRuntime(Runtime::kToFastProperties, 1);
2493
2494 // constructor
2495 __ CallRuntime(Runtime::kToFastProperties, 1);
2496
2497 context()->Plug(eax);
2498 }
2499
2500
2501
2418 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, 2502 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr,
2419 Token::Value op, 2503 Token::Value op,
2420 OverwriteMode mode) { 2504 OverwriteMode mode) {
2421 __ pop(edx); 2505 __ pop(edx);
2422 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); 2506 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code();
2423 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. 2507 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
2424 CallIC(code, expr->BinaryOperationFeedbackId()); 2508 CallIC(code, expr->BinaryOperationFeedbackId());
2425 patch_site.EmitPatchInfo(); 2509 patch_site.EmitPatchInfo();
2426 context()->Plug(eax); 2510 context()->Plug(eax);
2427 } 2511 }
(...skipping 2715 matching lines...) Expand 10 before | Expand all | Expand 10 after
5143 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5227 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5144 Assembler::target_address_at(call_target_address, 5228 Assembler::target_address_at(call_target_address,
5145 unoptimized_code)); 5229 unoptimized_code));
5146 return OSR_AFTER_STACK_CHECK; 5230 return OSR_AFTER_STACK_CHECK;
5147 } 5231 }
5148 5232
5149 5233
5150 } } // namespace v8::internal 5234 } } // namespace v8::internal
5151 5235
5152 #endif // V8_TARGET_ARCH_IA32 5236 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/full-codegen.cc ('K') | « src/full-codegen.cc ('k') | test/mjsunit/harmony/classes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698