Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: src/objects.h

Issue 6529055: [Isolates] Merge crankshaft (r5922 from bleeding_edge). (Closed)
Patch Set: Win32 port Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/messages.js ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 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
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 InstanceType type; 578 InstanceType type;
579 Object* ptr; 579 Object* ptr;
580 const char* str; 580 const char* str;
581 double number; 581 double number;
582 }; 582 };
583 583
584 584
585 // A template-ized version of the IsXXX functions. 585 // A template-ized version of the IsXXX functions.
586 template <class C> static inline bool Is(Object* obj); 586 template <class C> static inline bool Is(Object* obj);
587 587
588
588 class MaybeObject BASE_EMBEDDED { 589 class MaybeObject BASE_EMBEDDED {
589 public: 590 public:
590 inline bool IsFailure(); 591 inline bool IsFailure();
591 inline bool IsRetryAfterGC(); 592 inline bool IsRetryAfterGC();
592 inline bool IsOutOfMemory(); 593 inline bool IsOutOfMemory();
593 inline bool IsException(); 594 inline bool IsException();
594 INLINE(bool IsTheHole()); 595 INLINE(bool IsTheHole());
595 inline bool ToObject(Object** obj) { 596 inline bool ToObject(Object** obj) {
596 if (IsFailure()) return false; 597 if (IsFailure()) return false;
597 *obj = reinterpret_cast<Object*>(this); 598 *obj = reinterpret_cast<Object*>(this);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 inline bool IsExternalShortArray(); 648 inline bool IsExternalShortArray();
648 inline bool IsExternalUnsignedShortArray(); 649 inline bool IsExternalUnsignedShortArray();
649 inline bool IsExternalIntArray(); 650 inline bool IsExternalIntArray();
650 inline bool IsExternalUnsignedIntArray(); 651 inline bool IsExternalUnsignedIntArray();
651 inline bool IsExternalFloatArray(); 652 inline bool IsExternalFloatArray();
652 inline bool IsJSObject(); 653 inline bool IsJSObject();
653 inline bool IsJSContextExtensionObject(); 654 inline bool IsJSContextExtensionObject();
654 inline bool IsMap(); 655 inline bool IsMap();
655 inline bool IsFixedArray(); 656 inline bool IsFixedArray();
656 inline bool IsDescriptorArray(); 657 inline bool IsDescriptorArray();
658 inline bool IsDeoptimizationInputData();
659 inline bool IsDeoptimizationOutputData();
657 inline bool IsContext(); 660 inline bool IsContext();
658 inline bool IsCatchContext(); 661 inline bool IsCatchContext();
659 inline bool IsGlobalContext(); 662 inline bool IsGlobalContext();
660 inline bool IsJSFunction(); 663 inline bool IsJSFunction();
661 inline bool IsCode(); 664 inline bool IsCode();
662 inline bool IsOddball(); 665 inline bool IsOddball();
663 inline bool IsSharedFunctionInfo(); 666 inline bool IsSharedFunctionInfo();
664 inline bool IsJSValue(); 667 inline bool IsJSValue();
665 inline bool IsStringWrapper(); 668 inline bool IsStringWrapper();
666 inline bool IsProxy(); 669 inline bool IsProxy();
(...skipping 2229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2896 #ifdef DEBUG 2899 #ifdef DEBUG
2897 void ExternalFloatArrayPrint(); 2900 void ExternalFloatArrayPrint();
2898 void ExternalFloatArrayVerify(); 2901 void ExternalFloatArrayVerify();
2899 #endif // DEBUG 2902 #endif // DEBUG
2900 2903
2901 private: 2904 private:
2902 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloatArray); 2905 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloatArray);
2903 }; 2906 };
2904 2907
2905 2908
2909 // DeoptimizationInputData is a fixed array used to hold the deoptimization
2910 // data for code generated by the Hydrogen/Lithium compiler. It also
2911 // contains information about functions that were inlined. If N different
2912 // functions were inlined then first N elements of the literal array will
2913 // contain these functions.
2914 //
2915 // It can be empty.
2916 class DeoptimizationInputData: public FixedArray {
2917 public:
2918 // Layout description. Indices in the array.
2919 static const int kTranslationByteArrayIndex = 0;
2920 static const int kInlinedFunctionCountIndex = 1;
2921 static const int kLiteralArrayIndex = 2;
2922 static const int kOsrAstIdIndex = 3;
2923 static const int kOsrPcOffsetIndex = 4;
2924 static const int kFirstDeoptEntryIndex = 5;
2925
2926 // Offsets of deopt entry elements relative to the start of the entry.
2927 static const int kAstIdOffset = 0;
2928 static const int kTranslationIndexOffset = 1;
2929 static const int kArgumentsStackHeightOffset = 2;
2930 static const int kDeoptEntrySize = 3;
2931
2932 // Simple element accessors.
2933 #define DEFINE_ELEMENT_ACCESSORS(name, type) \
2934 type* name() { \
2935 return type::cast(get(k##name##Index)); \
2936 } \
2937 void Set##name(type* value) { \
2938 set(k##name##Index, value); \
2939 }
2940
2941 DEFINE_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray)
2942 DEFINE_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi)
2943 DEFINE_ELEMENT_ACCESSORS(LiteralArray, FixedArray)
2944 DEFINE_ELEMENT_ACCESSORS(OsrAstId, Smi)
2945 DEFINE_ELEMENT_ACCESSORS(OsrPcOffset, Smi)
2946
2947 // Unchecked accessor to be used during GC.
2948 FixedArray* UncheckedLiteralArray() {
2949 return reinterpret_cast<FixedArray*>(get(kLiteralArrayIndex));
2950 }
2951
2952 #undef DEFINE_ELEMENT_ACCESSORS
2953
2954 // Accessors for elements of the ith deoptimization entry.
2955 #define DEFINE_ENTRY_ACCESSORS(name, type) \
2956 type* name(int i) { \
2957 return type::cast(get(IndexForEntry(i) + k##name##Offset)); \
2958 } \
2959 void Set##name(int i, type* value) { \
2960 set(IndexForEntry(i) + k##name##Offset, value); \
2961 }
2962
2963 DEFINE_ENTRY_ACCESSORS(AstId, Smi)
2964 DEFINE_ENTRY_ACCESSORS(TranslationIndex, Smi)
2965 DEFINE_ENTRY_ACCESSORS(ArgumentsStackHeight, Smi)
2966
2967 #undef DEFINE_ENTRY_ACCESSORS
2968
2969 int DeoptCount() {
2970 return (length() - kFirstDeoptEntryIndex) / kDeoptEntrySize;
2971 }
2972
2973 // Allocates a DeoptimizationInputData.
2974 MUST_USE_RESULT static MaybeObject* Allocate(int deopt_entry_count,
2975 PretenureFlag pretenure);
2976
2977 // Casting.
2978 static inline DeoptimizationInputData* cast(Object* obj);
2979
2980 #ifdef DEBUG
2981 void DeoptimizationInputDataPrint();
2982 #endif
2983
2984 private:
2985 static int IndexForEntry(int i) {
2986 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize);
2987 }
2988
2989 static int LengthFor(int entry_count) {
2990 return IndexForEntry(entry_count);
2991 }
2992 };
2993
2994
2995 // DeoptimizationOutputData is a fixed array used to hold the deoptimization
2996 // data for code generated by the full compiler.
2997 // The format of the these objects is
2998 // [i * 2]: Ast ID for ith deoptimization.
2999 // [i * 2 + 1]: PC and state of ith deoptimization
3000 class DeoptimizationOutputData: public FixedArray {
3001 public:
3002 int DeoptPoints() { return length() / 2; }
3003 Smi* AstId(int index) { return Smi::cast(get(index * 2)); }
3004 void SetAstId(int index, Smi* id) { set(index * 2, id); }
3005 Smi* PcAndState(int index) { return Smi::cast(get(1 + index * 2)); }
3006 void SetPcAndState(int index, Smi* offset) { set(1 + index * 2, offset); }
3007
3008 static int LengthOfFixedArray(int deopt_points) {
3009 return deopt_points * 2;
3010 }
3011
3012 // Allocates a DeoptimizationOutputData.
3013 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_deopt_points,
3014 PretenureFlag pretenure);
3015
3016 // Casting.
3017 static inline DeoptimizationOutputData* cast(Object* obj);
3018
3019 #ifdef DEBUG
3020 void DeoptimizationOutputDataPrint();
3021 #endif
3022 };
3023
3024
2906 // Code describes objects with on-the-fly generated machine code. 3025 // Code describes objects with on-the-fly generated machine code.
2907 class Code: public HeapObject { 3026 class Code: public HeapObject {
2908 public: 3027 public:
2909 // Opaque data type for encapsulating code flags like kind, inline 3028 // Opaque data type for encapsulating code flags like kind, inline
2910 // cache state, and arguments count. 3029 // cache state, and arguments count.
2911 // FLAGS_MIN_VALUE and FLAGS_MAX_VALUE are specified to ensure that 3030 // FLAGS_MIN_VALUE and FLAGS_MAX_VALUE are specified to ensure that
2912 // enumeration type has correct value range (see Issue 830 for more details). 3031 // enumeration type has correct value range (see Issue 830 for more details).
2913 enum Flags { 3032 enum Flags {
2914 FLAGS_MIN_VALUE = kMinInt, 3033 FLAGS_MIN_VALUE = kMinInt,
2915 FLAGS_MAX_VALUE = kMaxInt 3034 FLAGS_MAX_VALUE = kMaxInt
2916 }; 3035 };
2917 3036
2918 enum Kind { 3037 enum Kind {
2919 FUNCTION, 3038 FUNCTION,
3039 OPTIMIZED_FUNCTION,
2920 STUB, 3040 STUB,
2921 BUILTIN, 3041 BUILTIN,
2922 LOAD_IC, 3042 LOAD_IC,
2923 KEYED_LOAD_IC, 3043 KEYED_LOAD_IC,
2924 CALL_IC, 3044 CALL_IC,
2925 KEYED_CALL_IC, 3045 KEYED_CALL_IC,
2926 STORE_IC, 3046 STORE_IC,
2927 KEYED_STORE_IC, 3047 KEYED_STORE_IC,
2928 BINARY_OP_IC, 3048 BINARY_OP_IC,
3049 TYPE_RECORDING_BINARY_OP_IC,
3050 COMPARE_IC,
2929 // No more than 16 kinds. The value currently encoded in four bits in 3051 // No more than 16 kinds. The value currently encoded in four bits in
2930 // Flags. 3052 // Flags.
2931 3053
2932 // Pseudo-kinds. 3054 // Pseudo-kinds.
2933 REGEXP = BUILTIN, 3055 REGEXP = BUILTIN,
2934 FIRST_IC_KIND = LOAD_IC, 3056 FIRST_IC_KIND = LOAD_IC,
2935 LAST_IC_KIND = BINARY_OP_IC 3057 LAST_IC_KIND = COMPARE_IC
2936 }; 3058 };
2937 3059
2938 enum { 3060 enum {
2939 NUMBER_OF_KINDS = LAST_IC_KIND + 1 3061 NUMBER_OF_KINDS = LAST_IC_KIND + 1
2940 }; 3062 };
2941 3063
2942 #ifdef ENABLE_DISASSEMBLER 3064 #ifdef ENABLE_DISASSEMBLER
2943 // Printing 3065 // Printing
2944 static const char* Kind2String(Kind kind); 3066 static const char* Kind2String(Kind kind);
2945 static const char* ICState2String(InlineCacheState state); 3067 static const char* ICState2String(InlineCacheState state);
2946 static const char* PropertyType2String(PropertyType type); 3068 static const char* PropertyType2String(PropertyType type);
2947 void Disassemble(const char* name); 3069 void Disassemble(const char* name);
2948 #endif // ENABLE_DISASSEMBLER 3070 #endif // ENABLE_DISASSEMBLER
2949 3071
2950 // [instruction_size]: Size of the native instructions 3072 // [instruction_size]: Size of the native instructions
2951 inline int instruction_size(); 3073 inline int instruction_size();
2952 inline void set_instruction_size(int value); 3074 inline void set_instruction_size(int value);
2953 3075
2954 // [relocation_info]: Code relocation information 3076 // [relocation_info]: Code relocation information
2955 DECL_ACCESSORS(relocation_info, ByteArray) 3077 DECL_ACCESSORS(relocation_info, ByteArray)
3078 void InvalidateRelocation();
2956 3079
2957 // Unchecked accessor to be used during GC. 3080 // [deoptimization_data]: Array containing data for deopt.
3081 DECL_ACCESSORS(deoptimization_data, FixedArray)
3082
3083 // Unchecked accessors to be used during GC.
2958 inline ByteArray* unchecked_relocation_info(); 3084 inline ByteArray* unchecked_relocation_info();
3085 inline FixedArray* unchecked_deoptimization_data();
2959 3086
2960 inline int relocation_size(); 3087 inline int relocation_size();
2961 3088
2962 // [flags]: Various code flags. 3089 // [flags]: Various code flags.
2963 inline Flags flags(); 3090 inline Flags flags();
2964 inline void set_flags(Flags flags); 3091 inline void set_flags(Flags flags);
2965 3092
2966 // [flags]: Access to specific code flags. 3093 // [flags]: Access to specific code flags.
2967 inline Kind kind(); 3094 inline Kind kind();
2968 inline InlineCacheState ic_state(); // Only valid for IC stubs. 3095 inline InlineCacheState ic_state(); // Only valid for IC stubs.
2969 inline InLoopFlag ic_in_loop(); // Only valid for IC stubs. 3096 inline InLoopFlag ic_in_loop(); // Only valid for IC stubs.
2970 inline PropertyType type(); // Only valid for monomorphic IC stubs. 3097 inline PropertyType type(); // Only valid for monomorphic IC stubs.
2971 inline int arguments_count(); // Only valid for call IC stubs. 3098 inline int arguments_count(); // Only valid for call IC stubs.
2972 3099
2973 // Testers for IC stub kinds. 3100 // Testers for IC stub kinds.
2974 inline bool is_inline_cache_stub(); 3101 inline bool is_inline_cache_stub();
2975 inline bool is_load_stub() { return kind() == LOAD_IC; } 3102 inline bool is_load_stub() { return kind() == LOAD_IC; }
2976 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } 3103 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; }
2977 inline bool is_store_stub() { return kind() == STORE_IC; } 3104 inline bool is_store_stub() { return kind() == STORE_IC; }
2978 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } 3105 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; }
2979 inline bool is_call_stub() { return kind() == CALL_IC; } 3106 inline bool is_call_stub() { return kind() == CALL_IC; }
2980 inline bool is_keyed_call_stub() { return kind() == KEYED_CALL_IC; } 3107 inline bool is_keyed_call_stub() { return kind() == KEYED_CALL_IC; }
3108 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; }
3109 inline bool is_type_recording_binary_op_stub() {
3110 return kind() == TYPE_RECORDING_BINARY_OP_IC;
3111 }
3112 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; }
2981 3113
2982 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. 3114 // [major_key]: For kind STUB or BINARY_OP_IC, the major key.
2983 inline int major_key(); 3115 inline int major_key();
2984 inline void set_major_key(int major); 3116 inline void set_major_key(int value);
3117
3118 // [optimizable]: For FUNCTION kind, tells if it is optimizable.
3119 inline bool optimizable();
3120 inline void set_optimizable(bool value);
3121
3122 // [has_deoptimization_support]: For FUNCTION kind, tells if it has
3123 // deoptimization support.
3124 inline bool has_deoptimization_support();
3125 inline void set_has_deoptimization_support(bool value);
3126
3127 // [allow_osr_at_loop_nesting_level]: For FUNCTION kind, tells for
3128 // how long the function has been marked for OSR and therefore which
3129 // level of loop nesting we are willing to do on-stack replacement
3130 // for.
3131 inline void set_allow_osr_at_loop_nesting_level(int level);
3132 inline int allow_osr_at_loop_nesting_level();
3133
3134 // [stack_slots]: For kind OPTIMIZED_FUNCTION, the number of stack slots
3135 // reserved in the code prologue.
3136 inline unsigned stack_slots();
3137 inline void set_stack_slots(unsigned slots);
3138
3139 // [safepoint_table_start]: For kind OPTIMIZED_CODE, the offset in
3140 // the instruction stream where the safepoint table starts.
3141 inline unsigned safepoint_table_start();
3142 inline void set_safepoint_table_start(unsigned offset);
3143
3144 // [stack_check_table_start]: For kind FUNCTION, the offset in the
3145 // instruction stream where the stack check table starts.
3146 inline unsigned stack_check_table_start();
3147 inline void set_stack_check_table_start(unsigned offset);
3148
3149 // [check type]: For kind CALL_IC, tells how to check if the
3150 // receiver is valid for the given call.
3151 inline CheckType check_type();
3152 inline void set_check_type(CheckType value);
3153
3154 // [binary op type]: For all BINARY_OP_IC.
3155 inline byte binary_op_type();
3156 inline void set_binary_op_type(byte value);
3157
3158 // [type-recording binary op type]: For all TYPE_RECORDING_BINARY_OP_IC.
3159 inline byte type_recording_binary_op_type();
3160 inline void set_type_recording_binary_op_type(byte value);
3161 inline byte type_recording_binary_op_result_type();
3162 inline void set_type_recording_binary_op_result_type(byte value);
3163
3164 // [compare state]: For kind compare IC stubs, tells what state the
3165 // stub is in.
3166 inline byte compare_state();
3167 inline void set_compare_state(byte value);
3168
3169 // Get the safepoint entry for the given pc. Returns NULL for
3170 // non-safepoint pcs.
3171 uint8_t* GetSafepointEntry(Address pc);
3172
3173 // Mark this code object as not having a stack check table. Assumes kind
3174 // is FUNCTION.
3175 void SetNoStackCheckTable();
3176
3177 // Find the first map in an IC stub.
3178 Map* FindFirstMap();
2985 3179
2986 // Flags operations. 3180 // Flags operations.
2987 static inline Flags ComputeFlags(Kind kind, 3181 static inline Flags ComputeFlags(Kind kind,
2988 InLoopFlag in_loop = NOT_IN_LOOP, 3182 InLoopFlag in_loop = NOT_IN_LOOP,
2989 InlineCacheState ic_state = UNINITIALIZED, 3183 InlineCacheState ic_state = UNINITIALIZED,
2990 PropertyType type = NORMAL, 3184 PropertyType type = NORMAL,
2991 int argc = -1, 3185 int argc = -1,
2992 InlineCacheHolderFlag holder = OWN_MAP); 3186 InlineCacheHolderFlag holder = OWN_MAP);
2993 3187
2994 static inline Flags ComputeMonomorphicFlags( 3188 static inline Flags ComputeMonomorphicFlags(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3062 // Dispatched behavior. 3256 // Dispatched behavior.
3063 int CodeSize() { return SizeFor(body_size()); } 3257 int CodeSize() { return SizeFor(body_size()); }
3064 inline void CodeIterateBody(ObjectVisitor* v); 3258 inline void CodeIterateBody(ObjectVisitor* v);
3065 3259
3066 template<typename StaticVisitor> 3260 template<typename StaticVisitor>
3067 inline void CodeIterateBody(Heap* heap); 3261 inline void CodeIterateBody(Heap* heap);
3068 #ifdef DEBUG 3262 #ifdef DEBUG
3069 void CodePrint(); 3263 void CodePrint();
3070 void CodeVerify(); 3264 void CodeVerify();
3071 #endif 3265 #endif
3266
3267 // Max loop nesting marker used to postpose OSR. We don't take loop
3268 // nesting that is deeper than 5 levels into account.
3269 static const int kMaxLoopNestingMarker = 6;
3270
3072 // Layout description. 3271 // Layout description.
3073 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; 3272 static const int kInstructionSizeOffset = HeapObject::kHeaderSize;
3074 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; 3273 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize;
3075 static const int kFlagsOffset = kRelocationInfoOffset + kPointerSize; 3274 static const int kDeoptimizationDataOffset =
3275 kRelocationInfoOffset + kPointerSize;
3276 static const int kFlagsOffset = kDeoptimizationDataOffset + kPointerSize;
3076 static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize; 3277 static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize;
3278
3279 static const int kKindSpecificFlagsSize = 2 * kIntSize;
3280
3281 static const int kHeaderPaddingStart = kKindSpecificFlagsOffset +
3282 kKindSpecificFlagsSize;
3283
3077 // Add padding to align the instruction start following right after 3284 // Add padding to align the instruction start following right after
3078 // the Code object header. 3285 // the Code object header.
3079 static const int kHeaderSize = 3286 static const int kHeaderSize =
3080 CODE_POINTER_ALIGN(kKindSpecificFlagsOffset + kIntSize); 3287 (kHeaderPaddingStart + kCodeAlignmentMask) & ~kCodeAlignmentMask;
3081 3288
3082 // Byte offsets within kKindSpecificFlagsOffset. 3289 // Byte offsets within kKindSpecificFlagsOffset.
3083 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset + 1; 3290 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset;
3291 static const int kOptimizableOffset = kKindSpecificFlagsOffset;
3292 static const int kStackSlotsOffset = kKindSpecificFlagsOffset;
3293 static const int kCheckTypeOffset = kKindSpecificFlagsOffset;
3294
3295 static const int kCompareStateOffset = kStubMajorKeyOffset + 1;
3296 static const int kBinaryOpTypeOffset = kStubMajorKeyOffset + 1;
3297 static const int kHasDeoptimizationSupportOffset = kOptimizableOffset + 1;
3298
3299 static const int kBinaryOpReturnTypeOffset = kBinaryOpTypeOffset + 1;
3300 static const int kAllowOSRAtLoopNestingLevelOffset =
3301 kHasDeoptimizationSupportOffset + 1;
3302
3303 static const int kSafepointTableStartOffset = kStackSlotsOffset + kIntSize;
3304 static const int kStackCheckTableStartOffset = kStackSlotsOffset + kIntSize;
3084 3305
3085 // Flags layout. 3306 // Flags layout.
3086 static const int kFlagsICStateShift = 0; 3307 static const int kFlagsICStateShift = 0;
3087 static const int kFlagsICInLoopShift = 3; 3308 static const int kFlagsICInLoopShift = 3;
3088 static const int kFlagsTypeShift = 4; 3309 static const int kFlagsTypeShift = 4;
3089 static const int kFlagsKindShift = 7; 3310 static const int kFlagsKindShift = 7;
3090 static const int kFlagsICHolderShift = 11; 3311 static const int kFlagsICHolderShift = 11;
3091 static const int kFlagsArgumentsCountShift = 12; 3312 static const int kFlagsArgumentsCountShift = 12;
3092 3313
3093 static const int kFlagsICStateMask = 0x00000007; // 00000000111 3314 static const int kFlagsICStateMask = 0x00000007; // 00000000111
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3249 DECL_ACCESSORS(constructor, Object) 3470 DECL_ACCESSORS(constructor, Object)
3250 3471
3251 inline JSFunction* unchecked_constructor(); 3472 inline JSFunction* unchecked_constructor();
3252 3473
3253 // [instance descriptors]: describes the object. 3474 // [instance descriptors]: describes the object.
3254 DECL_ACCESSORS(instance_descriptors, DescriptorArray) 3475 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
3255 3476
3256 // [stub cache]: contains stubs compiled for this map. 3477 // [stub cache]: contains stubs compiled for this map.
3257 DECL_ACCESSORS(code_cache, Object) 3478 DECL_ACCESSORS(code_cache, Object)
3258 3479
3480 // Lookup in the map's instance descriptors and fill out the result
3481 // with the given holder if the name is found. The holder may be
3482 // NULL when this function is used from the compiler.
3483 void LookupInDescriptors(JSObject* holder,
3484 String* name,
3485 LookupResult* result);
3486
3259 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); 3487 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
3260 3488
3261 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, 3489 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode,
3262 NormalizedMapSharingMode sharing); 3490 NormalizedMapSharingMode sharing);
3263 3491
3264 // Returns a copy of the map, with all transitions dropped from the 3492 // Returns a copy of the map, with all transitions dropped from the
3265 // instance descriptors. 3493 // instance descriptors.
3266 MUST_USE_RESULT MaybeObject* CopyDropTransitions(); 3494 MUST_USE_RESULT MaybeObject* CopyDropTransitions();
3267 3495
3268 // Returns this map if it has the fast elements bit set, otherwise 3496 // Returns this map if it has the fast elements bit set, otherwise
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
3501 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; 3729 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize;
3502 static const int kEvalFrominstructionsOffsetOffset = 3730 static const int kEvalFrominstructionsOffsetOffset =
3503 kEvalFromSharedOffset + kPointerSize; 3731 kEvalFromSharedOffset + kPointerSize;
3504 static const int kSize = kEvalFrominstructionsOffsetOffset + kPointerSize; 3732 static const int kSize = kEvalFrominstructionsOffsetOffset + kPointerSize;
3505 3733
3506 private: 3734 private:
3507 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); 3735 DISALLOW_IMPLICIT_CONSTRUCTORS(Script);
3508 }; 3736 };
3509 3737
3510 3738
3739 enum MathFunctionId {
3740 kNotSpecialMathFunction = 0,
3741 // These numbers must be kept in sync with the ones in math.js.
3742 kMathFloor = 1,
3743 kMathRound = 2,
3744 kMathCeil = 3,
3745 kMathAbs = 4,
3746 kMathLog = 5,
3747 kMathSin = 6,
3748 kMathCos = 7,
3749 kMathTan = 8,
3750 kMathASin = 9,
3751 kMathACos = 0xa,
3752 kMathATan = 0xb,
3753 kMathExp = 0xc,
3754 kMathSqrt = 0xd
3755 };
3756
3757
3511 // SharedFunctionInfo describes the JSFunction information that can be 3758 // SharedFunctionInfo describes the JSFunction information that can be
3512 // shared by multiple instances of the function. 3759 // shared by multiple instances of the function.
3513 class SharedFunctionInfo: public HeapObject { 3760 class SharedFunctionInfo: public HeapObject {
3514 public: 3761 public:
3515 // [name]: Function name. 3762 // [name]: Function name.
3516 DECL_ACCESSORS(name, Object) 3763 DECL_ACCESSORS(name, Object)
3517 3764
3518 // [code]: Function code. 3765 // [code]: Function code.
3519 DECL_ACCESSORS(code, Code) 3766 DECL_ACCESSORS(code, Code)
3520 3767
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3702 3949
3703 // Is this function a top-level function (scripts, evals). 3950 // Is this function a top-level function (scripts, evals).
3704 inline bool is_toplevel(); 3951 inline bool is_toplevel();
3705 inline void set_is_toplevel(bool value); 3952 inline void set_is_toplevel(bool value);
3706 3953
3707 // Bit field containing various information collected by the compiler to 3954 // Bit field containing various information collected by the compiler to
3708 // drive optimization. 3955 // drive optimization.
3709 inline int compiler_hints(); 3956 inline int compiler_hints();
3710 inline void set_compiler_hints(int value); 3957 inline void set_compiler_hints(int value);
3711 3958
3959 // A counter used to determine when to stress the deoptimizer with a
3960 // deopt.
3961 inline Smi* deopt_counter();
3962 inline void set_deopt_counter(Smi* counter);
3963
3712 // Add information on assignments of the form this.x = ...; 3964 // Add information on assignments of the form this.x = ...;
3713 void SetThisPropertyAssignmentsInfo( 3965 void SetThisPropertyAssignmentsInfo(
3714 bool has_only_simple_this_property_assignments, 3966 bool has_only_simple_this_property_assignments,
3715 FixedArray* this_property_assignments); 3967 FixedArray* this_property_assignments);
3716 3968
3717 // Clear information on assignments of the form this.x = ...; 3969 // Clear information on assignments of the form this.x = ...;
3718 void ClearThisPropertyAssignmentsInfo(); 3970 void ClearThisPropertyAssignmentsInfo();
3719 3971
3720 // Indicate that this function only consists of assignments of the form 3972 // Indicate that this function only consists of assignments of the form
3721 // this.x = y; where y is either a constant or refers to an argument. 3973 // this.x = y; where y is either a constant or refers to an argument.
3722 inline bool has_only_simple_this_property_assignments(); 3974 inline bool has_only_simple_this_property_assignments();
3723 3975
3724 inline bool try_full_codegen(); 3976 inline bool try_full_codegen();
3725 inline void set_try_full_codegen(bool flag); 3977 inline void set_try_full_codegen(bool flag);
3726 3978
3727 // Indicates if this function can be lazy compiled. 3979 // Indicates if this function can be lazy compiled.
3728 // This is used to determine if we can safely flush code from a function 3980 // This is used to determine if we can safely flush code from a function
3729 // when doing GC if we expect that the function will no longer be used. 3981 // when doing GC if we expect that the function will no longer be used.
3730 inline bool allows_lazy_compilation(); 3982 inline bool allows_lazy_compilation();
3731 inline void set_allows_lazy_compilation(bool flag); 3983 inline void set_allows_lazy_compilation(bool flag);
3732 3984
3733 // Indicates how many full GCs this function has survived with assigned 3985 // Indicates how many full GCs this function has survived with assigned
3734 // code object. Used to determine when it is relatively safe to flush 3986 // code object. Used to determine when it is relatively safe to flush
3735 // this code object and replace it with lazy compilation stub. 3987 // this code object and replace it with lazy compilation stub.
3736 // Age is reset when GC notices that the code object is referenced 3988 // Age is reset when GC notices that the code object is referenced
3737 // from the stack or compilation cache. 3989 // from the stack or compilation cache.
3738 inline int code_age(); 3990 inline int code_age();
3739 inline void set_code_age(int age); 3991 inline void set_code_age(int age);
3740 3992
3993 // Indicates whether optimizations have been disabled for this
3994 // shared function info. If a function is repeatedly optimized or if
3995 // we cannot optimize the function we disable optimization to avoid
3996 // spending time attempting to optimize it again.
3997 inline bool optimization_disabled();
3998 inline void set_optimization_disabled(bool value);
3999
4000 // Indicates whether or not the code in the shared function support
4001 // deoptimization.
4002 inline bool has_deoptimization_support();
4003
4004 // Enable deoptimization support through recompiled code.
4005 void EnableDeoptimizationSupport(Code* recompiled);
4006
4007 // Lookup the bailout ID and ASSERT that it exists in the non-optimized
4008 // code, returns whether it asserted (i.e., always true if assertions are
4009 // disabled).
4010 bool VerifyBailoutId(int id);
3741 4011
3742 // Check whether a inlined constructor can be generated with the given 4012 // Check whether a inlined constructor can be generated with the given
3743 // prototype. 4013 // prototype.
3744 bool CanGenerateInlineConstructor(Object* prototype); 4014 bool CanGenerateInlineConstructor(Object* prototype);
3745 4015
3746 // Prevents further attempts to generate inline constructors. 4016 // Prevents further attempts to generate inline constructors.
3747 // To be called if generation failed for any reason. 4017 // To be called if generation failed for any reason.
3748 void ForbidInlineConstructor(); 4018 void ForbidInlineConstructor();
3749 4019
3750 // For functions which only contains this property assignments this provides 4020 // For functions which only contains this property assignments this provides
3751 // access to the names for the properties assigned. 4021 // access to the names for the properties assigned.
3752 DECL_ACCESSORS(this_property_assignments, Object) 4022 DECL_ACCESSORS(this_property_assignments, Object)
3753 inline int this_property_assignments_count(); 4023 inline int this_property_assignments_count();
3754 inline void set_this_property_assignments_count(int value); 4024 inline void set_this_property_assignments_count(int value);
3755 String* GetThisPropertyAssignmentName(int index); 4025 String* GetThisPropertyAssignmentName(int index);
3756 bool IsThisPropertyAssignmentArgument(int index); 4026 bool IsThisPropertyAssignmentArgument(int index);
3757 int GetThisPropertyAssignmentArgument(int index); 4027 int GetThisPropertyAssignmentArgument(int index);
3758 Object* GetThisPropertyAssignmentConstant(int index); 4028 Object* GetThisPropertyAssignmentConstant(int index);
3759 4029
3760 // [source code]: Source code for the function. 4030 // [source code]: Source code for the function.
3761 bool HasSourceCode(); 4031 bool HasSourceCode();
3762 Object* GetSourceCode(); 4032 Object* GetSourceCode();
3763 4033
4034 inline int opt_count();
4035 inline void set_opt_count(int opt_count);
4036
4037 // Source size of this function.
4038 int SourceSize();
4039
3764 // Calculate the instance size. 4040 // Calculate the instance size.
3765 int CalculateInstanceSize(); 4041 int CalculateInstanceSize();
3766 4042
3767 // Calculate the number of in-object properties. 4043 // Calculate the number of in-object properties.
3768 int CalculateInObjectProperties(); 4044 int CalculateInObjectProperties();
3769 4045
3770 // Dispatched behavior. 4046 // Dispatched behavior.
3771 // Set max_length to -1 for unlimited length. 4047 // Set max_length to -1 for unlimited length.
3772 void SourceCodePrint(StringStream* accumulator, int max_length); 4048 void SourceCodePrint(StringStream* accumulator, int max_length);
3773 #ifdef DEBUG 4049 #ifdef DEBUG
(...skipping 17 matching lines...) Expand all
3791 kConstructStubOffset + kPointerSize; 4067 kConstructStubOffset + kPointerSize;
3792 static const int kFunctionDataOffset = 4068 static const int kFunctionDataOffset =
3793 kInstanceClassNameOffset + kPointerSize; 4069 kInstanceClassNameOffset + kPointerSize;
3794 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; 4070 static const int kScriptOffset = kFunctionDataOffset + kPointerSize;
3795 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; 4071 static const int kDebugInfoOffset = kScriptOffset + kPointerSize;
3796 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; 4072 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize;
3797 static const int kInitialMapOffset = 4073 static const int kInitialMapOffset =
3798 kInferredNameOffset + kPointerSize; 4074 kInferredNameOffset + kPointerSize;
3799 static const int kThisPropertyAssignmentsOffset = 4075 static const int kThisPropertyAssignmentsOffset =
3800 kInitialMapOffset + kPointerSize; 4076 kInitialMapOffset + kPointerSize;
4077 static const int kDeoptCounterOffset =
4078 kThisPropertyAssignmentsOffset + kPointerSize;
3801 #if V8_HOST_ARCH_32_BIT 4079 #if V8_HOST_ARCH_32_BIT
3802 // Smi fields. 4080 // Smi fields.
3803 static const int kLengthOffset = 4081 static const int kLengthOffset =
3804 kThisPropertyAssignmentsOffset + kPointerSize; 4082 kDeoptCounterOffset + kPointerSize;
3805 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; 4083 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize;
3806 static const int kExpectedNofPropertiesOffset = 4084 static const int kExpectedNofPropertiesOffset =
3807 kFormalParameterCountOffset + kPointerSize; 4085 kFormalParameterCountOffset + kPointerSize;
3808 static const int kNumLiteralsOffset = 4086 static const int kNumLiteralsOffset =
3809 kExpectedNofPropertiesOffset + kPointerSize; 4087 kExpectedNofPropertiesOffset + kPointerSize;
3810 static const int kStartPositionAndTypeOffset = 4088 static const int kStartPositionAndTypeOffset =
3811 kNumLiteralsOffset + kPointerSize; 4089 kNumLiteralsOffset + kPointerSize;
3812 static const int kEndPositionOffset = 4090 static const int kEndPositionOffset =
3813 kStartPositionAndTypeOffset + kPointerSize; 4091 kStartPositionAndTypeOffset + kPointerSize;
3814 static const int kFunctionTokenPositionOffset = 4092 static const int kFunctionTokenPositionOffset =
3815 kEndPositionOffset + kPointerSize; 4093 kEndPositionOffset + kPointerSize;
3816 static const int kCompilerHintsOffset = 4094 static const int kCompilerHintsOffset =
3817 kFunctionTokenPositionOffset + kPointerSize; 4095 kFunctionTokenPositionOffset + kPointerSize;
3818 static const int kThisPropertyAssignmentsCountOffset = 4096 static const int kThisPropertyAssignmentsCountOffset =
3819 kCompilerHintsOffset + kPointerSize; 4097 kCompilerHintsOffset + kPointerSize;
4098 static const int kOptCountOffset =
4099 kThisPropertyAssignmentsCountOffset + kPointerSize;
3820 // Total size. 4100 // Total size.
3821 static const int kSize = kThisPropertyAssignmentsCountOffset + kPointerSize; 4101 static const int kSize = kOptCountOffset + kPointerSize;
3822 #else 4102 #else
3823 // The only reason to use smi fields instead of int fields 4103 // The only reason to use smi fields instead of int fields
3824 // is to allow iteration without maps decoding during 4104 // is to allow iteration without maps decoding during
3825 // garbage collections. 4105 // garbage collections.
3826 // To avoid wasting space on 64-bit architectures we use 4106 // To avoid wasting space on 64-bit architectures we use
3827 // the following trick: we group integer fields into pairs 4107 // the following trick: we group integer fields into pairs
3828 // First integer in each pair is shifted left by 1. 4108 // First integer in each pair is shifted left by 1.
3829 // By doing this we guarantee that LSB of each kPointerSize aligned 4109 // By doing this we guarantee that LSB of each kPointerSize aligned
3830 // word is not set and thus this word cannot be treated as pointer 4110 // word is not set and thus this word cannot be treated as pointer
3831 // to HeapObject during old space traversal. 4111 // to HeapObject during old space traversal.
3832 static const int kLengthOffset = 4112 static const int kLengthOffset =
3833 kThisPropertyAssignmentsOffset + kPointerSize; 4113 kDeoptCounterOffset + kPointerSize;
3834 static const int kFormalParameterCountOffset = 4114 static const int kFormalParameterCountOffset =
3835 kLengthOffset + kIntSize; 4115 kLengthOffset + kIntSize;
3836 4116
3837 static const int kExpectedNofPropertiesOffset = 4117 static const int kExpectedNofPropertiesOffset =
3838 kFormalParameterCountOffset + kIntSize; 4118 kFormalParameterCountOffset + kIntSize;
3839 static const int kNumLiteralsOffset = 4119 static const int kNumLiteralsOffset =
3840 kExpectedNofPropertiesOffset + kIntSize; 4120 kExpectedNofPropertiesOffset + kIntSize;
3841 4121
3842 static const int kEndPositionOffset = 4122 static const int kEndPositionOffset =
3843 kNumLiteralsOffset + kIntSize; 4123 kNumLiteralsOffset + kIntSize;
3844 static const int kStartPositionAndTypeOffset = 4124 static const int kStartPositionAndTypeOffset =
3845 kEndPositionOffset + kIntSize; 4125 kEndPositionOffset + kIntSize;
3846 4126
3847 static const int kFunctionTokenPositionOffset = 4127 static const int kFunctionTokenPositionOffset =
3848 kStartPositionAndTypeOffset + kIntSize; 4128 kStartPositionAndTypeOffset + kIntSize;
3849 static const int kCompilerHintsOffset = 4129 static const int kCompilerHintsOffset =
3850 kFunctionTokenPositionOffset + kIntSize; 4130 kFunctionTokenPositionOffset + kIntSize;
3851 4131
3852 static const int kThisPropertyAssignmentsCountOffset = 4132 static const int kThisPropertyAssignmentsCountOffset =
3853 kCompilerHintsOffset + kIntSize; 4133 kCompilerHintsOffset + kIntSize;
4134 static const int kOptCountOffset =
4135 kThisPropertyAssignmentsCountOffset + kIntSize;
3854 4136
3855 // Total size. 4137 // Total size.
3856 static const int kSize = kThisPropertyAssignmentsCountOffset + kIntSize; 4138 static const int kSize = kOptCountOffset + kIntSize;
3857 4139
3858 #endif 4140 #endif
3859 4141
3860 // The construction counter for inobject slack tracking is stored in the 4142 // The construction counter for inobject slack tracking is stored in the
3861 // most significant byte of compiler_hints which is otherwise unused. 4143 // most significant byte of compiler_hints which is otherwise unused.
3862 // Its offset depends on the endian-ness of the architecture. 4144 // Its offset depends on the endian-ness of the architecture.
3863 #if __BYTE_ORDER == __LITTLE_ENDIAN 4145 #if __BYTE_ORDER == __LITTLE_ENDIAN
3864 static const int kConstructionCountOffset = kCompilerHintsOffset + 3; 4146 static const int kConstructionCountOffset = kCompilerHintsOffset + 3;
3865 #elif __BYTE_ORDER == __BIG_ENDIAN 4147 #elif __BYTE_ORDER == __BIG_ENDIAN
3866 static const int kConstructionCountOffset = kCompilerHintsOffset + 0; 4148 static const int kConstructionCountOffset = kCompilerHintsOffset + 0;
3867 #else 4149 #else
3868 #error Unknown byte ordering 4150 #error Unknown byte ordering
3869 #endif 4151 #endif
3870 4152
3871 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); 4153 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize);
3872 4154
4155 // Get/set a special tag on the functions from math.js so we can inline
4156 // efficient versions of them in the code.
4157 inline MathFunctionId math_function_id();
4158 inline void set_math_function_id(int id);
4159 static inline int max_math_id_number() { return kMathFunctionMask; }
4160
3873 typedef FixedBodyDescriptor<kNameOffset, 4161 typedef FixedBodyDescriptor<kNameOffset,
3874 kThisPropertyAssignmentsOffset + kPointerSize, 4162 kThisPropertyAssignmentsOffset + kPointerSize,
3875 kSize> BodyDescriptor; 4163 kSize> BodyDescriptor;
3876 4164
3877 private: 4165 private:
3878 // Bit positions in start_position_and_type. 4166 // Bit positions in start_position_and_type.
3879 // The source code start position is in the 30 most significant bits of 4167 // The source code start position is in the 30 most significant bits of
3880 // the start_position_and_type field. 4168 // the start_position_and_type field.
3881 static const int kIsExpressionBit = 0; 4169 static const int kIsExpressionBit = 0;
3882 static const int kIsTopLevelBit = 1; 4170 static const int kIsTopLevelBit = 1;
3883 static const int kStartPositionShift = 2; 4171 static const int kStartPositionShift = 2;
3884 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); 4172 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1);
3885 4173
3886 // Bit positions in compiler_hints. 4174 // Bit positions in compiler_hints.
3887 static const int kHasOnlySimpleThisPropertyAssignments = 0; 4175 static const int kHasOnlySimpleThisPropertyAssignments = 0;
3888 static const int kTryFullCodegen = 1; 4176 static const int kTryFullCodegen = 1;
3889 static const int kAllowLazyCompilation = 2; 4177 static const int kAllowLazyCompilation = 2;
3890 static const int kLiveObjectsMayExist = 3; 4178 static const int kMathFunctionShift = 3;
3891 static const int kCodeAgeShift = 4; 4179 static const int kMathFunctionMask = 0xf;
3892 static const int kCodeAgeMask = 7; 4180 static const int kLiveObjectsMayExist = 7;
4181 static const int kCodeAgeShift = 8;
4182 static const int kCodeAgeMask = 0x7;
4183 static const int kOptimizationDisabled = 11;
3893 4184
3894 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); 4185 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo);
3895 }; 4186 };
3896 4187
3897 4188
3898 // JSFunction describes JavaScript functions. 4189 // JSFunction describes JavaScript functions.
3899 class JSFunction: public JSObject { 4190 class JSFunction: public JSObject {
3900 public: 4191 public:
3901 // [prototype_or_initial_map]: 4192 // [prototype_or_initial_map]:
3902 DECL_ACCESSORS(prototype_or_initial_map, Object) 4193 DECL_ACCESSORS(prototype_or_initial_map, Object)
3903 4194
3904 // [shared_function_info]: The information about the function that 4195 // [shared_function_info]: The information about the function that
3905 // can be shared by instances. 4196 // can be shared by instances.
3906 DECL_ACCESSORS(shared, SharedFunctionInfo) 4197 DECL_ACCESSORS(shared, SharedFunctionInfo)
3907 4198
3908 inline SharedFunctionInfo* unchecked_shared(); 4199 inline SharedFunctionInfo* unchecked_shared();
3909 4200
3910 // [context]: The context for this function. 4201 // [context]: The context for this function.
3911 inline Context* context(); 4202 inline Context* context();
3912 inline Object* unchecked_context(); 4203 inline Object* unchecked_context();
3913 inline void set_context(Object* context); 4204 inline void set_context(Object* context);
3914 4205
3915 // [code]: The generated code object for this function. Executed 4206 // [code]: The generated code object for this function. Executed
3916 // when the function is invoked, e.g. foo() or new foo(). See 4207 // when the function is invoked, e.g. foo() or new foo(). See
3917 // [[Call]] and [[Construct]] description in ECMA-262, section 4208 // [[Call]] and [[Construct]] description in ECMA-262, section
3918 // 8.6.2, page 27. 4209 // 8.6.2, page 27.
3919 inline Code* code(); 4210 inline Code* code();
3920 inline void set_code(Code* value); 4211 inline void set_code(Code* code);
4212 inline void ReplaceCode(Code* code);
3921 4213
3922 inline Code* unchecked_code(); 4214 inline Code* unchecked_code();
3923 4215
3924 // Tells whether this function is builtin. 4216 // Tells whether this function is builtin.
3925 inline bool IsBuiltin(); 4217 inline bool IsBuiltin();
3926 4218
4219 // Tells whether or not the function needs arguments adaption.
4220 inline bool NeedsArgumentsAdaption();
4221
4222 // Tells whether or not this function has been optimized.
4223 inline bool IsOptimized();
4224
4225 // Mark this function for lazy recompilation. The function will be
4226 // recompiled the next time it is executed.
4227 void MarkForLazyRecompilation();
4228
4229 // Tells whether or not the function is already marked for lazy
4230 // recompilation.
4231 inline bool IsMarkedForLazyRecompilation();
4232
4233 // Compute a hash code for the source code of this function.
4234 uint32_t SourceHash();
4235
4236 // Check whether or not this function is inlineable.
4237 bool IsInlineable();
4238
3927 // [literals]: Fixed array holding the materialized literals. 4239 // [literals]: Fixed array holding the materialized literals.
3928 // 4240 //
3929 // If the function contains object, regexp or array literals, the 4241 // If the function contains object, regexp or array literals, the
3930 // literals array prefix contains the object, regexp, and array 4242 // literals array prefix contains the object, regexp, and array
3931 // function to be used when creating these literals. This is 4243 // function to be used when creating these literals. This is
3932 // necessary so that we do not dynamically lookup the object, regexp 4244 // necessary so that we do not dynamically lookup the object, regexp
3933 // or array functions. Performing a dynamic lookup, we might end up 4245 // or array functions. Performing a dynamic lookup, we might end up
3934 // using the functions from a new context that we should not have 4246 // using the functions from a new context that we should not have
3935 // access to. 4247 // access to.
3936 DECL_ACCESSORS(literals, FixedArray) 4248 DECL_ACCESSORS(literals, FixedArray)
(...skipping 26 matching lines...) Expand all
3963 // not have one. Note that this method does not copy the initial map 4275 // not have one. Note that this method does not copy the initial map
3964 // if it has one already, but simply replaces it with the new value. 4276 // if it has one already, but simply replaces it with the new value.
3965 // Instances created afterwards will have a map whose [[class]] is 4277 // Instances created afterwards will have a map whose [[class]] is
3966 // set to 'value', but there is no guarantees on instances created 4278 // set to 'value', but there is no guarantees on instances created
3967 // before. 4279 // before.
3968 Object* SetInstanceClassName(String* name); 4280 Object* SetInstanceClassName(String* name);
3969 4281
3970 // Returns if this function has been compiled to native code yet. 4282 // Returns if this function has been compiled to native code yet.
3971 inline bool is_compiled(); 4283 inline bool is_compiled();
3972 4284
4285 // [next_function_link]: Field for linking functions. This list is treated as
4286 // a weak list by the GC.
4287 DECL_ACCESSORS(next_function_link, Object)
4288
4289 // Prints the name of the function using PrintF.
4290 void PrintName();
4291
3973 // Casting. 4292 // Casting.
3974 static inline JSFunction* cast(Object* obj); 4293 static inline JSFunction* cast(Object* obj);
3975 4294
3976 // Iterates the objects, including code objects indirectly referenced 4295 // Iterates the objects, including code objects indirectly referenced
3977 // through pointers to the first instruction in the code object. 4296 // through pointers to the first instruction in the code object.
3978 void JSFunctionIterateBody(int object_size, ObjectVisitor* v); 4297 void JSFunctionIterateBody(int object_size, ObjectVisitor* v);
3979 4298
3980 // Dispatched behavior. 4299 // Dispatched behavior.
3981 #ifdef DEBUG 4300 #ifdef DEBUG
3982 void JSFunctionPrint(); 4301 void JSFunctionPrint();
3983 void JSFunctionVerify(); 4302 void JSFunctionVerify();
3984 #endif 4303 #endif
3985 4304
3986 // Returns the number of allocated literals. 4305 // Returns the number of allocated literals.
3987 inline int NumberOfLiterals(); 4306 inline int NumberOfLiterals();
3988 4307
3989 // Retrieve the global context from a function's literal array. 4308 // Retrieve the global context from a function's literal array.
3990 static Context* GlobalContextFromLiterals(FixedArray* literals); 4309 static Context* GlobalContextFromLiterals(FixedArray* literals);
3991 4310
3992 // Layout descriptors. 4311 // Layout descriptors. The last property (from kNonWeakFieldsEndOffset to
4312 // kSize) is weak and has special handling during garbage collection.
3993 static const int kCodeEntryOffset = JSObject::kHeaderSize; 4313 static const int kCodeEntryOffset = JSObject::kHeaderSize;
3994 static const int kPrototypeOrInitialMapOffset = 4314 static const int kPrototypeOrInitialMapOffset =
3995 kCodeEntryOffset + kPointerSize; 4315 kCodeEntryOffset + kPointerSize;
3996 static const int kSharedFunctionInfoOffset = 4316 static const int kSharedFunctionInfoOffset =
3997 kPrototypeOrInitialMapOffset + kPointerSize; 4317 kPrototypeOrInitialMapOffset + kPointerSize;
3998 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize; 4318 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize;
3999 static const int kLiteralsOffset = kContextOffset + kPointerSize; 4319 static const int kLiteralsOffset = kContextOffset + kPointerSize;
4000 static const int kSize = kLiteralsOffset + kPointerSize; 4320 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize;
4321 static const int kNextFunctionLinkOffset = kNonWeakFieldsEndOffset;
4322 static const int kSize = kNextFunctionLinkOffset + kPointerSize;
4001 4323
4002 // Layout of the literals array. 4324 // Layout of the literals array.
4003 static const int kLiteralsPrefixSize = 1; 4325 static const int kLiteralsPrefixSize = 1;
4004 static const int kLiteralGlobalContextIndex = 0; 4326 static const int kLiteralGlobalContextIndex = 0;
4005 private: 4327 private:
4006 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction); 4328 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction);
4007 }; 4329 };
4008 4330
4009 4331
4010 // JSGlobalProxy's prototype must be a JSGlobalObject or null, 4332 // JSGlobalProxy's prototype must be a JSGlobalObject or null,
(...skipping 24 matching lines...) Expand all
4035 static const int kSize = kContextOffset + kPointerSize; 4357 static const int kSize = kContextOffset + kPointerSize;
4036 4358
4037 private: 4359 private:
4038 4360
4039 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy); 4361 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy);
4040 }; 4362 };
4041 4363
4042 4364
4043 // Forward declaration. 4365 // Forward declaration.
4044 class JSBuiltinsObject; 4366 class JSBuiltinsObject;
4367 class JSGlobalPropertyCell;
4045 4368
4046 // Common super class for JavaScript global objects and the special 4369 // Common super class for JavaScript global objects and the special
4047 // builtins global objects. 4370 // builtins global objects.
4048 class GlobalObject: public JSObject { 4371 class GlobalObject: public JSObject {
4049 public: 4372 public:
4050 // [builtins]: the object holding the runtime routines written in JS. 4373 // [builtins]: the object holding the runtime routines written in JS.
4051 DECL_ACCESSORS(builtins, JSBuiltinsObject) 4374 DECL_ACCESSORS(builtins, JSBuiltinsObject)
4052 4375
4053 // [global context]: the global context corresponding to this global object. 4376 // [global context]: the global context corresponding to this global object.
4054 DECL_ACCESSORS(global_context, Context) 4377 DECL_ACCESSORS(global_context, Context)
4055 4378
4056 // [global receiver]: the global receiver object of the context 4379 // [global receiver]: the global receiver object of the context
4057 DECL_ACCESSORS(global_receiver, JSObject) 4380 DECL_ACCESSORS(global_receiver, JSObject)
4058 4381
4059 // Retrieve the property cell used to store a property. 4382 // Retrieve the property cell used to store a property.
4060 Object* GetPropertyCell(LookupResult* result); 4383 JSGlobalPropertyCell* GetPropertyCell(LookupResult* result);
4061 4384
4062 // This is like GetProperty, but is used when you know the lookup won't fail 4385 // This is like GetProperty, but is used when you know the lookup won't fail
4063 // by throwing an exception. This is for the debug and builtins global 4386 // by throwing an exception. This is for the debug and builtins global
4064 // objects, where it is known which properties can be expected to be present 4387 // objects, where it is known which properties can be expected to be present
4065 // on the object. 4388 // on the object.
4066 Object* GetPropertyNoExceptionThrown(String* key) { 4389 Object* GetPropertyNoExceptionThrown(String* key) {
4067 Object* answer = GetProperty(key)->ToObjectUnchecked(); 4390 Object* answer = GetProperty(key)->ToObjectUnchecked();
4068 return answer; 4391 return answer;
4069 } 4392 }
4070 4393
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
4312 HashTableKey*> { 4635 HashTableKey*> {
4313 public: 4636 public:
4314 // Find cached value for a string key, otherwise return null. 4637 // Find cached value for a string key, otherwise return null.
4315 Object* Lookup(String* src); 4638 Object* Lookup(String* src);
4316 Object* LookupEval(String* src, Context* context); 4639 Object* LookupEval(String* src, Context* context);
4317 Object* LookupRegExp(String* source, JSRegExp::Flags flags); 4640 Object* LookupRegExp(String* source, JSRegExp::Flags flags);
4318 MaybeObject* Put(String* src, Object* value); 4641 MaybeObject* Put(String* src, Object* value);
4319 MaybeObject* PutEval(String* src, Context* context, Object* value); 4642 MaybeObject* PutEval(String* src, Context* context, Object* value);
4320 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value); 4643 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value);
4321 4644
4645 // Remove given value from cache.
4646 void Remove(Object* value);
4647
4322 static inline CompilationCacheTable* cast(Object* obj); 4648 static inline CompilationCacheTable* cast(Object* obj);
4323 4649
4324 private: 4650 private:
4325 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable); 4651 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable);
4326 }; 4652 };
4327 4653
4328 4654
4329 class CodeCache: public Struct { 4655 class CodeCache: public Struct {
4330 public: 4656 public:
4331 DECL_ACCESSORS(default_cache, FixedArray) 4657 DECL_ACCESSORS(default_cache, FixedArray)
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
5730 6056
5731 // To allow lazy clearing of inline caches the visitor has 6057 // To allow lazy clearing of inline caches the visitor has
5732 // a rich interface for iterating over Code objects.. 6058 // a rich interface for iterating over Code objects..
5733 6059
5734 // Visits a code target in the instruction stream. 6060 // Visits a code target in the instruction stream.
5735 virtual void VisitCodeTarget(RelocInfo* rinfo); 6061 virtual void VisitCodeTarget(RelocInfo* rinfo);
5736 6062
5737 // Visits a code entry in a JS function. 6063 // Visits a code entry in a JS function.
5738 virtual void VisitCodeEntry(Address entry_address); 6064 virtual void VisitCodeEntry(Address entry_address);
5739 6065
6066 // Visits a global property cell reference in the instruction stream.
6067 virtual void VisitGlobalPropertyCell(RelocInfo* rinfo);
6068
5740 // Visits a runtime entry in the instruction stream. 6069 // Visits a runtime entry in the instruction stream.
5741 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {} 6070 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {}
5742 6071
5743 // Visits the resource of an ASCII or two-byte string. 6072 // Visits the resource of an ASCII or two-byte string.
5744 virtual void VisitExternalAsciiString( 6073 virtual void VisitExternalAsciiString(
5745 v8::String::ExternalAsciiStringResource** resource) {} 6074 v8::String::ExternalAsciiStringResource** resource) {}
5746 virtual void VisitExternalTwoByteString( 6075 virtual void VisitExternalTwoByteString(
5747 v8::String::ExternalStringResource** resource) {} 6076 v8::String::ExternalStringResource** resource) {}
5748 6077
5749 // Visits a debug call target in the instruction stream. 6078 // Visits a debug call target in the instruction stream.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5802 } else { 6131 } else {
5803 value &= ~(1 << bit_position); 6132 value &= ~(1 << bit_position);
5804 } 6133 }
5805 return value; 6134 return value;
5806 } 6135 }
5807 }; 6136 };
5808 6137
5809 } } // namespace v8::internal 6138 } } // namespace v8::internal
5810 6139
5811 #endif // V8_OBJECTS_H_ 6140 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698