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