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