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

Side by Side 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, 1 month 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
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | test/mjsunit/harmony/classes.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_X64 7 #if V8_TARGET_ARCH_X64
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 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 default: 2413 default:
2414 UNREACHABLE(); 2414 UNREACHABLE();
2415 break; 2415 break;
2416 } 2416 }
2417 2417
2418 __ bind(&done); 2418 __ bind(&done);
2419 context()->Plug(rax); 2419 context()->Plug(rax);
2420 } 2420 }
2421 2421
2422 2422
2423 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
2424 // Constructor is in rax.
2425 DCHECK(lit != NULL);
2426 __ Push(rax);
2427
2428 // No access check is needed here since the constructor is created by the
2429 // class literal.
2430 Register scratch = rbx;
2431 __ movp(scratch, FieldOperand(rax, JSFunction::kPrototypeOrInitialMapOffset));
2432 __ Push(scratch);
2433
2434 for (int i = 0; i < lit->properties()->length(); i++) {
2435 ObjectLiteral::Property* property = lit->properties()->at(i);
2436 Literal* key = property->key()->AsLiteral();
2437 Expression* value = property->value();
2438 DCHECK(key != NULL);
2439
2440 if (property->is_static()) {
2441 __ Push(Operand(rsp, kPointerSize)); // constructor
2442 } else {
2443 __ Push(Operand(rsp, 0)); // prototype
2444 }
2445 VisitForStackValue(key);
2446
2447 switch (property->kind()) {
2448 case ObjectLiteral::Property::CONSTANT:
2449 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2450 case ObjectLiteral::Property::COMPUTED:
2451 case ObjectLiteral::Property::PROTOTYPE:
2452 VisitForStackValue(value);
2453 __ Push(Smi::FromInt(NONE));
2454 __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
2455 break;
2456
2457 case ObjectLiteral::Property::GETTER:
2458 VisitForStackValue(value);
2459 __ Push(isolate()->factory()->null_value());
2460 __ Push(Smi::FromInt(NONE));
2461 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
2462 break;
2463
2464 case ObjectLiteral::Property::SETTER:
2465 __ Push(isolate()->factory()->null_value());
2466 VisitForStackValue(value);
2467 __ Push(Smi::FromInt(NONE));
2468 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
2469 break;
2470
2471 default:
2472 UNREACHABLE();
2473 }
2474 }
2475
2476 // prototype
2477 __ CallRuntime(Runtime::kToFastProperties, 1);
2478
2479 // constructor
2480 __ CallRuntime(Runtime::kToFastProperties, 1);
2481 }
2482
2483
2423 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, 2484 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr,
2424 Token::Value op, 2485 Token::Value op,
2425 OverwriteMode mode) { 2486 OverwriteMode mode) {
2426 __ Pop(rdx); 2487 __ Pop(rdx);
2427 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); 2488 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code();
2428 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. 2489 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
2429 CallIC(code, expr->BinaryOperationFeedbackId()); 2490 CallIC(code, expr->BinaryOperationFeedbackId());
2430 patch_site.EmitPatchInfo(); 2491 patch_site.EmitPatchInfo();
2431 context()->Plug(rax); 2492 context()->Plug(rax);
2432 } 2493 }
(...skipping 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after
5177 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5238 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5178 Assembler::target_address_at(call_target_address, 5239 Assembler::target_address_at(call_target_address,
5179 unoptimized_code)); 5240 unoptimized_code));
5180 return OSR_AFTER_STACK_CHECK; 5241 return OSR_AFTER_STACK_CHECK;
5181 } 5242 }
5182 5243
5183 5244
5184 } } // namespace v8::internal 5245 } } // namespace v8::internal
5185 5246
5186 #endif // V8_TARGET_ARCH_X64 5247 #endif // V8_TARGET_ARCH_X64
OLDNEW
« 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