| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 28 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 |
| 31 // The original source code covered by the above license above has been | 31 // The original source code covered by the above license above has been |
| 32 // modified significantly by Google Inc. | 32 // modified significantly by Google Inc. |
| 33 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 33 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 34 | 34 |
| 35 #include "v8.h" | 35 #include "v8.h" |
| 36 | 36 |
| 37 #include "arguments.h" | 37 #include "arguments.h" |
| 38 #include "deoptimizer.h" |
| 38 #include "execution.h" | 39 #include "execution.h" |
| 39 #include "ic-inl.h" | 40 #include "ic-inl.h" |
| 40 #include "factory.h" | 41 #include "factory.h" |
| 41 #include "runtime.h" | 42 #include "runtime.h" |
| 43 #include "runtime-profiler.h" |
| 42 #include "serialize.h" | 44 #include "serialize.h" |
| 43 #include "stub-cache.h" | 45 #include "stub-cache.h" |
| 44 #include "regexp-stack.h" | 46 #include "regexp-stack.h" |
| 45 #include "ast.h" | 47 #include "ast.h" |
| 46 #include "regexp-macro-assembler.h" | 48 #include "regexp-macro-assembler.h" |
| 47 #include "platform.h" | 49 #include "platform.h" |
| 48 // Include native regexp-macro-assembler. | 50 // Include native regexp-macro-assembler. |
| 49 #ifndef V8_INTERPRETED_REGEXP | 51 #ifndef V8_INTERPRETED_REGEXP |
| 50 #if V8_TARGET_ARCH_IA32 | 52 #if V8_TARGET_ARCH_IA32 |
| 51 #include "ia32/regexp-macro-assembler-ia32.h" | 53 #include "ia32/regexp-macro-assembler-ia32.h" |
| 52 #elif V8_TARGET_ARCH_X64 | 54 #elif V8_TARGET_ARCH_X64 |
| 53 #include "x64/regexp-macro-assembler-x64.h" | 55 #include "x64/regexp-macro-assembler-x64.h" |
| 54 #elif V8_TARGET_ARCH_ARM | 56 #elif V8_TARGET_ARCH_ARM |
| 55 #include "arm/regexp-macro-assembler-arm.h" | 57 #include "arm/regexp-macro-assembler-arm.h" |
| 56 #else // Unknown architecture. | 58 #else // Unknown architecture. |
| 57 #error "Unknown architecture." | 59 #error "Unknown architecture." |
| 58 #endif // Target architecture. | 60 #endif // Target architecture. |
| 59 #endif // V8_INTERPRETED_REGEXP | 61 #endif // V8_INTERPRETED_REGEXP |
| 60 | 62 |
| 61 namespace v8 { | 63 namespace v8 { |
| 62 namespace internal { | 64 namespace internal { |
| 63 | 65 |
| 64 | 66 |
| 67 const double DoubleConstant::min_int = kMinInt; |
| 68 const double DoubleConstant::one_half = 0.5; |
| 69 |
| 70 |
| 65 // ----------------------------------------------------------------------------- | 71 // ----------------------------------------------------------------------------- |
| 66 // Implementation of Label | 72 // Implementation of Label |
| 67 | 73 |
| 68 int Label::pos() const { | 74 int Label::pos() const { |
| 69 if (pos_ < 0) return -pos_ - 1; | 75 if (pos_ < 0) return -pos_ - 1; |
| 70 if (pos_ > 0) return pos_ - 1; | 76 if (pos_ > 0) return pos_ - 1; |
| 71 UNREACHABLE(); | 77 UNREACHABLE(); |
| 72 return 0; | 78 return 0; |
| 73 } | 79 } |
| 74 | 80 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 209 } |
| 204 } | 210 } |
| 205 | 211 |
| 206 | 212 |
| 207 void RelocInfoWriter::Write(const RelocInfo* rinfo) { | 213 void RelocInfoWriter::Write(const RelocInfo* rinfo) { |
| 208 #ifdef DEBUG | 214 #ifdef DEBUG |
| 209 byte* begin_pos = pos_; | 215 byte* begin_pos = pos_; |
| 210 #endif | 216 #endif |
| 211 COUNTERS->reloc_info_count()->Increment(); | 217 COUNTERS->reloc_info_count()->Increment(); |
| 212 ASSERT(rinfo->pc() - last_pc_ >= 0); | 218 ASSERT(rinfo->pc() - last_pc_ >= 0); |
| 213 ASSERT(RelocInfo::NUMBER_OF_MODES < kMaxRelocModes); | 219 ASSERT(RelocInfo::NUMBER_OF_MODES <= kMaxRelocModes); |
| 214 // Use unsigned delta-encoding for pc. | 220 // Use unsigned delta-encoding for pc. |
| 215 uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); | 221 uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); |
| 216 RelocInfo::Mode rmode = rinfo->rmode(); | 222 RelocInfo::Mode rmode = rinfo->rmode(); |
| 217 | 223 |
| 218 // The two most common modes are given small tags, and usually fit in a byte. | 224 // The two most common modes are given small tags, and usually fit in a byte. |
| 219 if (rmode == RelocInfo::EMBEDDED_OBJECT) { | 225 if (rmode == RelocInfo::EMBEDDED_OBJECT) { |
| 220 WriteTaggedPC(pc_delta, kEmbeddedObjectTag); | 226 WriteTaggedPC(pc_delta, kEmbeddedObjectTag); |
| 221 } else if (rmode == RelocInfo::CODE_TARGET) { | 227 } else if (rmode == RelocInfo::CODE_TARGET) { |
| 222 WriteTaggedPC(pc_delta, kCodeTargetTag); | 228 WriteTaggedPC(pc_delta, kCodeTargetTag); |
| 223 } else if (RelocInfo::IsPosition(rmode)) { | 229 } else if (RelocInfo::IsPosition(rmode)) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 385 } |
| 380 } | 386 } |
| 381 } | 387 } |
| 382 done_ = true; | 388 done_ = true; |
| 383 } | 389 } |
| 384 | 390 |
| 385 | 391 |
| 386 RelocIterator::RelocIterator(Code* code, int mode_mask) { | 392 RelocIterator::RelocIterator(Code* code, int mode_mask) { |
| 387 rinfo_.pc_ = code->instruction_start(); | 393 rinfo_.pc_ = code->instruction_start(); |
| 388 rinfo_.data_ = 0; | 394 rinfo_.data_ = 0; |
| 389 // relocation info is read backwards | 395 // Relocation info is read backwards. |
| 390 pos_ = code->relocation_start() + code->relocation_size(); | 396 pos_ = code->relocation_start() + code->relocation_size(); |
| 391 end_ = code->relocation_start(); | 397 end_ = code->relocation_start(); |
| 392 done_ = false; | 398 done_ = false; |
| 393 mode_mask_ = mode_mask; | 399 mode_mask_ = mode_mask; |
| 394 if (mode_mask_ == 0) pos_ = end_; | 400 if (mode_mask_ == 0) pos_ = end_; |
| 395 next(); | 401 next(); |
| 396 } | 402 } |
| 397 | 403 |
| 398 | 404 |
| 399 RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) { | 405 RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) { |
| 400 rinfo_.pc_ = desc.buffer; | 406 rinfo_.pc_ = desc.buffer; |
| 401 rinfo_.data_ = 0; | 407 rinfo_.data_ = 0; |
| 402 // relocation info is read backwards | 408 // Relocation info is read backwards. |
| 403 pos_ = desc.buffer + desc.buffer_size; | 409 pos_ = desc.buffer + desc.buffer_size; |
| 404 end_ = pos_ - desc.reloc_size; | 410 end_ = pos_ - desc.reloc_size; |
| 405 done_ = false; | 411 done_ = false; |
| 406 mode_mask_ = mode_mask; | 412 mode_mask_ = mode_mask; |
| 407 if (mode_mask_ == 0) pos_ = end_; | 413 if (mode_mask_ == 0) pos_ = end_; |
| 408 next(); | 414 next(); |
| 409 } | 415 } |
| 410 | 416 |
| 411 | 417 |
| 412 // ----------------------------------------------------------------------------- | 418 // ----------------------------------------------------------------------------- |
| (...skipping 11 matching lines...) Expand all Loading... |
| 424 return "code target (js construct call)"; | 430 return "code target (js construct call)"; |
| 425 case RelocInfo::CODE_TARGET_CONTEXT: | 431 case RelocInfo::CODE_TARGET_CONTEXT: |
| 426 return "code target (context)"; | 432 return "code target (context)"; |
| 427 case RelocInfo::DEBUG_BREAK: | 433 case RelocInfo::DEBUG_BREAK: |
| 428 #ifndef ENABLE_DEBUGGER_SUPPORT | 434 #ifndef ENABLE_DEBUGGER_SUPPORT |
| 429 UNREACHABLE(); | 435 UNREACHABLE(); |
| 430 #endif | 436 #endif |
| 431 return "debug break"; | 437 return "debug break"; |
| 432 case RelocInfo::CODE_TARGET: | 438 case RelocInfo::CODE_TARGET: |
| 433 return "code target"; | 439 return "code target"; |
| 440 case RelocInfo::GLOBAL_PROPERTY_CELL: |
| 441 return "global property cell"; |
| 434 case RelocInfo::RUNTIME_ENTRY: | 442 case RelocInfo::RUNTIME_ENTRY: |
| 435 return "runtime entry"; | 443 return "runtime entry"; |
| 436 case RelocInfo::JS_RETURN: | 444 case RelocInfo::JS_RETURN: |
| 437 return "js return"; | 445 return "js return"; |
| 438 case RelocInfo::COMMENT: | 446 case RelocInfo::COMMENT: |
| 439 return "comment"; | 447 return "comment"; |
| 440 case RelocInfo::POSITION: | 448 case RelocInfo::POSITION: |
| 441 return "position"; | 449 return "position"; |
| 442 case RelocInfo::STATEMENT_POSITION: | 450 case RelocInfo::STATEMENT_POSITION: |
| 443 return "statement position"; | 451 return "statement position"; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 469 } else if (rmode_ == EXTERNAL_REFERENCE) { | 477 } else if (rmode_ == EXTERNAL_REFERENCE) { |
| 470 ExternalReferenceEncoder ref_encoder; | 478 ExternalReferenceEncoder ref_encoder; |
| 471 PrintF(" (%s) (%p)", | 479 PrintF(" (%s) (%p)", |
| 472 ref_encoder.NameOfAddress(*target_reference_address()), | 480 ref_encoder.NameOfAddress(*target_reference_address()), |
| 473 *target_reference_address()); | 481 *target_reference_address()); |
| 474 } else if (IsCodeTarget(rmode_)) { | 482 } else if (IsCodeTarget(rmode_)) { |
| 475 Code* code = Code::GetCodeFromTargetAddress(target_address()); | 483 Code* code = Code::GetCodeFromTargetAddress(target_address()); |
| 476 PrintF(" (%s) (%p)", Code::Kind2String(code->kind()), target_address()); | 484 PrintF(" (%s) (%p)", Code::Kind2String(code->kind()), target_address()); |
| 477 } else if (IsPosition(rmode_)) { | 485 } else if (IsPosition(rmode_)) { |
| 478 PrintF(" (%" V8_PTR_PREFIX "d)", data()); | 486 PrintF(" (%" V8_PTR_PREFIX "d)", data()); |
| 487 } else if (rmode_ == RelocInfo::RUNTIME_ENTRY) { |
| 488 // Depotimization bailouts are stored as runtime entries. |
| 489 int id = Deoptimizer::GetDeoptimizationId( |
| 490 target_address(), Deoptimizer::EAGER); |
| 491 if (id != Deoptimizer::kNotDeoptimizationEntry) { |
| 492 PrintF(" (deoptimization bailout %d)", id); |
| 493 } |
| 479 } | 494 } |
| 480 | 495 |
| 481 PrintF("\n"); | 496 PrintF("\n"); |
| 482 } | 497 } |
| 483 #endif // ENABLE_DISASSEMBLER | 498 #endif // ENABLE_DISASSEMBLER |
| 484 | 499 |
| 485 | 500 |
| 486 #ifdef DEBUG | 501 #ifdef DEBUG |
| 487 void RelocInfo::Verify() { | 502 void RelocInfo::Verify() { |
| 488 switch (rmode_) { | 503 switch (rmode_) { |
| 489 case EMBEDDED_OBJECT: | 504 case EMBEDDED_OBJECT: |
| 490 Object::VerifyPointer(target_object()); | 505 Object::VerifyPointer(target_object()); |
| 491 break; | 506 break; |
| 507 case GLOBAL_PROPERTY_CELL: |
| 508 Object::VerifyPointer(target_cell()); |
| 509 break; |
| 492 case DEBUG_BREAK: | 510 case DEBUG_BREAK: |
| 493 #ifndef ENABLE_DEBUGGER_SUPPORT | 511 #ifndef ENABLE_DEBUGGER_SUPPORT |
| 494 UNREACHABLE(); | 512 UNREACHABLE(); |
| 495 break; | 513 break; |
| 496 #endif | 514 #endif |
| 497 case CONSTRUCT_CALL: | 515 case CONSTRUCT_CALL: |
| 498 case CODE_TARGET_CONTEXT: | 516 case CODE_TARGET_CONTEXT: |
| 499 case CODE_TARGET: { | 517 case CODE_TARGET: { |
| 500 // convert inline target address to code object | 518 // convert inline target address to code object |
| 501 Address addr = target_address(); | 519 Address addr = target_address(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 return ExternalReference(Redirect(FUNCTION_ADDR(V8::Random))); | 612 return ExternalReference(Redirect(FUNCTION_ADDR(V8::Random))); |
| 595 } | 613 } |
| 596 | 614 |
| 597 | 615 |
| 598 ExternalReference ExternalReference::transcendental_cache_array_address() { | 616 ExternalReference ExternalReference::transcendental_cache_array_address() { |
| 599 return ExternalReference(Isolate::Current()->transcendental_cache()-> | 617 return ExternalReference(Isolate::Current()->transcendental_cache()-> |
| 600 cache_array_address()); | 618 cache_array_address()); |
| 601 } | 619 } |
| 602 | 620 |
| 603 | 621 |
| 622 ExternalReference ExternalReference::new_deoptimizer_function() { |
| 623 return ExternalReference( |
| 624 Redirect(FUNCTION_ADDR(Deoptimizer::New))); |
| 625 } |
| 626 |
| 627 |
| 628 ExternalReference ExternalReference::compute_output_frames_function() { |
| 629 return ExternalReference( |
| 630 Redirect(FUNCTION_ADDR(Deoptimizer::ComputeOutputFrames))); |
| 631 } |
| 632 |
| 633 |
| 634 ExternalReference ExternalReference::global_contexts_list() { |
| 635 return ExternalReference(Isolate::Current()-> |
| 636 heap()->global_contexts_list_address()); |
| 637 } |
| 638 |
| 639 |
| 604 ExternalReference ExternalReference::keyed_lookup_cache_keys() { | 640 ExternalReference ExternalReference::keyed_lookup_cache_keys() { |
| 605 return ExternalReference(Isolate::Current()-> | 641 return ExternalReference(Isolate::Current()-> |
| 606 keyed_lookup_cache()->keys_address()); | 642 keyed_lookup_cache()->keys_address()); |
| 607 } | 643 } |
| 608 | 644 |
| 609 | 645 |
| 610 ExternalReference ExternalReference::keyed_lookup_cache_field_offsets() { | 646 ExternalReference ExternalReference::keyed_lookup_cache_field_offsets() { |
| 611 return ExternalReference(Isolate::Current()-> | 647 return ExternalReference(Isolate::Current()-> |
| 612 keyed_lookup_cache()->field_offsets_address()); | 648 keyed_lookup_cache()->field_offsets_address()); |
| 613 } | 649 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 ExternalReference ExternalReference::handle_scope_limit_address() { | 715 ExternalReference ExternalReference::handle_scope_limit_address() { |
| 680 return ExternalReference(HandleScope::current_limit_address()); | 716 return ExternalReference(HandleScope::current_limit_address()); |
| 681 } | 717 } |
| 682 | 718 |
| 683 | 719 |
| 684 ExternalReference ExternalReference::scheduled_exception_address() { | 720 ExternalReference ExternalReference::scheduled_exception_address() { |
| 685 return ExternalReference(Isolate::Current()->scheduled_exception_address()); | 721 return ExternalReference(Isolate::Current()->scheduled_exception_address()); |
| 686 } | 722 } |
| 687 | 723 |
| 688 | 724 |
| 725 ExternalReference ExternalReference::address_of_min_int() { |
| 726 return ExternalReference(reinterpret_cast<void*>( |
| 727 const_cast<double*>(&DoubleConstant::min_int))); |
| 728 } |
| 729 |
| 730 |
| 731 ExternalReference ExternalReference::address_of_one_half() { |
| 732 return ExternalReference(reinterpret_cast<void*>( |
| 733 const_cast<double*>(&DoubleConstant::one_half))); |
| 734 } |
| 735 |
| 736 |
| 689 #ifndef V8_INTERPRETED_REGEXP | 737 #ifndef V8_INTERPRETED_REGEXP |
| 690 | 738 |
| 691 ExternalReference ExternalReference::re_check_stack_guard_state() { | 739 ExternalReference ExternalReference::re_check_stack_guard_state() { |
| 692 Address function; | 740 Address function; |
| 693 #ifdef V8_TARGET_ARCH_X64 | 741 #ifdef V8_TARGET_ARCH_X64 |
| 694 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState); | 742 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState); |
| 695 #elif V8_TARGET_ARCH_IA32 | 743 #elif V8_TARGET_ARCH_IA32 |
| 696 function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState); | 744 function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState); |
| 697 #elif V8_TARGET_ARCH_ARM | 745 #elif V8_TARGET_ARCH_ARM |
| 698 function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState); | 746 function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); | 895 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); |
| 848 state_.written_position = state_.current_position; | 896 state_.written_position = state_.current_position; |
| 849 written = true; | 897 written = true; |
| 850 } | 898 } |
| 851 | 899 |
| 852 // Return whether something was written. | 900 // Return whether something was written. |
| 853 return written; | 901 return written; |
| 854 } | 902 } |
| 855 | 903 |
| 856 } } // namespace v8::internal | 904 } } // namespace v8::internal |
| OLD | NEW |