| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 return Object::IsHeapObject() | 462 return Object::IsHeapObject() |
| 463 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE; | 463 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE; |
| 464 } | 464 } |
| 465 | 465 |
| 466 | 466 |
| 467 bool Object::IsDescriptorArray() { | 467 bool Object::IsDescriptorArray() { |
| 468 return IsFixedArray(); | 468 return IsFixedArray(); |
| 469 } | 469 } |
| 470 | 470 |
| 471 | 471 |
| 472 bool Object::IsDeoptimizationInputData() { |
| 473 // Must be a fixed array. |
| 474 if (!IsFixedArray()) return false; |
| 475 |
| 476 // There's no sure way to detect the difference between a fixed array and |
| 477 // a deoptimization data array. Since this is used for asserts we can |
| 478 // check that the length is zero or else the fixed size plus a multiple of |
| 479 // the entry size. |
| 480 int length = FixedArray::cast(this)->length(); |
| 481 if (length == 0) return true; |
| 482 |
| 483 length -= DeoptimizationInputData::kFirstDeoptEntryIndex; |
| 484 return length >= 0 && |
| 485 length % DeoptimizationInputData::kDeoptEntrySize == 0; |
| 486 } |
| 487 |
| 488 |
| 489 bool Object::IsDeoptimizationOutputData() { |
| 490 if (!IsFixedArray()) return false; |
| 491 // There's actually no way to see the difference between a fixed array and |
| 492 // a deoptimization data array. Since this is used for asserts we can check |
| 493 // that the length is plausible though. |
| 494 if (FixedArray::cast(this)->length() % 2 != 0) return false; |
| 495 return true; |
| 496 } |
| 497 |
| 498 |
| 472 bool Object::IsContext() { | 499 bool Object::IsContext() { |
| 473 if (Object::IsHeapObject()) { | 500 if (Object::IsHeapObject()) { |
| 474 Heap* heap = HeapObject::cast(this)->GetHeap(); | 501 Heap* heap = HeapObject::cast(this)->GetHeap(); |
| 475 return (HeapObject::cast(this)->map() == heap->context_map() || | 502 return (HeapObject::cast(this)->map() == heap->context_map() || |
| 476 HeapObject::cast(this)->map() == heap->catch_context_map() || | 503 HeapObject::cast(this)->map() == heap->catch_context_map() || |
| 477 HeapObject::cast(this)->map() == heap->global_context_map()); | 504 HeapObject::cast(this)->map() == heap->global_context_map()); |
| 478 } | 505 } |
| 479 return false; | 506 return false; |
| 480 } | 507 } |
| 481 | 508 |
| (...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 1789 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
| 1763 } | 1790 } |
| 1764 | 1791 |
| 1765 | 1792 |
| 1766 // ------------------------------------ | 1793 // ------------------------------------ |
| 1767 // Cast operations | 1794 // Cast operations |
| 1768 | 1795 |
| 1769 | 1796 |
| 1770 CAST_ACCESSOR(FixedArray) | 1797 CAST_ACCESSOR(FixedArray) |
| 1771 CAST_ACCESSOR(DescriptorArray) | 1798 CAST_ACCESSOR(DescriptorArray) |
| 1799 CAST_ACCESSOR(DeoptimizationInputData) |
| 1800 CAST_ACCESSOR(DeoptimizationOutputData) |
| 1772 CAST_ACCESSOR(SymbolTable) | 1801 CAST_ACCESSOR(SymbolTable) |
| 1773 CAST_ACCESSOR(JSFunctionResultCache) | 1802 CAST_ACCESSOR(JSFunctionResultCache) |
| 1774 CAST_ACCESSOR(NormalizedMapCache) | 1803 CAST_ACCESSOR(NormalizedMapCache) |
| 1775 CAST_ACCESSOR(CompilationCacheTable) | 1804 CAST_ACCESSOR(CompilationCacheTable) |
| 1776 CAST_ACCESSOR(CodeCacheHashTable) | 1805 CAST_ACCESSOR(CodeCacheHashTable) |
| 1777 CAST_ACCESSOR(MapCache) | 1806 CAST_ACCESSOR(MapCache) |
| 1778 CAST_ACCESSOR(String) | 1807 CAST_ACCESSOR(String) |
| 1779 CAST_ACCESSOR(SeqString) | 1808 CAST_ACCESSOR(SeqString) |
| 1780 CAST_ACCESSOR(SeqAsciiString) | 1809 CAST_ACCESSOR(SeqAsciiString) |
| 1781 CAST_ACCESSOR(SeqTwoByteString) | 1810 CAST_ACCESSOR(SeqTwoByteString) |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2456 } | 2485 } |
| 2457 | 2486 |
| 2458 | 2487 |
| 2459 int Code::arguments_count() { | 2488 int Code::arguments_count() { |
| 2460 ASSERT(is_call_stub() || is_keyed_call_stub() || kind() == STUB); | 2489 ASSERT(is_call_stub() || is_keyed_call_stub() || kind() == STUB); |
| 2461 return ExtractArgumentsCountFromFlags(flags()); | 2490 return ExtractArgumentsCountFromFlags(flags()); |
| 2462 } | 2491 } |
| 2463 | 2492 |
| 2464 | 2493 |
| 2465 int Code::major_key() { | 2494 int Code::major_key() { |
| 2466 ASSERT(kind() == STUB || kind() == BINARY_OP_IC); | 2495 ASSERT(kind() == STUB || |
| 2496 kind() == BINARY_OP_IC || |
| 2497 kind() == TYPE_RECORDING_BINARY_OP_IC || |
| 2498 kind() == COMPARE_IC); |
| 2467 return READ_BYTE_FIELD(this, kStubMajorKeyOffset); | 2499 return READ_BYTE_FIELD(this, kStubMajorKeyOffset); |
| 2468 } | 2500 } |
| 2469 | 2501 |
| 2470 | 2502 |
| 2471 void Code::set_major_key(int major) { | 2503 void Code::set_major_key(int major) { |
| 2472 ASSERT(kind() == STUB || kind() == BINARY_OP_IC); | 2504 ASSERT(kind() == STUB || |
| 2505 kind() == BINARY_OP_IC || |
| 2506 kind() == TYPE_RECORDING_BINARY_OP_IC || |
| 2507 kind() == COMPARE_IC); |
| 2473 ASSERT(0 <= major && major < 256); | 2508 ASSERT(0 <= major && major < 256); |
| 2474 WRITE_BYTE_FIELD(this, kStubMajorKeyOffset, major); | 2509 WRITE_BYTE_FIELD(this, kStubMajorKeyOffset, major); |
| 2475 } | 2510 } |
| 2476 | 2511 |
| 2477 | 2512 |
| 2513 bool Code::optimizable() { |
| 2514 ASSERT(kind() == FUNCTION); |
| 2515 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; |
| 2516 } |
| 2517 |
| 2518 |
| 2519 void Code::set_optimizable(bool value) { |
| 2520 ASSERT(kind() == FUNCTION); |
| 2521 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0); |
| 2522 } |
| 2523 |
| 2524 |
| 2525 bool Code::has_deoptimization_support() { |
| 2526 ASSERT(kind() == FUNCTION); |
| 2527 return READ_BYTE_FIELD(this, kHasDeoptimizationSupportOffset) == 1; |
| 2528 } |
| 2529 |
| 2530 |
| 2531 void Code::set_has_deoptimization_support(bool value) { |
| 2532 ASSERT(kind() == FUNCTION); |
| 2533 WRITE_BYTE_FIELD(this, kHasDeoptimizationSupportOffset, value ? 1 : 0); |
| 2534 } |
| 2535 |
| 2536 |
| 2537 int Code::allow_osr_at_loop_nesting_level() { |
| 2538 ASSERT(kind() == FUNCTION); |
| 2539 return READ_BYTE_FIELD(this, kAllowOSRAtLoopNestingLevelOffset); |
| 2540 } |
| 2541 |
| 2542 |
| 2543 void Code::set_allow_osr_at_loop_nesting_level(int level) { |
| 2544 ASSERT(kind() == FUNCTION); |
| 2545 ASSERT(level >= 0 && level <= kMaxLoopNestingMarker); |
| 2546 WRITE_BYTE_FIELD(this, kAllowOSRAtLoopNestingLevelOffset, level); |
| 2547 } |
| 2548 |
| 2549 |
| 2550 unsigned Code::stack_slots() { |
| 2551 ASSERT(kind() == OPTIMIZED_FUNCTION); |
| 2552 return READ_UINT32_FIELD(this, kStackSlotsOffset); |
| 2553 } |
| 2554 |
| 2555 |
| 2556 void Code::set_stack_slots(unsigned slots) { |
| 2557 ASSERT(kind() == OPTIMIZED_FUNCTION); |
| 2558 WRITE_UINT32_FIELD(this, kStackSlotsOffset, slots); |
| 2559 } |
| 2560 |
| 2561 |
| 2562 unsigned Code::safepoint_table_start() { |
| 2563 ASSERT(kind() == OPTIMIZED_FUNCTION); |
| 2564 return READ_UINT32_FIELD(this, kSafepointTableStartOffset); |
| 2565 } |
| 2566 |
| 2567 |
| 2568 void Code::set_safepoint_table_start(unsigned offset) { |
| 2569 ASSERT(kind() == OPTIMIZED_FUNCTION); |
| 2570 ASSERT(IsAligned(offset, static_cast<unsigned>(kIntSize))); |
| 2571 WRITE_UINT32_FIELD(this, kSafepointTableStartOffset, offset); |
| 2572 } |
| 2573 |
| 2574 |
| 2575 unsigned Code::stack_check_table_start() { |
| 2576 ASSERT(kind() == FUNCTION); |
| 2577 return READ_UINT32_FIELD(this, kStackCheckTableStartOffset); |
| 2578 } |
| 2579 |
| 2580 |
| 2581 void Code::set_stack_check_table_start(unsigned offset) { |
| 2582 ASSERT(kind() == FUNCTION); |
| 2583 ASSERT(IsAligned(offset, static_cast<unsigned>(kIntSize))); |
| 2584 WRITE_UINT32_FIELD(this, kStackCheckTableStartOffset, offset); |
| 2585 } |
| 2586 |
| 2587 |
| 2588 CheckType Code::check_type() { |
| 2589 ASSERT(is_call_stub() || is_keyed_call_stub()); |
| 2590 byte type = READ_BYTE_FIELD(this, kCheckTypeOffset); |
| 2591 return static_cast<CheckType>(type); |
| 2592 } |
| 2593 |
| 2594 |
| 2595 void Code::set_check_type(CheckType value) { |
| 2596 ASSERT(is_call_stub() || is_keyed_call_stub()); |
| 2597 WRITE_BYTE_FIELD(this, kCheckTypeOffset, value); |
| 2598 } |
| 2599 |
| 2600 |
| 2601 byte Code::binary_op_type() { |
| 2602 ASSERT(is_binary_op_stub()); |
| 2603 return READ_BYTE_FIELD(this, kBinaryOpTypeOffset); |
| 2604 } |
| 2605 |
| 2606 |
| 2607 void Code::set_binary_op_type(byte value) { |
| 2608 ASSERT(is_binary_op_stub()); |
| 2609 WRITE_BYTE_FIELD(this, kBinaryOpTypeOffset, value); |
| 2610 } |
| 2611 |
| 2612 |
| 2613 byte Code::type_recording_binary_op_type() { |
| 2614 ASSERT(is_type_recording_binary_op_stub()); |
| 2615 return READ_BYTE_FIELD(this, kBinaryOpTypeOffset); |
| 2616 } |
| 2617 |
| 2618 |
| 2619 void Code::set_type_recording_binary_op_type(byte value) { |
| 2620 ASSERT(is_type_recording_binary_op_stub()); |
| 2621 WRITE_BYTE_FIELD(this, kBinaryOpTypeOffset, value); |
| 2622 } |
| 2623 |
| 2624 |
| 2625 byte Code::type_recording_binary_op_result_type() { |
| 2626 ASSERT(is_type_recording_binary_op_stub()); |
| 2627 return READ_BYTE_FIELD(this, kBinaryOpReturnTypeOffset); |
| 2628 } |
| 2629 |
| 2630 |
| 2631 void Code::set_type_recording_binary_op_result_type(byte value) { |
| 2632 ASSERT(is_type_recording_binary_op_stub()); |
| 2633 WRITE_BYTE_FIELD(this, kBinaryOpReturnTypeOffset, value); |
| 2634 } |
| 2635 |
| 2636 |
| 2637 byte Code::compare_state() { |
| 2638 ASSERT(is_compare_ic_stub()); |
| 2639 return READ_BYTE_FIELD(this, kCompareStateOffset); |
| 2640 } |
| 2641 |
| 2642 |
| 2643 void Code::set_compare_state(byte value) { |
| 2644 ASSERT(is_compare_ic_stub()); |
| 2645 WRITE_BYTE_FIELD(this, kCompareStateOffset, value); |
| 2646 } |
| 2647 |
| 2648 |
| 2478 bool Code::is_inline_cache_stub() { | 2649 bool Code::is_inline_cache_stub() { |
| 2479 Kind kind = this->kind(); | 2650 Kind kind = this->kind(); |
| 2480 return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND; | 2651 return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND; |
| 2481 } | 2652 } |
| 2482 | 2653 |
| 2483 | 2654 |
| 2484 Code::Flags Code::ComputeFlags(Kind kind, | 2655 Code::Flags Code::ComputeFlags(Kind kind, |
| 2485 InLoopFlag in_loop, | 2656 InLoopFlag in_loop, |
| 2486 InlineCacheState ic_state, | 2657 InlineCacheState ic_state, |
| 2487 PropertyType type, | 2658 PropertyType type, |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 } | 2797 } |
| 2627 | 2798 |
| 2628 | 2799 |
| 2629 ACCESSORS(Map, instance_descriptors, DescriptorArray, | 2800 ACCESSORS(Map, instance_descriptors, DescriptorArray, |
| 2630 kInstanceDescriptorsOffset) | 2801 kInstanceDescriptorsOffset) |
| 2631 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) | 2802 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) |
| 2632 ACCESSORS(Map, constructor, Object, kConstructorOffset) | 2803 ACCESSORS(Map, constructor, Object, kConstructorOffset) |
| 2633 | 2804 |
| 2634 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 2805 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
| 2635 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) | 2806 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) |
| 2807 ACCESSORS_GCSAFE(JSFunction, next_function_link, Object, |
| 2808 kNextFunctionLinkOffset) |
| 2636 | 2809 |
| 2637 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) | 2810 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) |
| 2638 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) | 2811 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) |
| 2639 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) | 2812 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) |
| 2640 | 2813 |
| 2641 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) | 2814 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) |
| 2642 | 2815 |
| 2643 ACCESSORS(AccessorInfo, getter, Object, kGetterOffset) | 2816 ACCESSORS(AccessorInfo, getter, Object, kGetterOffset) |
| 2644 ACCESSORS(AccessorInfo, setter, Object, kSetterOffset) | 2817 ACCESSORS(AccessorInfo, setter, Object, kSetterOffset) |
| 2645 ACCESSORS(AccessorInfo, data, Object, kDataOffset) | 2818 ACCESSORS(AccessorInfo, data, Object, kDataOffset) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2763 SMI_ACCESSORS(SharedFunctionInfo, num_literals, kNumLiteralsOffset) | 2936 SMI_ACCESSORS(SharedFunctionInfo, num_literals, kNumLiteralsOffset) |
| 2764 SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type, | 2937 SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type, |
| 2765 kStartPositionAndTypeOffset) | 2938 kStartPositionAndTypeOffset) |
| 2766 SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset) | 2939 SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset) |
| 2767 SMI_ACCESSORS(SharedFunctionInfo, function_token_position, | 2940 SMI_ACCESSORS(SharedFunctionInfo, function_token_position, |
| 2768 kFunctionTokenPositionOffset) | 2941 kFunctionTokenPositionOffset) |
| 2769 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, | 2942 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, |
| 2770 kCompilerHintsOffset) | 2943 kCompilerHintsOffset) |
| 2771 SMI_ACCESSORS(SharedFunctionInfo, this_property_assignments_count, | 2944 SMI_ACCESSORS(SharedFunctionInfo, this_property_assignments_count, |
| 2772 kThisPropertyAssignmentsCountOffset) | 2945 kThisPropertyAssignmentsCountOffset) |
| 2946 SMI_ACCESSORS(SharedFunctionInfo, opt_count, kOptCountOffset) |
| 2773 #else | 2947 #else |
| 2774 | 2948 |
| 2775 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ | 2949 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ |
| 2776 STATIC_ASSERT(holder::offset % kPointerSize == 0); \ | 2950 STATIC_ASSERT(holder::offset % kPointerSize == 0); \ |
| 2777 int holder::name() { \ | 2951 int holder::name() { \ |
| 2778 int value = READ_INT_FIELD(this, offset); \ | 2952 int value = READ_INT_FIELD(this, offset); \ |
| 2779 ASSERT(kHeapObjectTag == 1); \ | 2953 ASSERT(kHeapObjectTag == 1); \ |
| 2780 ASSERT((value & kHeapObjectTag) == 0); \ | 2954 ASSERT((value & kHeapObjectTag) == 0); \ |
| 2781 return value >> 1; \ | 2955 return value >> 1; \ |
| 2782 } \ | 2956 } \ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2812 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, | 2986 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, |
| 2813 function_token_position, | 2987 function_token_position, |
| 2814 kFunctionTokenPositionOffset) | 2988 kFunctionTokenPositionOffset) |
| 2815 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, | 2989 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, |
| 2816 compiler_hints, | 2990 compiler_hints, |
| 2817 kCompilerHintsOffset) | 2991 kCompilerHintsOffset) |
| 2818 | 2992 |
| 2819 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, | 2993 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, |
| 2820 this_property_assignments_count, | 2994 this_property_assignments_count, |
| 2821 kThisPropertyAssignmentsCountOffset) | 2995 kThisPropertyAssignmentsCountOffset) |
| 2996 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, opt_count, kOptCountOffset) |
| 2822 #endif | 2997 #endif |
| 2823 | 2998 |
| 2824 | 2999 |
| 2825 int SharedFunctionInfo::construction_count() { | 3000 int SharedFunctionInfo::construction_count() { |
| 2826 return READ_BYTE_FIELD(this, kConstructionCountOffset); | 3001 return READ_BYTE_FIELD(this, kConstructionCountOffset); |
| 2827 } | 3002 } |
| 2828 | 3003 |
| 2829 | 3004 |
| 2830 void SharedFunctionInfo::set_construction_count(int value) { | 3005 void SharedFunctionInfo::set_construction_count(int value) { |
| 2831 ASSERT(0 <= value && value < 256); | 3006 ASSERT(0 <= value && value < 256); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2845 set_compiler_hints(compiler_hints() & ~(1 << kLiveObjectsMayExist)); | 3020 set_compiler_hints(compiler_hints() & ~(1 << kLiveObjectsMayExist)); |
| 2846 } | 3021 } |
| 2847 } | 3022 } |
| 2848 | 3023 |
| 2849 | 3024 |
| 2850 bool SharedFunctionInfo::IsInobjectSlackTrackingInProgress() { | 3025 bool SharedFunctionInfo::IsInobjectSlackTrackingInProgress() { |
| 2851 return initial_map() != HEAP->undefined_value(); | 3026 return initial_map() != HEAP->undefined_value(); |
| 2852 } | 3027 } |
| 2853 | 3028 |
| 2854 | 3029 |
| 3030 bool SharedFunctionInfo::optimization_disabled() { |
| 3031 return BooleanBit::get(compiler_hints(), kOptimizationDisabled); |
| 3032 } |
| 3033 |
| 3034 |
| 3035 void SharedFunctionInfo::set_optimization_disabled(bool disable) { |
| 3036 set_compiler_hints(BooleanBit::set(compiler_hints(), |
| 3037 kOptimizationDisabled, |
| 3038 disable)); |
| 3039 // If disabling optimizations we reflect that in the code object so |
| 3040 // it will not be counted as optimizable code. |
| 3041 if ((code()->kind() == Code::FUNCTION) && disable) { |
| 3042 code()->set_optimizable(false); |
| 3043 } |
| 3044 } |
| 3045 |
| 3046 |
| 2855 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset) | 3047 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset) |
| 2856 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset) | 3048 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset) |
| 2857 | 3049 |
| 2858 bool Script::HasValidSource() { | 3050 bool Script::HasValidSource() { |
| 2859 Object* src = this->source(); | 3051 Object* src = this->source(); |
| 2860 if (!src->IsString()) return true; | 3052 if (!src->IsString()) return true; |
| 2861 String* src_str = String::cast(src); | 3053 String* src_str = String::cast(src); |
| 2862 if (!StringShape(src_str).IsExternal()) return true; | 3054 if (!StringShape(src_str).IsExternal()) return true; |
| 2863 if (src_str->IsAsciiRepresentation()) { | 3055 if (src_str->IsAsciiRepresentation()) { |
| 2864 return ExternalAsciiString::cast(src)->resource() != NULL; | 3056 return ExternalAsciiString::cast(src)->resource() != NULL; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2890 return Code::cast(READ_FIELD(this, kCodeOffset)); | 3082 return Code::cast(READ_FIELD(this, kCodeOffset)); |
| 2891 } | 3083 } |
| 2892 | 3084 |
| 2893 | 3085 |
| 2894 Code* SharedFunctionInfo::unchecked_code() { | 3086 Code* SharedFunctionInfo::unchecked_code() { |
| 2895 return reinterpret_cast<Code*>(READ_FIELD(this, kCodeOffset)); | 3087 return reinterpret_cast<Code*>(READ_FIELD(this, kCodeOffset)); |
| 2896 } | 3088 } |
| 2897 | 3089 |
| 2898 | 3090 |
| 2899 void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) { | 3091 void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) { |
| 3092 // If optimization has been disabled for the shared function info, |
| 3093 // reflect that in the code object so it will not be counted as |
| 3094 // optimizable code. |
| 3095 ASSERT(value->kind() != Code::FUNCTION || |
| 3096 !value->optimizable() || |
| 3097 this->code() == Isolate::Current()->builtins()-> |
| 3098 builtin(Builtins::Illegal) || |
| 3099 this->allows_lazy_compilation()); |
| 2900 WRITE_FIELD(this, kCodeOffset, value); | 3100 WRITE_FIELD(this, kCodeOffset, value); |
| 2901 ASSERT(!Isolate::Current()->heap()->InNewSpace(value)); | 3101 ASSERT(!Isolate::Current()->heap()->InNewSpace(value)); |
| 2902 } | 3102 } |
| 2903 | 3103 |
| 2904 | 3104 |
| 2905 SerializedScopeInfo* SharedFunctionInfo::scope_info() { | 3105 SerializedScopeInfo* SharedFunctionInfo::scope_info() { |
| 2906 return reinterpret_cast<SerializedScopeInfo*>( | 3106 return reinterpret_cast<SerializedScopeInfo*>( |
| 2907 READ_FIELD(this, kScopeInfoOffset)); | 3107 READ_FIELD(this, kScopeInfoOffset)); |
| 2908 } | 3108 } |
| 2909 | 3109 |
| 2910 | 3110 |
| 2911 void SharedFunctionInfo::set_scope_info(SerializedScopeInfo* value, | 3111 void SharedFunctionInfo::set_scope_info(SerializedScopeInfo* value, |
| 2912 WriteBarrierMode mode) { | 3112 WriteBarrierMode mode) { |
| 2913 WRITE_FIELD(this, kScopeInfoOffset, reinterpret_cast<Object*>(value)); | 3113 WRITE_FIELD(this, kScopeInfoOffset, reinterpret_cast<Object*>(value)); |
| 2914 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kScopeInfoOffset, mode); | 3114 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kScopeInfoOffset, mode); |
| 2915 } | 3115 } |
| 2916 | 3116 |
| 2917 | 3117 |
| 3118 Smi* SharedFunctionInfo::deopt_counter() { |
| 3119 return reinterpret_cast<Smi*>(READ_FIELD(this, kDeoptCounterOffset)); |
| 3120 } |
| 3121 |
| 3122 |
| 3123 void SharedFunctionInfo::set_deopt_counter(Smi* value) { |
| 3124 WRITE_FIELD(this, kDeoptCounterOffset, value); |
| 3125 } |
| 3126 |
| 3127 |
| 2918 bool SharedFunctionInfo::is_compiled() { | 3128 bool SharedFunctionInfo::is_compiled() { |
| 2919 return code() != | 3129 return code() != |
| 2920 Isolate::Current()->builtins()->builtin(Builtins::LazyCompile); | 3130 Isolate::Current()->builtins()->builtin(Builtins::LazyCompile); |
| 2921 } | 3131 } |
| 2922 | 3132 |
| 2923 | 3133 |
| 2924 bool SharedFunctionInfo::IsApiFunction() { | 3134 bool SharedFunctionInfo::IsApiFunction() { |
| 2925 return function_data()->IsFunctionTemplateInfo(); | 3135 return function_data()->IsFunctionTemplateInfo(); |
| 2926 } | 3136 } |
| 2927 | 3137 |
| 2928 | 3138 |
| 2929 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() { | 3139 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() { |
| 2930 ASSERT(IsApiFunction()); | 3140 ASSERT(IsApiFunction()); |
| 2931 return FunctionTemplateInfo::cast(function_data()); | 3141 return FunctionTemplateInfo::cast(function_data()); |
| 2932 } | 3142 } |
| 2933 | 3143 |
| 2934 | 3144 |
| 2935 bool SharedFunctionInfo::HasCustomCallGenerator() { | 3145 bool SharedFunctionInfo::HasCustomCallGenerator() { |
| 2936 return function_data()->IsSmi(); | 3146 return function_data()->IsSmi(); |
| 2937 } | 3147 } |
| 2938 | 3148 |
| 2939 | 3149 |
| 3150 MathFunctionId SharedFunctionInfo::math_function_id() { |
| 3151 return static_cast<MathFunctionId>( |
| 3152 (compiler_hints() >> kMathFunctionShift) & kMathFunctionMask); |
| 3153 } |
| 3154 |
| 3155 |
| 3156 void SharedFunctionInfo::set_math_function_id(int math_fn) { |
| 3157 ASSERT(math_fn <= max_math_id_number()); |
| 3158 set_compiler_hints(compiler_hints() | |
| 3159 ((math_fn & kMathFunctionMask) << kMathFunctionShift)); |
| 3160 } |
| 3161 |
| 3162 |
| 2940 int SharedFunctionInfo::custom_call_generator_id() { | 3163 int SharedFunctionInfo::custom_call_generator_id() { |
| 2941 ASSERT(HasCustomCallGenerator()); | 3164 ASSERT(HasCustomCallGenerator()); |
| 2942 return Smi::cast(function_data())->value(); | 3165 return Smi::cast(function_data())->value(); |
| 2943 } | 3166 } |
| 2944 | 3167 |
| 2945 | 3168 |
| 2946 int SharedFunctionInfo::code_age() { | 3169 int SharedFunctionInfo::code_age() { |
| 2947 return (compiler_hints() >> kCodeAgeShift) & kCodeAgeMask; | 3170 return (compiler_hints() >> kCodeAgeShift) & kCodeAgeMask; |
| 2948 } | 3171 } |
| 2949 | 3172 |
| 2950 | 3173 |
| 2951 void SharedFunctionInfo::set_code_age(int code_age) { | 3174 void SharedFunctionInfo::set_code_age(int code_age) { |
| 2952 set_compiler_hints(compiler_hints() | | 3175 set_compiler_hints(compiler_hints() | |
| 2953 ((code_age & kCodeAgeMask) << kCodeAgeShift)); | 3176 ((code_age & kCodeAgeMask) << kCodeAgeShift)); |
| 2954 } | 3177 } |
| 2955 | 3178 |
| 2956 | 3179 |
| 3180 bool SharedFunctionInfo::has_deoptimization_support() { |
| 3181 Code* code = this->code(); |
| 3182 return code->kind() == Code::FUNCTION && code->has_deoptimization_support(); |
| 3183 } |
| 3184 |
| 3185 |
| 2957 bool JSFunction::IsBuiltin() { | 3186 bool JSFunction::IsBuiltin() { |
| 2958 return context()->global()->IsJSBuiltinsObject(); | 3187 return context()->global()->IsJSBuiltinsObject(); |
| 2959 } | 3188 } |
| 2960 | 3189 |
| 2961 | 3190 |
| 3191 bool JSFunction::NeedsArgumentsAdaption() { |
| 3192 return shared()->formal_parameter_count() != |
| 3193 SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
| 3194 } |
| 3195 |
| 3196 |
| 3197 bool JSFunction::IsOptimized() { |
| 3198 return code()->kind() == Code::OPTIMIZED_FUNCTION; |
| 3199 } |
| 3200 |
| 3201 |
| 3202 bool JSFunction::IsMarkedForLazyRecompilation() { |
| 3203 return code() == GetIsolate()->builtins()->builtin(Builtins::LazyRecompile); |
| 3204 } |
| 3205 |
| 3206 |
| 2962 Code* JSFunction::code() { | 3207 Code* JSFunction::code() { |
| 2963 return Code::cast(unchecked_code()); | 3208 return Code::cast(unchecked_code()); |
| 2964 } | 3209 } |
| 2965 | 3210 |
| 2966 | 3211 |
| 2967 Code* JSFunction::unchecked_code() { | 3212 Code* JSFunction::unchecked_code() { |
| 2968 return reinterpret_cast<Code*>( | 3213 return reinterpret_cast<Code*>( |
| 2969 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset))); | 3214 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset))); |
| 2970 } | 3215 } |
| 2971 | 3216 |
| 2972 | 3217 |
| 2973 void JSFunction::set_code(Code* value) { | 3218 void JSFunction::set_code(Code* value) { |
| 2974 // Skip the write barrier because code is never in new space. | 3219 // Skip the write barrier because code is never in new space. |
| 2975 ASSERT(!HEAP->InNewSpace(value)); | 3220 ASSERT(!HEAP->InNewSpace(value)); |
| 2976 Address entry = value->entry(); | 3221 Address entry = value->entry(); |
| 2977 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); | 3222 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); |
| 2978 } | 3223 } |
| 2979 | 3224 |
| 2980 | 3225 |
| 3226 void JSFunction::ReplaceCode(Code* code) { |
| 3227 bool was_optimized = IsOptimized(); |
| 3228 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; |
| 3229 |
| 3230 set_code(code); |
| 3231 |
| 3232 // Add/remove the function from the list of optimized functions for this |
| 3233 // context based on the state change. |
| 3234 if (!was_optimized && is_optimized) { |
| 3235 context()->global_context()->AddOptimizedFunction(this); |
| 3236 } |
| 3237 if (was_optimized && !is_optimized) { |
| 3238 context()->global_context()->RemoveOptimizedFunction(this); |
| 3239 } |
| 3240 } |
| 3241 |
| 3242 |
| 2981 Context* JSFunction::context() { | 3243 Context* JSFunction::context() { |
| 2982 return Context::cast(READ_FIELD(this, kContextOffset)); | 3244 return Context::cast(READ_FIELD(this, kContextOffset)); |
| 2983 } | 3245 } |
| 2984 | 3246 |
| 2985 | 3247 |
| 2986 Object* JSFunction::unchecked_context() { | 3248 Object* JSFunction::unchecked_context() { |
| 2987 return READ_FIELD(this, kContextOffset); | 3249 return READ_FIELD(this, kContextOffset); |
| 2988 } | 3250 } |
| 2989 | 3251 |
| 2990 | 3252 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3104 | 3366 |
| 3105 JSValue* JSValue::cast(Object* obj) { | 3367 JSValue* JSValue::cast(Object* obj) { |
| 3106 ASSERT(obj->IsJSValue()); | 3368 ASSERT(obj->IsJSValue()); |
| 3107 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); | 3369 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); |
| 3108 return reinterpret_cast<JSValue*>(obj); | 3370 return reinterpret_cast<JSValue*>(obj); |
| 3109 } | 3371 } |
| 3110 | 3372 |
| 3111 | 3373 |
| 3112 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) | 3374 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) |
| 3113 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) | 3375 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) |
| 3376 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) |
| 3114 | 3377 |
| 3115 | 3378 |
| 3116 byte* Code::instruction_start() { | 3379 byte* Code::instruction_start() { |
| 3117 return FIELD_ADDR(this, kHeaderSize); | 3380 return FIELD_ADDR(this, kHeaderSize); |
| 3118 } | 3381 } |
| 3119 | 3382 |
| 3120 | 3383 |
| 3121 byte* Code::instruction_end() { | 3384 byte* Code::instruction_end() { |
| 3122 return instruction_start() + instruction_size(); | 3385 return instruction_start() + instruction_size(); |
| 3123 } | 3386 } |
| 3124 | 3387 |
| 3125 | 3388 |
| 3126 int Code::body_size() { | 3389 int Code::body_size() { |
| 3127 return RoundUp(instruction_size(), kObjectAlignment); | 3390 return RoundUp(instruction_size(), kObjectAlignment); |
| 3128 } | 3391 } |
| 3129 | 3392 |
| 3130 | 3393 |
| 3394 FixedArray* Code::unchecked_deoptimization_data() { |
| 3395 return reinterpret_cast<FixedArray*>( |
| 3396 READ_FIELD(this, kDeoptimizationDataOffset)); |
| 3397 } |
| 3398 |
| 3399 |
| 3131 ByteArray* Code::unchecked_relocation_info() { | 3400 ByteArray* Code::unchecked_relocation_info() { |
| 3132 return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset)); | 3401 return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset)); |
| 3133 } | 3402 } |
| 3134 | 3403 |
| 3135 | 3404 |
| 3136 byte* Code::relocation_start() { | 3405 byte* Code::relocation_start() { |
| 3137 return unchecked_relocation_info()->GetDataStartAddress(); | 3406 return unchecked_relocation_info()->GetDataStartAddress(); |
| 3138 } | 3407 } |
| 3139 | 3408 |
| 3140 | 3409 |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3751 #undef WRITE_INT_FIELD | 4020 #undef WRITE_INT_FIELD |
| 3752 #undef READ_SHORT_FIELD | 4021 #undef READ_SHORT_FIELD |
| 3753 #undef WRITE_SHORT_FIELD | 4022 #undef WRITE_SHORT_FIELD |
| 3754 #undef READ_BYTE_FIELD | 4023 #undef READ_BYTE_FIELD |
| 3755 #undef WRITE_BYTE_FIELD | 4024 #undef WRITE_BYTE_FIELD |
| 3756 | 4025 |
| 3757 | 4026 |
| 3758 } } // namespace v8::internal | 4027 } } // namespace v8::internal |
| 3759 | 4028 |
| 3760 #endif // V8_OBJECTS_INL_H_ | 4029 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |