Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1491 | 1491 |
| 1492 | 1492 |
| 1493 // FixedArray describes fixed sized arrays where element | 1493 // FixedArray describes fixed sized arrays where element |
| 1494 // type is Object*. | 1494 // type is Object*. |
| 1495 | 1495 |
| 1496 class FixedArray: public Array { | 1496 class FixedArray: public Array { |
| 1497 public: | 1497 public: |
| 1498 | 1498 |
| 1499 // Setter and getter for elements. | 1499 // Setter and getter for elements. |
| 1500 inline Object* get(int index); | 1500 inline Object* get(int index); |
| 1501 // Setter that uses write barrier. | |
| 1501 inline void set(int index, Object* value); | 1502 inline void set(int index, Object* value); |
| 1502 | 1503 |
| 1503 // Setter with barrier mode. | 1504 // Setter that doesn't need write barrier). |
| 1505 inline void set(int index, Smi* value); | |
| 1506 // Setter with explicit barrier mode. | |
| 1504 inline void set(int index, Object* value, WriteBarrierMode mode); | 1507 inline void set(int index, Object* value, WriteBarrierMode mode); |
| 1505 | 1508 |
| 1506 // Setters for frequently used oddballs located in old space. | 1509 // Setters for frequently used oddballs located in old space. |
| 1507 inline void set_undefined(int index); | 1510 inline void set_undefined(int index); |
| 1508 inline void set_null(int index); | 1511 inline void set_null(int index); |
| 1509 inline void set_the_hole(int index); | 1512 inline void set_the_hole(int index); |
| 1510 | 1513 |
| 1511 // Copy operations. | 1514 // Copy operations. |
| 1512 inline Object* Copy(); | 1515 inline Object* Copy(); |
| 1513 Object* CopySize(int new_length); | 1516 Object* CopySize(int new_length); |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2107 | 2110 |
| 2108 enum Kind { | 2111 enum Kind { |
| 2109 FUNCTION, | 2112 FUNCTION, |
| 2110 STUB, | 2113 STUB, |
| 2111 BUILTIN, | 2114 BUILTIN, |
| 2112 LOAD_IC, | 2115 LOAD_IC, |
| 2113 KEYED_LOAD_IC, | 2116 KEYED_LOAD_IC, |
| 2114 CALL_IC, | 2117 CALL_IC, |
| 2115 STORE_IC, | 2118 STORE_IC, |
| 2116 KEYED_STORE_IC, | 2119 KEYED_STORE_IC, |
| 2120 // No more than eight kinds. The value currently encoded in three bits in | |
| 2121 // Flags. | |
| 2117 | 2122 |
| 2118 // Pseudo-kinds. | 2123 // Pseudo-kinds. |
| 2124 REGEXP = BUILTIN, | |
| 2119 FIRST_IC_KIND = LOAD_IC, | 2125 FIRST_IC_KIND = LOAD_IC, |
| 2120 LAST_IC_KIND = KEYED_STORE_IC | 2126 LAST_IC_KIND = KEYED_STORE_IC |
| 2121 }; | 2127 }; |
| 2122 | 2128 |
| 2123 enum { | 2129 enum { |
| 2124 NUMBER_OF_KINDS = LAST_IC_KIND + 1 | 2130 NUMBER_OF_KINDS = KEYED_STORE_IC + 1 |
|
Christian Plesner Hansen
2008/11/26 06:49:56
Should be LAST_IC_KIND
| |
| 2125 }; | 2131 }; |
| 2126 | 2132 |
| 2127 // A state indicates that inline cache in this Code object contains | 2133 // A state indicates that inline cache in this Code object contains |
| 2128 // objects or relative instruction addresses. | 2134 // objects or relative instruction addresses. |
| 2129 enum ICTargetState { | 2135 enum ICTargetState { |
| 2130 IC_TARGET_IS_ADDRESS, | 2136 IC_TARGET_IS_ADDRESS, |
| 2131 IC_TARGET_IS_OBJECT | 2137 IC_TARGET_IS_OBJECT |
| 2132 }; | 2138 }; |
| 2133 | 2139 |
| 2134 #ifdef ENABLE_DISASSEMBLER | 2140 #ifdef ENABLE_DISASSEMBLER |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2265 static const int kFlagsICStateShift = 0; | 2271 static const int kFlagsICStateShift = 0; |
| 2266 static const int kFlagsKindShift = 3; | 2272 static const int kFlagsKindShift = 3; |
| 2267 static const int kFlagsTypeShift = 6; | 2273 static const int kFlagsTypeShift = 6; |
| 2268 static const int kFlagsArgumentsCountShift = 9; | 2274 static const int kFlagsArgumentsCountShift = 9; |
| 2269 | 2275 |
| 2270 static const int kFlagsICStateMask = 0x00000007; // 000000111 | 2276 static const int kFlagsICStateMask = 0x00000007; // 000000111 |
| 2271 static const int kFlagsKindMask = 0x00000038; // 000111000 | 2277 static const int kFlagsKindMask = 0x00000038; // 000111000 |
| 2272 static const int kFlagsTypeMask = 0x000001C0; // 111000000 | 2278 static const int kFlagsTypeMask = 0x000001C0; // 111000000 |
| 2273 static const int kFlagsArgumentsCountMask = 0xFFFFFE00; | 2279 static const int kFlagsArgumentsCountMask = 0xFFFFFE00; |
| 2274 | 2280 |
| 2275 | |
| 2276 private: | 2281 private: |
| 2277 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 2282 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
| 2278 }; | 2283 }; |
| 2279 | 2284 |
| 2280 | 2285 |
| 2281 // All heap objects have a Map that describes their structure. | 2286 // All heap objects have a Map that describes their structure. |
| 2282 // A Map contains information about: | 2287 // A Map contains information about: |
| 2283 // - Size information about the object | 2288 // - Size information about the object |
| 2284 // - How to iterate over an object (for garbage collection) | 2289 // - How to iterate over an object (for garbage collection) |
| 2285 class Map: public HeapObject { | 2290 class Map: public HeapObject { |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2905 static const int kValueOffset = JSObject::kHeaderSize; | 2910 static const int kValueOffset = JSObject::kHeaderSize; |
| 2906 static const int kSize = kValueOffset + kPointerSize; | 2911 static const int kSize = kValueOffset + kPointerSize; |
| 2907 | 2912 |
| 2908 private: | 2913 private: |
| 2909 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue); | 2914 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue); |
| 2910 }; | 2915 }; |
| 2911 | 2916 |
| 2912 // Regular expressions | 2917 // Regular expressions |
| 2913 class JSRegExp: public JSObject { | 2918 class JSRegExp: public JSObject { |
| 2914 public: | 2919 public: |
| 2915 enum Type { NOT_COMPILED, JSCRE, ATOM }; | 2920 // Meaning of Type: |
| 2921 // NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet. | |
| 2922 // JSCRE: A complex RegExp for JSCRE | |
| 2923 // ATOM: A simple string to match against using an indexOf operation. | |
| 2924 // IRREGEXP: Compiled with Irregexp. | |
| 2925 // IRREGEXP_NATIVE: Compiled to native code with Irregexp. | |
| 2926 enum Type { NOT_COMPILED, JSCRE, ATOM, IRREGEXP, IRREGEXP_NATIVE }; | |
| 2916 enum Flag { NONE = 0, GLOBAL = 1, IGNORE_CASE = 2, MULTILINE = 4 }; | 2927 enum Flag { NONE = 0, GLOBAL = 1, IGNORE_CASE = 2, MULTILINE = 4 }; |
| 2917 | 2928 |
| 2918 class Flags { | 2929 class Flags { |
| 2919 public: | 2930 public: |
| 2920 explicit Flags(uint32_t value) : value_(value) { } | 2931 explicit Flags(uint32_t value) : value_(value) { } |
| 2921 bool is_global() { return (value_ & GLOBAL) != 0; } | 2932 bool is_global() { return (value_ & GLOBAL) != 0; } |
| 2922 bool is_ignore_case() { return (value_ & IGNORE_CASE) != 0; } | 2933 bool is_ignore_case() { return (value_ & IGNORE_CASE) != 0; } |
| 2923 bool is_multiline() { return (value_ & MULTILINE) != 0; } | 2934 bool is_multiline() { return (value_ & MULTILINE) != 0; } |
| 2924 uint32_t value() { return value_; } | 2935 uint32_t value() { return value_; } |
| 2925 private: | 2936 private: |
| 2926 uint32_t value_; | 2937 uint32_t value_; |
| 2927 }; | 2938 }; |
| 2928 | 2939 |
| 2929 DECL_ACCESSORS(data, Object) | 2940 DECL_ACCESSORS(data, Object) |
| 2930 | 2941 |
| 2931 inline Type TypeTag(); | 2942 inline Type TypeTag(); |
| 2943 inline Flags GetFlags(); | |
| 2944 inline String* Pattern(); | |
| 2932 inline Object* DataAt(int index); | 2945 inline Object* DataAt(int index); |
| 2933 | 2946 |
| 2934 static inline JSRegExp* cast(Object* obj); | 2947 static inline JSRegExp* cast(Object* obj); |
| 2935 | 2948 |
| 2936 // Dispatched behavior. | 2949 // Dispatched behavior. |
| 2937 #ifdef DEBUG | 2950 #ifdef DEBUG |
| 2938 void JSRegExpPrint(); | 2951 void JSRegExpPrint(); |
| 2939 void JSRegExpVerify(); | 2952 void JSRegExpVerify(); |
| 2940 #endif | 2953 #endif |
| 2941 | 2954 |
| 2942 static const int kDataOffset = JSObject::kHeaderSize; | 2955 static const int kDataOffset = JSObject::kHeaderSize; |
| 2943 static const int kSize = kDataOffset + kIntSize; | 2956 static const int kSize = kDataOffset + kIntSize; |
| 2944 | 2957 |
| 2945 static const int kTagIndex = 0; | 2958 static const int kTagIndex = 0; |
| 2946 static const int kSourceIndex = kTagIndex + 1; | 2959 static const int kSourceIndex = kTagIndex + 1; |
| 2947 static const int kFlagsIndex = kSourceIndex + 1; | 2960 static const int kFlagsIndex = kSourceIndex + 1; |
| 2948 // These two are the same since the same entry is shared for | 2961 // These three are the same since the same entry is shared for |
| 2949 // different purposes in different types of regexps. | 2962 // different purposes in different types of regexps. |
| 2950 static const int kAtomPatternIndex = kFlagsIndex + 1; | 2963 static const int kAtomPatternIndex = kFlagsIndex + 1; |
| 2951 static const int kJscreDataIndex = kFlagsIndex + 1; | 2964 static const int kJscreDataIndex = kFlagsIndex + 1; |
| 2965 static const int kIrregexpDataIndex = kFlagsIndex + 1; | |
| 2952 static const int kDataSize = kAtomPatternIndex + 1; | 2966 static const int kDataSize = kAtomPatternIndex + 1; |
| 2953 }; | 2967 }; |
| 2954 | 2968 |
| 2955 | 2969 |
| 2956 class CompilationCacheTable: public HashTable<0, 2> { | 2970 class CompilationCacheTable: public HashTable<0, 2> { |
| 2957 public: | 2971 public: |
| 2958 // Find cached value for a string key, otherwise return null. | 2972 // Find cached value for a string key, otherwise return null. |
| 2959 Object* Lookup(String* src); | 2973 Object* Lookup(String* src); |
| 2960 Object* LookupRegExp(String* source, JSRegExp::Flags flags); | 2974 Object* LookupRegExp(String* source, JSRegExp::Flags flags); |
| 2961 Object* Put(String* src, Object* value); | 2975 Object* Put(String* src, Object* value); |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3571 // Support for StringInputBuffer. | 3585 // Support for StringInputBuffer. |
| 3572 void ExternalTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 3586 void ExternalTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 3573 unsigned* offset_ptr, | 3587 unsigned* offset_ptr, |
| 3574 unsigned chars); | 3588 unsigned chars); |
| 3575 | 3589 |
| 3576 private: | 3590 private: |
| 3577 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); | 3591 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); |
| 3578 }; | 3592 }; |
| 3579 | 3593 |
| 3580 | 3594 |
| 3595 // A flat string reader provides random access to the contents of a | |
| 3596 // string independent of the character width of the string. The handle | |
| 3597 // must be valid as long as the reader is being used. | |
| 3598 class FlatStringReader BASE_EMBEDDED { | |
| 3599 public: | |
| 3600 explicit FlatStringReader(Handle<String> str); | |
| 3601 explicit FlatStringReader(Vector<const char> input); | |
| 3602 ~FlatStringReader(); | |
| 3603 void RefreshState(); | |
| 3604 inline uc32 Get(int index); | |
| 3605 int length() { return length_; } | |
| 3606 static void PostGarbageCollectionProcessing(); | |
| 3607 private: | |
| 3608 String** str_; | |
| 3609 bool is_ascii_; | |
| 3610 int length_; | |
| 3611 const void* start_; | |
| 3612 FlatStringReader* prev_; | |
| 3613 static FlatStringReader* top_; | |
| 3614 }; | |
| 3615 | |
| 3616 | |
| 3581 // Note that StringInputBuffers are not valid across a GC! To fix this | 3617 // Note that StringInputBuffers are not valid across a GC! To fix this |
| 3582 // it would have to store a String Handle instead of a String* and | 3618 // it would have to store a String Handle instead of a String* and |
| 3583 // AsciiStringReadBlock would have to be modified to use memcpy. | 3619 // AsciiStringReadBlock would have to be modified to use memcpy. |
| 3584 // | 3620 // |
| 3585 // StringInputBuffer is able to traverse any string regardless of how | 3621 // StringInputBuffer is able to traverse any string regardless of how |
| 3586 // deeply nested a sequence of ConsStrings it is made of. However, | 3622 // deeply nested a sequence of ConsStrings it is made of. However, |
| 3587 // performance will be better if deep strings are flattened before they | 3623 // performance will be better if deep strings are flattened before they |
| 3588 // are traversed. Since flattening requires memory allocation this is | 3624 // are traversed. Since flattening requires memory allocation this is |
| 3589 // not always desirable, however (esp. in debugging situations). | 3625 // not always desirable, however (esp. in debugging situations). |
| 3590 class StringInputBuffer: public unibrow::InputBuffer<String, String*, 1024> { | 3626 class StringInputBuffer: public unibrow::InputBuffer<String, String*, 1024> { |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4165 } else { | 4201 } else { |
| 4166 value &= ~(1 << bit_position); | 4202 value &= ~(1 << bit_position); |
| 4167 } | 4203 } |
| 4168 return value; | 4204 return value; |
| 4169 } | 4205 } |
| 4170 }; | 4206 }; |
| 4171 | 4207 |
| 4172 } } // namespace v8::internal | 4208 } } // namespace v8::internal |
| 4173 | 4209 |
| 4174 #endif // V8_OBJECTS_H_ | 4210 #endif // V8_OBJECTS_H_ |
| OLD | NEW |