OLD | NEW |
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 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2451 default: | 2451 default: |
2452 UNREACHABLE(); | 2452 UNREACHABLE(); |
2453 break; | 2453 break; |
2454 } | 2454 } |
2455 | 2455 |
2456 __ bind(&done); | 2456 __ bind(&done); |
2457 context()->Plug(rax); | 2457 context()->Plug(rax); |
2458 } | 2458 } |
2459 | 2459 |
2460 | 2460 |
2461 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { | 2461 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit, |
| 2462 int* used_store_slots) { |
2462 // Constructor is in rax. | 2463 // Constructor is in rax. |
2463 DCHECK(lit != NULL); | 2464 DCHECK(lit != NULL); |
2464 __ Push(rax); | 2465 __ Push(rax); |
2465 | 2466 |
2466 // No access check is needed here since the constructor is created by the | 2467 // No access check is needed here since the constructor is created by the |
2467 // class literal. | 2468 // class literal. |
2468 Register scratch = rbx; | 2469 Register scratch = rbx; |
2469 __ movp(scratch, FieldOperand(rax, JSFunction::kPrototypeOrInitialMapOffset)); | 2470 __ movp(scratch, FieldOperand(rax, JSFunction::kPrototypeOrInitialMapOffset)); |
2470 __ Push(scratch); | 2471 __ Push(scratch); |
2471 | 2472 |
2472 // store_slot_index points to the vector IC slot for the next store IC used. | |
2473 // ClassLiteral::ComputeFeedbackRequirements controls the allocation of slots | |
2474 // and must be updated if the number of store ICs emitted here changes. | |
2475 int store_slot_index = 0; | |
2476 for (int i = 0; i < lit->properties()->length(); i++) { | 2473 for (int i = 0; i < lit->properties()->length(); i++) { |
2477 ObjectLiteral::Property* property = lit->properties()->at(i); | 2474 ObjectLiteral::Property* property = lit->properties()->at(i); |
2478 Expression* value = property->value(); | 2475 Expression* value = property->value(); |
2479 | 2476 |
2480 if (property->is_static()) { | 2477 if (property->is_static()) { |
2481 __ Push(Operand(rsp, kPointerSize)); // constructor | 2478 __ Push(Operand(rsp, kPointerSize)); // constructor |
2482 } else { | 2479 } else { |
2483 __ Push(Operand(rsp, 0)); // prototype | 2480 __ Push(Operand(rsp, 0)); // prototype |
2484 } | 2481 } |
2485 EmitPropertyKey(property, lit->GetIdForProperty(i)); | 2482 EmitPropertyKey(property, lit->GetIdForProperty(i)); |
2486 | 2483 |
2487 // The static prototype property is read only. We handle the non computed | 2484 // The static prototype property is read only. We handle the non computed |
2488 // property name case in the parser. Since this is the only case where we | 2485 // property name case in the parser. Since this is the only case where we |
2489 // need to check for an own read only property we special case this so we do | 2486 // need to check for an own read only property we special case this so we do |
2490 // not need to do this for every property. | 2487 // not need to do this for every property. |
2491 if (property->is_static() && property->is_computed_name()) { | 2488 if (property->is_static() && property->is_computed_name()) { |
2492 __ CallRuntime(Runtime::kThrowIfStaticPrototype, 1); | 2489 __ CallRuntime(Runtime::kThrowIfStaticPrototype, 1); |
2493 __ Push(rax); | 2490 __ Push(rax); |
2494 } | 2491 } |
2495 | 2492 |
2496 VisitForStackValue(value); | 2493 VisitForStackValue(value); |
2497 EmitSetHomeObjectIfNeeded(value, 2, | 2494 EmitSetHomeObjectIfNeeded(value, 2, |
2498 lit->SlotForHomeObject(value, &store_slot_index)); | 2495 lit->SlotForHomeObject(value, used_store_slots)); |
2499 | 2496 |
2500 switch (property->kind()) { | 2497 switch (property->kind()) { |
2501 case ObjectLiteral::Property::CONSTANT: | 2498 case ObjectLiteral::Property::CONSTANT: |
2502 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 2499 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
2503 case ObjectLiteral::Property::PROTOTYPE: | 2500 case ObjectLiteral::Property::PROTOTYPE: |
2504 UNREACHABLE(); | 2501 UNREACHABLE(); |
2505 case ObjectLiteral::Property::COMPUTED: | 2502 case ObjectLiteral::Property::COMPUTED: |
2506 __ CallRuntime(Runtime::kDefineClassMethod, 3); | 2503 __ CallRuntime(Runtime::kDefineClassMethod, 3); |
2507 break; | 2504 break; |
2508 | 2505 |
(...skipping 10 matching lines...) Expand all Loading... |
2519 default: | 2516 default: |
2520 UNREACHABLE(); | 2517 UNREACHABLE(); |
2521 } | 2518 } |
2522 } | 2519 } |
2523 | 2520 |
2524 // prototype | 2521 // prototype |
2525 __ CallRuntime(Runtime::kToFastProperties, 1); | 2522 __ CallRuntime(Runtime::kToFastProperties, 1); |
2526 | 2523 |
2527 // constructor | 2524 // constructor |
2528 __ CallRuntime(Runtime::kToFastProperties, 1); | 2525 __ CallRuntime(Runtime::kToFastProperties, 1); |
2529 | |
2530 // Verify that compilation exactly consumed the number of store ic slots that | |
2531 // the ClassLiteral node had to offer. | |
2532 DCHECK(!FLAG_vector_stores || store_slot_index == lit->slot_count()); | |
2533 } | 2526 } |
2534 | 2527 |
2535 | 2528 |
2536 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { | 2529 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { |
2537 __ Pop(rdx); | 2530 __ Pop(rdx); |
2538 Handle<Code> code = | 2531 Handle<Code> code = |
2539 CodeFactory::BinaryOpIC(isolate(), op, strength(language_mode())).code(); | 2532 CodeFactory::BinaryOpIC(isolate(), op, strength(language_mode())).code(); |
2540 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2533 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2541 CallIC(code, expr->BinaryOperationFeedbackId()); | 2534 CallIC(code, expr->BinaryOperationFeedbackId()); |
2542 patch_site.EmitPatchInfo(); | 2535 patch_site.EmitPatchInfo(); |
(...skipping 2944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5487 Assembler::target_address_at(call_target_address, | 5480 Assembler::target_address_at(call_target_address, |
5488 unoptimized_code)); | 5481 unoptimized_code)); |
5489 return OSR_AFTER_STACK_CHECK; | 5482 return OSR_AFTER_STACK_CHECK; |
5490 } | 5483 } |
5491 | 5484 |
5492 | 5485 |
5493 } // namespace internal | 5486 } // namespace internal |
5494 } // namespace v8 | 5487 } // namespace v8 |
5495 | 5488 |
5496 #endif // V8_TARGET_ARCH_X64 | 5489 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |