| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 // string) or a INTERNALIZED_STRING_TYPE (if it is a internalized string). | 328 // string) or a INTERNALIZED_STRING_TYPE (if it is a internalized string). |
| 329 // | 329 // |
| 330 // NOTE: The following things are some that depend on the string types having | 330 // NOTE: The following things are some that depend on the string types having |
| 331 // instance_types that are less than those of all other types: | 331 // instance_types that are less than those of all other types: |
| 332 // HeapObject::Size, HeapObject::IterateBody, the typeof operator, and | 332 // HeapObject::Size, HeapObject::IterateBody, the typeof operator, and |
| 333 // Object::IsString. | 333 // Object::IsString. |
| 334 // | 334 // |
| 335 // NOTE: Everything following JS_VALUE_TYPE is considered a | 335 // NOTE: Everything following JS_VALUE_TYPE is considered a |
| 336 // JSObject for GC purposes. The first four entries here have typeof | 336 // JSObject for GC purposes. The first four entries here have typeof |
| 337 // 'object', whereas JS_FUNCTION_TYPE has typeof 'function'. | 337 // 'object', whereas JS_FUNCTION_TYPE has typeof 'function'. |
| 338 #define INSTANCE_TYPE_LIST_ALL(V) \ | 338 #define INSTANCE_TYPE_LIST(V) \ |
| 339 V(STRING_TYPE) \ | 339 V(STRING_TYPE) \ |
| 340 V(ASCII_STRING_TYPE) \ | 340 V(ASCII_STRING_TYPE) \ |
| 341 V(CONS_STRING_TYPE) \ | 341 V(CONS_STRING_TYPE) \ |
| 342 V(CONS_ASCII_STRING_TYPE) \ | 342 V(CONS_ASCII_STRING_TYPE) \ |
| 343 V(SLICED_STRING_TYPE) \ | 343 V(SLICED_STRING_TYPE) \ |
| 344 V(SLICED_ASCII_STRING_TYPE) \ | 344 V(SLICED_ASCII_STRING_TYPE) \ |
| 345 V(EXTERNAL_STRING_TYPE) \ | 345 V(EXTERNAL_STRING_TYPE) \ |
| 346 V(EXTERNAL_ASCII_STRING_TYPE) \ | 346 V(EXTERNAL_ASCII_STRING_TYPE) \ |
| 347 V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \ | 347 V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \ |
| 348 V(SHORT_EXTERNAL_STRING_TYPE) \ | 348 V(SHORT_EXTERNAL_STRING_TYPE) \ |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 V(JS_DATA_VIEW_TYPE) \ | 426 V(JS_DATA_VIEW_TYPE) \ |
| 427 V(JS_PROXY_TYPE) \ | 427 V(JS_PROXY_TYPE) \ |
| 428 V(JS_SET_TYPE) \ | 428 V(JS_SET_TYPE) \ |
| 429 V(JS_MAP_TYPE) \ | 429 V(JS_MAP_TYPE) \ |
| 430 V(JS_WEAK_MAP_TYPE) \ | 430 V(JS_WEAK_MAP_TYPE) \ |
| 431 V(JS_WEAK_SET_TYPE) \ | 431 V(JS_WEAK_SET_TYPE) \ |
| 432 V(JS_REGEXP_TYPE) \ | 432 V(JS_REGEXP_TYPE) \ |
| 433 \ | 433 \ |
| 434 V(JS_FUNCTION_TYPE) \ | 434 V(JS_FUNCTION_TYPE) \ |
| 435 V(JS_FUNCTION_PROXY_TYPE) \ | 435 V(JS_FUNCTION_PROXY_TYPE) \ |
| 436 | |
| 437 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 438 #define INSTANCE_TYPE_LIST_DEBUGGER(V) \ | |
| 439 V(DEBUG_INFO_TYPE) \ | 436 V(DEBUG_INFO_TYPE) \ |
| 440 V(BREAK_POINT_INFO_TYPE) | 437 V(BREAK_POINT_INFO_TYPE) |
| 441 #else | |
| 442 #define INSTANCE_TYPE_LIST_DEBUGGER(V) | |
| 443 #endif | |
| 444 | |
| 445 #define INSTANCE_TYPE_LIST(V) \ | |
| 446 INSTANCE_TYPE_LIST_ALL(V) \ | |
| 447 INSTANCE_TYPE_LIST_DEBUGGER(V) | |
| 448 | 438 |
| 449 | 439 |
| 450 // Since string types are not consecutive, this macro is used to | 440 // Since string types are not consecutive, this macro is used to |
| 451 // iterate over them. | 441 // iterate over them. |
| 452 #define STRING_TYPE_LIST(V) \ | 442 #define STRING_TYPE_LIST(V) \ |
| 453 V(STRING_TYPE, \ | 443 V(STRING_TYPE, \ |
| 454 kVariableSizeSentinel, \ | 444 kVariableSizeSentinel, \ |
| 455 string, \ | 445 string, \ |
| 456 String) \ | 446 String) \ |
| 457 V(ASCII_STRING_TYPE, \ | 447 V(ASCII_STRING_TYPE, \ |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 V(MapCache) \ | 1039 V(MapCache) \ |
| 1050 V(Primitive) \ | 1040 V(Primitive) \ |
| 1051 V(GlobalObject) \ | 1041 V(GlobalObject) \ |
| 1052 V(JSGlobalObject) \ | 1042 V(JSGlobalObject) \ |
| 1053 V(JSBuiltinsObject) \ | 1043 V(JSBuiltinsObject) \ |
| 1054 V(JSGlobalProxy) \ | 1044 V(JSGlobalProxy) \ |
| 1055 V(UndetectableObject) \ | 1045 V(UndetectableObject) \ |
| 1056 V(AccessCheckNeeded) \ | 1046 V(AccessCheckNeeded) \ |
| 1057 V(Cell) \ | 1047 V(Cell) \ |
| 1058 V(PropertyCell) \ | 1048 V(PropertyCell) \ |
| 1059 V(ObjectHashTable) | 1049 V(ObjectHashTable) \ |
| 1050 V(WeakHashTable) |
| 1060 | 1051 |
| 1061 | 1052 |
| 1062 #define ERROR_MESSAGES_LIST(V) \ | 1053 #define ERROR_MESSAGES_LIST(V) \ |
| 1063 V(kNoReason, "no reason") \ | 1054 V(kNoReason, "no reason") \ |
| 1064 \ | 1055 \ |
| 1065 V(k32BitValueInRegisterIsNotZeroExtended, \ | 1056 V(k32BitValueInRegisterIsNotZeroExtended, \ |
| 1066 "32 bit value in register is not zero-extended") \ | 1057 "32 bit value in register is not zero-extended") \ |
| 1067 V(kAlignmentMarkerExpected, "alignment marker expected") \ | 1058 V(kAlignmentMarkerExpected, "alignment marker expected") \ |
| 1068 V(kAllocationIsNotDoubleAligned, "Allocation is not double aligned") \ | 1059 V(kAllocationIsNotDoubleAligned, "Allocation is not double aligned") \ |
| 1069 V(kAPICallReturnedInvalidObject, "API call returned invalid object") \ | 1060 V(kAPICallReturnedInvalidObject, "API call returned invalid object") \ |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 V(kLiveEdit, "LiveEdit") \ | 1210 V(kLiveEdit, "LiveEdit") \ |
| 1220 V(kLookupVariableInCountOperation, \ | 1211 V(kLookupVariableInCountOperation, \ |
| 1221 "lookup variable in count operation") \ | 1212 "lookup variable in count operation") \ |
| 1222 V(kMapIsNoLongerInEax, "Map is no longer in eax") \ | 1213 V(kMapIsNoLongerInEax, "Map is no longer in eax") \ |
| 1223 V(kModuleDeclaration, "Module declaration") \ | 1214 V(kModuleDeclaration, "Module declaration") \ |
| 1224 V(kModuleLiteral, "Module literal") \ | 1215 V(kModuleLiteral, "Module literal") \ |
| 1225 V(kModulePath, "Module path") \ | 1216 V(kModulePath, "Module path") \ |
| 1226 V(kModuleStatement, "Module statement") \ | 1217 V(kModuleStatement, "Module statement") \ |
| 1227 V(kModuleVariable, "Module variable") \ | 1218 V(kModuleVariable, "Module variable") \ |
| 1228 V(kModuleUrl, "Module url") \ | 1219 V(kModuleUrl, "Module url") \ |
| 1220 V(kNativeFunctionLiteral, "Native function literal") \ |
| 1229 V(kNoCasesLeft, "no cases left") \ | 1221 V(kNoCasesLeft, "no cases left") \ |
| 1230 V(kNoEmptyArraysHereInEmitFastAsciiArrayJoin, \ | 1222 V(kNoEmptyArraysHereInEmitFastAsciiArrayJoin, \ |
| 1231 "No empty arrays here in EmitFastAsciiArrayJoin") \ | 1223 "No empty arrays here in EmitFastAsciiArrayJoin") \ |
| 1232 V(kNonInitializerAssignmentToConst, \ | 1224 V(kNonInitializerAssignmentToConst, \ |
| 1233 "non-initializer assignment to const") \ | 1225 "non-initializer assignment to const") \ |
| 1234 V(kNonSmiIndex, "Non-smi index") \ | 1226 V(kNonSmiIndex, "Non-smi index") \ |
| 1235 V(kNonSmiKeyInArrayLiteral, "Non-smi key in array literal") \ | 1227 V(kNonSmiKeyInArrayLiteral, "Non-smi key in array literal") \ |
| 1236 V(kNonSmiValue, "Non-smi value") \ | 1228 V(kNonSmiValue, "Non-smi value") \ |
| 1237 V(kNotEnoughVirtualRegistersForValues, \ | 1229 V(kNotEnoughVirtualRegistersForValues, \ |
| 1238 "not enough virtual registers for values") \ | 1230 "not enough virtual registers for values") \ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1267 "reference to a variable which requires dynamic lookup") \ | 1259 "reference to a variable which requires dynamic lookup") \ |
| 1268 V(kReferenceToGlobalLexicalVariable, \ | 1260 V(kReferenceToGlobalLexicalVariable, \ |
| 1269 "reference to global lexical variable") \ | 1261 "reference to global lexical variable") \ |
| 1270 V(kReferenceToUninitializedVariable, "reference to uninitialized variable") \ | 1262 V(kReferenceToUninitializedVariable, "reference to uninitialized variable") \ |
| 1271 V(kRegisterDidNotMatchExpectedRoot, "Register did not match expected root") \ | 1263 V(kRegisterDidNotMatchExpectedRoot, "Register did not match expected root") \ |
| 1272 V(kRegisterWasClobbered, "register was clobbered") \ | 1264 V(kRegisterWasClobbered, "register was clobbered") \ |
| 1273 V(kRememberedSetPointerInNewSpace, "remembered set pointer is in new space") \ | 1265 V(kRememberedSetPointerInNewSpace, "remembered set pointer is in new space") \ |
| 1274 V(kReturnAddressNotFoundInFrame, "return address not found in frame") \ | 1266 V(kReturnAddressNotFoundInFrame, "return address not found in frame") \ |
| 1275 V(kRhsHasBeenClobbered, "rhs has been clobbered") \ | 1267 V(kRhsHasBeenClobbered, "rhs has been clobbered") \ |
| 1276 V(kScopedBlock, "ScopedBlock") \ | 1268 V(kScopedBlock, "ScopedBlock") \ |
| 1277 V(kSharedFunctionInfoLiteral, "Shared function info literal") \ | |
| 1278 V(kSmiAdditionOverflow, "Smi addition overflow") \ | 1269 V(kSmiAdditionOverflow, "Smi addition overflow") \ |
| 1279 V(kSmiSubtractionOverflow, "Smi subtraction overflow") \ | 1270 V(kSmiSubtractionOverflow, "Smi subtraction overflow") \ |
| 1280 V(kStackAccessBelowStackPointer, "stack access below stack pointer") \ | 1271 V(kStackAccessBelowStackPointer, "stack access below stack pointer") \ |
| 1281 V(kStackFrameTypesMustMatch, "stack frame types must match") \ | 1272 V(kStackFrameTypesMustMatch, "stack frame types must match") \ |
| 1282 V(kSwitchStatementMixedOrNonLiteralSwitchLabels, \ | 1273 V(kSwitchStatementMixedOrNonLiteralSwitchLabels, \ |
| 1283 "SwitchStatement: mixed or non-literal switch labels") \ | 1274 "SwitchStatement: mixed or non-literal switch labels") \ |
| 1284 V(kSwitchStatementTooManyClauses, "SwitchStatement: too many clauses") \ | 1275 V(kSwitchStatementTooManyClauses, "SwitchStatement: too many clauses") \ |
| 1285 V(kTheCurrentStackPointerIsBelowCsp, \ | 1276 V(kTheCurrentStackPointerIsBelowCsp, \ |
| 1286 "the current stack pointer is below csp") \ | 1277 "the current stack pointer is below csp") \ |
| 1287 V(kTheInstructionShouldBeALui, "The instruction should be a lui") \ | 1278 V(kTheInstructionShouldBeALui, "The instruction should be a lui") \ |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2199 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); | 2190 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); |
| 2200 | 2191 |
| 2201 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); | 2192 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); |
| 2202 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); | 2193 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); |
| 2203 | 2194 |
| 2204 // Try to follow an existing transition to a field with attributes NONE. The | 2195 // Try to follow an existing transition to a field with attributes NONE. The |
| 2205 // return value indicates whether the transition was successful. | 2196 // return value indicates whether the transition was successful. |
| 2206 static inline Handle<Map> FindTransitionToField(Handle<Map> map, | 2197 static inline Handle<Map> FindTransitionToField(Handle<Map> map, |
| 2207 Handle<Name> key); | 2198 Handle<Name> key); |
| 2208 | 2199 |
| 2209 inline int LastAddedFieldIndex(); | |
| 2210 | |
| 2211 // Extend the receiver with a single fast property appeared first in the | 2200 // Extend the receiver with a single fast property appeared first in the |
| 2212 // passed map. This also extends the property backing store if necessary. | 2201 // passed map. This also extends the property backing store if necessary. |
| 2213 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); | 2202 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); |
| 2214 | 2203 |
| 2215 // Migrates the given object to a map whose field representations are the | 2204 // Migrates the given object to a map whose field representations are the |
| 2216 // lowest upper bound of all known representations for that field. | 2205 // lowest upper bound of all known representations for that field. |
| 2217 static void MigrateInstance(Handle<JSObject> instance); | 2206 static void MigrateInstance(Handle<JSObject> instance); |
| 2218 | 2207 |
| 2219 // Migrates the given object only if the target map is already available, | 2208 // Migrates the given object only if the target map is already available, |
| 2220 // or returns an empty handle if such a map is not yet available. | 2209 // or returns an empty handle if such a map is not yet available. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2261 bool continue_search); | 2250 bool continue_search); |
| 2262 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck( | 2251 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck( |
| 2263 Object* receiver, | 2252 Object* receiver, |
| 2264 LookupResult* result, | 2253 LookupResult* result, |
| 2265 Name* name, | 2254 Name* name, |
| 2266 bool continue_search); | 2255 bool continue_search); |
| 2267 PropertyAttributes GetElementAttributeWithReceiver(JSReceiver* receiver, | 2256 PropertyAttributes GetElementAttributeWithReceiver(JSReceiver* receiver, |
| 2268 uint32_t index, | 2257 uint32_t index, |
| 2269 bool continue_search); | 2258 bool continue_search); |
| 2270 | 2259 |
| 2260 // Retrieves an AccessorPair property from the given object. Might return |
| 2261 // undefined if the property doesn't exist or is of a different kind. |
| 2262 static Handle<Object> GetAccessor(Handle<JSObject> object, |
| 2263 Handle<Name> name, |
| 2264 AccessorComponent component); |
| 2265 |
| 2266 // Defines an AccessorPair property on the given object. |
| 2267 // TODO(mstarzinger): Rename to SetAccessor() and return empty handle on |
| 2268 // exception instead of letting callers check for scheduled exception. |
| 2271 static void DefineAccessor(Handle<JSObject> object, | 2269 static void DefineAccessor(Handle<JSObject> object, |
| 2272 Handle<Name> name, | 2270 Handle<Name> name, |
| 2273 Handle<Object> getter, | 2271 Handle<Object> getter, |
| 2274 Handle<Object> setter, | 2272 Handle<Object> setter, |
| 2275 PropertyAttributes attributes, | 2273 PropertyAttributes attributes, |
| 2276 v8::AccessControl access_control = v8::DEFAULT); | 2274 v8::AccessControl access_control = v8::DEFAULT); |
| 2277 | 2275 |
| 2278 MaybeObject* LookupAccessor(Name* name, AccessorComponent component); | 2276 // Defines an AccessorInfo property on the given object. |
| 2279 | |
| 2280 static Handle<Object> SetAccessor(Handle<JSObject> object, | 2277 static Handle<Object> SetAccessor(Handle<JSObject> object, |
| 2281 Handle<AccessorInfo> info); | 2278 Handle<AccessorInfo> info); |
| 2282 | 2279 |
| 2283 // Used from Object::GetProperty(). | 2280 // Used from Object::GetProperty(). |
| 2284 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( | 2281 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( |
| 2285 Object* receiver, | 2282 Object* receiver, |
| 2286 LookupResult* result, | 2283 LookupResult* result, |
| 2287 Name* name, | 2284 Name* name, |
| 2288 PropertyAttributes* attributes); | 2285 PropertyAttributes* attributes); |
| 2289 MUST_USE_RESULT MaybeObject* GetPropertyWithInterceptor( | 2286 MUST_USE_RESULT MaybeObject* GetPropertyWithInterceptor( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2369 // represented in a FixedDoubleArray and has at least one value that can only | 2366 // represented in a FixedDoubleArray and has at least one value that can only |
| 2370 // be represented as a double and not a Smi. | 2367 // be represented as a double and not a Smi. |
| 2371 bool ShouldConvertToFastDoubleElements(bool* has_smi_only_elements); | 2368 bool ShouldConvertToFastDoubleElements(bool* has_smi_only_elements); |
| 2372 | 2369 |
| 2373 // Computes the new capacity when expanding the elements of a JSObject. | 2370 // Computes the new capacity when expanding the elements of a JSObject. |
| 2374 static int NewElementsCapacity(int old_capacity) { | 2371 static int NewElementsCapacity(int old_capacity) { |
| 2375 // (old_capacity + 50%) + 16 | 2372 // (old_capacity + 50%) + 16 |
| 2376 return old_capacity + (old_capacity >> 1) + 16; | 2373 return old_capacity + (old_capacity >> 1) + 16; |
| 2377 } | 2374 } |
| 2378 | 2375 |
| 2379 PropertyType GetLocalPropertyType(Name* name); | |
| 2380 PropertyType GetLocalElementType(uint32_t index); | |
| 2381 | |
| 2382 // These methods do not perform access checks! | 2376 // These methods do not perform access checks! |
| 2383 AccessorPair* GetLocalPropertyAccessorPair(Name* name); | 2377 AccessorPair* GetLocalPropertyAccessorPair(Name* name); |
| 2384 AccessorPair* GetLocalElementAccessorPair(uint32_t index); | 2378 AccessorPair* GetLocalElementAccessorPair(uint32_t index); |
| 2385 | 2379 |
| 2386 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, | 2380 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, |
| 2387 Object* value, | 2381 Object* value, |
| 2388 StrictModeFlag strict_mode, | 2382 StrictModeFlag strict_mode, |
| 2389 bool check_prototype); | 2383 bool check_prototype); |
| 2390 | 2384 |
| 2391 MUST_USE_RESULT MaybeObject* SetDictionaryElement( | 2385 MUST_USE_RESULT MaybeObject* SetDictionaryElement( |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2931 inline void set_the_hole(int index); | 2925 inline void set_the_hole(int index); |
| 2932 | 2926 |
| 2933 inline Object** GetFirstElementAddress(); | 2927 inline Object** GetFirstElementAddress(); |
| 2934 inline bool ContainsOnlySmisOrHoles(); | 2928 inline bool ContainsOnlySmisOrHoles(); |
| 2935 | 2929 |
| 2936 // Gives access to raw memory which stores the array's data. | 2930 // Gives access to raw memory which stores the array's data. |
| 2937 inline Object** data_start(); | 2931 inline Object** data_start(); |
| 2938 | 2932 |
| 2939 // Copy operations. | 2933 // Copy operations. |
| 2940 MUST_USE_RESULT inline MaybeObject* Copy(); | 2934 MUST_USE_RESULT inline MaybeObject* Copy(); |
| 2941 MUST_USE_RESULT MaybeObject* CopySize(int new_length); | 2935 MUST_USE_RESULT MaybeObject* CopySize(int new_length, |
| 2936 PretenureFlag pretenure = NOT_TENURED); |
| 2942 | 2937 |
| 2943 // Add the elements of a JSArray to this FixedArray. | 2938 // Add the elements of a JSArray to this FixedArray. |
| 2944 MUST_USE_RESULT MaybeObject* AddKeysFromJSArray(JSArray* array); | 2939 MUST_USE_RESULT MaybeObject* AddKeysFromJSArray(JSArray* array); |
| 2945 | 2940 |
| 2946 // Compute the union of this and other. | 2941 // Compute the union of this and other. |
| 2947 MUST_USE_RESULT MaybeObject* UnionOfKeys(FixedArray* other); | 2942 MUST_USE_RESULT MaybeObject* UnionOfKeys(FixedArray* other); |
| 2948 | 2943 |
| 2949 // Copy a sub array from the receiver to dest. | 2944 // Copy a sub array from the receiver to dest. |
| 2950 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); | 2945 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); |
| 2951 | 2946 |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3566 | 3561 |
| 3567 void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode); | 3562 void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode); |
| 3568 | 3563 |
| 3569 // Rehashes this hash-table into the new table. | 3564 // Rehashes this hash-table into the new table. |
| 3570 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); | 3565 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); |
| 3571 | 3566 |
| 3572 // Attempt to shrink hash table after removal of key. | 3567 // Attempt to shrink hash table after removal of key. |
| 3573 MUST_USE_RESULT MaybeObject* Shrink(Key key); | 3568 MUST_USE_RESULT MaybeObject* Shrink(Key key); |
| 3574 | 3569 |
| 3575 // Ensure enough space for n additional elements. | 3570 // Ensure enough space for n additional elements. |
| 3576 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key); | 3571 MUST_USE_RESULT MaybeObject* EnsureCapacity( |
| 3572 int n, |
| 3573 Key key, |
| 3574 PretenureFlag pretenure = NOT_TENURED); |
| 3577 }; | 3575 }; |
| 3578 | 3576 |
| 3579 | 3577 |
| 3580 // HashTableKey is an abstract superclass for virtual key behavior. | 3578 // HashTableKey is an abstract superclass for virtual key behavior. |
| 3581 class HashTableKey { | 3579 class HashTableKey { |
| 3582 public: | 3580 public: |
| 3583 // Returns whether the other object matches this key. | 3581 // Returns whether the other object matches this key. |
| 3584 virtual bool IsMatch(Object* other) = 0; | 3582 virtual bool IsMatch(Object* other) = 0; |
| 3585 // Returns the hash value for this key. | 3583 // Returns the hash value for this key. |
| 3586 virtual uint32_t Hash() = 0; | 3584 virtual uint32_t Hash() = 0; |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4005 void AddEntry(int entry, Object* key, Object* value); | 4003 void AddEntry(int entry, Object* key, Object* value); |
| 4006 void RemoveEntry(int entry); | 4004 void RemoveEntry(int entry); |
| 4007 | 4005 |
| 4008 // Returns the index to the value of an entry. | 4006 // Returns the index to the value of an entry. |
| 4009 static inline int EntryToValueIndex(int entry) { | 4007 static inline int EntryToValueIndex(int entry) { |
| 4010 return EntryToIndex(entry) + 1; | 4008 return EntryToIndex(entry) + 1; |
| 4011 } | 4009 } |
| 4012 }; | 4010 }; |
| 4013 | 4011 |
| 4014 | 4012 |
| 4013 template <int entrysize> |
| 4014 class WeakHashTableShape : public BaseShape<Object*> { |
| 4015 public: |
| 4016 static inline bool IsMatch(Object* key, Object* other); |
| 4017 static inline uint32_t Hash(Object* key); |
| 4018 static inline uint32_t HashForObject(Object* key, Object* object); |
| 4019 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, |
| 4020 Object* key); |
| 4021 static const int kPrefixSize = 0; |
| 4022 static const int kEntrySize = entrysize; |
| 4023 }; |
| 4024 |
| 4025 |
| 4026 // WeakHashTable maps keys that are arbitrary objects to object values. |
| 4027 // It is used for the global weak hash table that maps objects |
| 4028 // embedded in optimized code to dependent code lists. |
| 4029 class WeakHashTable: public HashTable<WeakHashTableShape<2>, Object*> { |
| 4030 public: |
| 4031 static inline WeakHashTable* cast(Object* obj) { |
| 4032 ASSERT(obj->IsHashTable()); |
| 4033 return reinterpret_cast<WeakHashTable*>(obj); |
| 4034 } |
| 4035 |
| 4036 // Looks up the value associated with the given key. The hole value is |
| 4037 // returned in case the key is not present. |
| 4038 Object* Lookup(Object* key); |
| 4039 |
| 4040 // Adds (or overwrites) the value associated with the given key. Mapping a |
| 4041 // key to the hole value causes removal of the whole entry. |
| 4042 MUST_USE_RESULT MaybeObject* Put(Object* key, Object* value); |
| 4043 |
| 4044 private: |
| 4045 friend class MarkCompactCollector; |
| 4046 |
| 4047 void AddEntry(int entry, Object* key, Object* value); |
| 4048 |
| 4049 // Returns the index to the value of an entry. |
| 4050 static inline int EntryToValueIndex(int entry) { |
| 4051 return EntryToIndex(entry) + 1; |
| 4052 } |
| 4053 }; |
| 4054 |
| 4055 |
| 4015 // JSFunctionResultCache caches results of some JSFunction invocation. | 4056 // JSFunctionResultCache caches results of some JSFunction invocation. |
| 4016 // It is a fixed array with fixed structure: | 4057 // It is a fixed array with fixed structure: |
| 4017 // [0]: factory function | 4058 // [0]: factory function |
| 4018 // [1]: finger index | 4059 // [1]: finger index |
| 4019 // [2]: current cache size | 4060 // [2]: current cache size |
| 4020 // [3]: dummy field. | 4061 // [3]: dummy field. |
| 4021 // The rest of array are key/value pairs. | 4062 // The rest of array are key/value pairs. |
| 4022 class JSFunctionResultCache: public FixedArray { | 4063 class JSFunctionResultCache: public FixedArray { |
| 4023 public: | 4064 public: |
| 4024 static const int kFactoryIndex = 0; | 4065 static const int kFactoryIndex = 0; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4143 int ParameterIndex(String* name); | 4184 int ParameterIndex(String* name); |
| 4144 | 4185 |
| 4145 // Lookup support for serialized scope info. Returns the function context | 4186 // Lookup support for serialized scope info. Returns the function context |
| 4146 // slot index if the function name is present and context-allocated (named | 4187 // slot index if the function name is present and context-allocated (named |
| 4147 // function expressions, only), otherwise returns a value < 0. The name | 4188 // function expressions, only), otherwise returns a value < 0. The name |
| 4148 // must be an internalized string. | 4189 // must be an internalized string. |
| 4149 int FunctionContextSlotIndex(String* name, VariableMode* mode); | 4190 int FunctionContextSlotIndex(String* name, VariableMode* mode); |
| 4150 | 4191 |
| 4151 | 4192 |
| 4152 // Copies all the context locals into an object used to materialize a scope. | 4193 // Copies all the context locals into an object used to materialize a scope. |
| 4153 bool CopyContextLocalsToScopeObject(Isolate* isolate, | 4194 static bool CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, |
| 4154 Handle<Context> context, | 4195 Handle<Context> context, |
| 4155 Handle<JSObject> scope_object); | 4196 Handle<JSObject> scope_object); |
| 4156 | 4197 |
| 4157 | 4198 |
| 4158 static Handle<ScopeInfo> Create(Scope* scope, Zone* zone); | 4199 static Handle<ScopeInfo> Create(Scope* scope, Zone* zone); |
| 4159 | 4200 |
| 4160 // Serializes empty scope info. | 4201 // Serializes empty scope info. |
| 4161 static ScopeInfo* Empty(Isolate* isolate); | 4202 static ScopeInfo* Empty(Isolate* isolate); |
| 4162 | 4203 |
| 4163 #ifdef DEBUG | 4204 #ifdef DEBUG |
| 4164 void Print(); | 4205 void Print(); |
| 4165 #endif | 4206 #endif |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4796 class Code: public HeapObject { | 4837 class Code: public HeapObject { |
| 4797 public: | 4838 public: |
| 4798 // Opaque data type for encapsulating code flags like kind, inline | 4839 // Opaque data type for encapsulating code flags like kind, inline |
| 4799 // cache state, and arguments count. | 4840 // cache state, and arguments count. |
| 4800 typedef uint32_t Flags; | 4841 typedef uint32_t Flags; |
| 4801 | 4842 |
| 4802 #define NON_IC_KIND_LIST(V) \ | 4843 #define NON_IC_KIND_LIST(V) \ |
| 4803 V(FUNCTION) \ | 4844 V(FUNCTION) \ |
| 4804 V(OPTIMIZED_FUNCTION) \ | 4845 V(OPTIMIZED_FUNCTION) \ |
| 4805 V(STUB) \ | 4846 V(STUB) \ |
| 4847 V(HANDLER) \ |
| 4806 V(BUILTIN) \ | 4848 V(BUILTIN) \ |
| 4807 V(REGEXP) | 4849 V(REGEXP) |
| 4808 | 4850 |
| 4809 #define IC_KIND_LIST(V) \ | 4851 #define IC_KIND_LIST(V) \ |
| 4810 V(LOAD_IC) \ | 4852 V(LOAD_IC) \ |
| 4811 V(KEYED_LOAD_IC) \ | 4853 V(KEYED_LOAD_IC) \ |
| 4812 V(CALL_IC) \ | 4854 V(CALL_IC) \ |
| 4813 V(KEYED_CALL_IC) \ | 4855 V(KEYED_CALL_IC) \ |
| 4814 V(STORE_IC) \ | 4856 V(STORE_IC) \ |
| 4815 V(KEYED_STORE_IC) \ | 4857 V(KEYED_STORE_IC) \ |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4905 inline ByteArray* unchecked_relocation_info(); | 4947 inline ByteArray* unchecked_relocation_info(); |
| 4906 | 4948 |
| 4907 inline int relocation_size(); | 4949 inline int relocation_size(); |
| 4908 | 4950 |
| 4909 // [flags]: Various code flags. | 4951 // [flags]: Various code flags. |
| 4910 inline Flags flags(); | 4952 inline Flags flags(); |
| 4911 inline void set_flags(Flags flags); | 4953 inline void set_flags(Flags flags); |
| 4912 | 4954 |
| 4913 // [flags]: Access to specific code flags. | 4955 // [flags]: Access to specific code flags. |
| 4914 inline Kind kind(); | 4956 inline Kind kind(); |
| 4957 inline Kind handler_kind() { |
| 4958 return static_cast<Kind>(arguments_count()); |
| 4959 } |
| 4915 inline InlineCacheState ic_state(); // Only valid for IC stubs. | 4960 inline InlineCacheState ic_state(); // Only valid for IC stubs. |
| 4916 inline ExtraICState extra_ic_state(); // Only valid for IC stubs. | 4961 inline ExtraICState extra_ic_state(); // Only valid for IC stubs. |
| 4917 | 4962 |
| 4918 inline ExtraICState extended_extra_ic_state(); // Only valid for | 4963 inline ExtraICState extended_extra_ic_state(); // Only valid for |
| 4919 // non-call IC stubs. | 4964 // non-call IC stubs. |
| 4920 static bool needs_extended_extra_ic_state(Kind kind) { | 4965 static bool needs_extended_extra_ic_state(Kind kind) { |
| 4921 // TODO(danno): This is a bit of a hack right now since there are still | 4966 // TODO(danno): This is a bit of a hack right now since there are still |
| 4922 // clients of this API that pass "extra" values in for argc. These clients | 4967 // clients of this API that pass "extra" values in for argc. These clients |
| 4923 // should be retrofitted to used ExtendedExtraICState. | 4968 // should be retrofitted to used ExtendedExtraICState. |
| 4924 return kind == COMPARE_NIL_IC || kind == TO_BOOLEAN_IC; | 4969 return kind == COMPARE_NIL_IC || kind == TO_BOOLEAN_IC || |
| 4970 kind == BINARY_OP_IC; |
| 4925 } | 4971 } |
| 4926 | 4972 |
| 4927 inline StubType type(); // Only valid for monomorphic IC stubs. | 4973 inline StubType type(); // Only valid for monomorphic IC stubs. |
| 4928 inline int arguments_count(); // Only valid for call IC stubs. | 4974 inline int arguments_count(); // Only valid for call IC stubs. |
| 4929 | 4975 |
| 4930 // Testers for IC stub kinds. | 4976 // Testers for IC stub kinds. |
| 4931 inline bool is_inline_cache_stub(); | 4977 inline bool is_inline_cache_stub(); |
| 4932 inline bool is_debug_stub(); | 4978 inline bool is_debug_stub(); |
| 4979 inline bool is_handler() { return kind() == HANDLER; } |
| 4933 inline bool is_load_stub() { return kind() == LOAD_IC; } | 4980 inline bool is_load_stub() { return kind() == LOAD_IC; } |
| 4934 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } | 4981 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } |
| 4935 inline bool is_store_stub() { return kind() == STORE_IC; } | 4982 inline bool is_store_stub() { return kind() == STORE_IC; } |
| 4936 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } | 4983 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } |
| 4937 inline bool is_call_stub() { return kind() == CALL_IC; } | 4984 inline bool is_call_stub() { return kind() == CALL_IC; } |
| 4938 inline bool is_keyed_call_stub() { return kind() == KEYED_CALL_IC; } | 4985 inline bool is_keyed_call_stub() { return kind() == KEYED_CALL_IC; } |
| 4939 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } | 4986 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } |
| 4940 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } | 4987 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } |
| 4941 inline bool is_compare_nil_ic_stub() { return kind() == COMPARE_NIL_IC; } | 4988 inline bool is_compare_nil_ic_stub() { return kind() == COMPARE_NIL_IC; } |
| 4942 inline bool is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } | 4989 inline bool is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } |
| 4990 inline bool is_keyed_stub(); |
| 4943 | 4991 |
| 4944 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. | 4992 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. |
| 4945 inline int major_key(); | 4993 inline int major_key(); |
| 4946 inline void set_major_key(int value); | 4994 inline void set_major_key(int value); |
| 4947 | 4995 |
| 4948 // For kind STUB or ICs, tells whether or not a code object was generated by | 4996 // For kind STUB or ICs, tells whether or not a code object was generated by |
| 4949 // the optimizing compiler (but it may not be an optimized function). | 4997 // the optimizing compiler (but it may not be an optimized function). |
| 4950 bool is_crankshafted(); | 4998 bool is_crankshafted(); |
| 4951 inline void set_is_crankshafted(bool value); | 4999 inline void set_is_crankshafted(bool value); |
| 4952 | 5000 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5016 // cache is passed to the stub. | 5064 // cache is passed to the stub. |
| 5017 inline bool has_function_cache(); | 5065 inline bool has_function_cache(); |
| 5018 inline void set_has_function_cache(bool flag); | 5066 inline void set_has_function_cache(bool flag); |
| 5019 | 5067 |
| 5020 | 5068 |
| 5021 // [marked_for_deoptimization]: For kind OPTIMIZED_FUNCTION tells whether | 5069 // [marked_for_deoptimization]: For kind OPTIMIZED_FUNCTION tells whether |
| 5022 // the code is going to be deoptimized because of dead embedded maps. | 5070 // the code is going to be deoptimized because of dead embedded maps. |
| 5023 inline bool marked_for_deoptimization(); | 5071 inline bool marked_for_deoptimization(); |
| 5024 inline void set_marked_for_deoptimization(bool flag); | 5072 inline void set_marked_for_deoptimization(bool flag); |
| 5025 | 5073 |
| 5026 bool allowed_in_shared_map_code_cache(); | |
| 5027 | |
| 5028 // Get the safepoint entry for the given pc. | 5074 // Get the safepoint entry for the given pc. |
| 5029 SafepointEntry GetSafepointEntry(Address pc); | 5075 SafepointEntry GetSafepointEntry(Address pc); |
| 5030 | 5076 |
| 5031 // Find an object in a stub with a specified map | 5077 // Find an object in a stub with a specified map |
| 5032 Object* FindNthObject(int n, Map* match_map); | 5078 Object* FindNthObject(int n, Map* match_map); |
| 5033 void ReplaceNthObject(int n, Map* match_map, Object* replace_with); | 5079 void ReplaceNthObject(int n, Map* match_map, Object* replace_with); |
| 5034 | 5080 |
| 5035 // Find the first map in an IC stub. | 5081 // Find the first map in an IC stub. |
| 5036 Map* FindFirstMap(); | 5082 Map* FindFirstMap(); |
| 5037 void FindAllMaps(MapHandleList* maps); | 5083 void FindAllMaps(MapHandleList* maps); |
| 5038 void ReplaceFirstMap(Map* replace); | 5084 void ReplaceFirstMap(Map* replace); |
| 5039 | 5085 |
| 5040 // Find the first code in an IC stub. | 5086 // Find the first handler in an IC stub. |
| 5041 Code* FindFirstCode(); | 5087 Code* FindFirstHandler(); |
| 5042 void FindAllCode(CodeHandleList* code_list, int length); | 5088 |
| 5089 // Find |length| handlers and put them into |code_list|. Returns false if not |
| 5090 // enough handlers can be found. |
| 5091 MUST_USE_RESULT bool FindHandlers(CodeHandleList* code_list, int length); |
| 5043 | 5092 |
| 5044 // Find the first name in an IC stub. | 5093 // Find the first name in an IC stub. |
| 5045 Name* FindFirstName(); | 5094 Name* FindFirstName(); |
| 5046 | 5095 |
| 5047 void ReplaceNthCell(int n, Cell* replace_with); | 5096 void ReplaceNthCell(int n, Cell* replace_with); |
| 5048 | 5097 |
| 5049 class ExtraICStateStrictMode: public BitField<StrictModeFlag, 0, 1> {}; | 5098 class ExtraICStateStrictMode: public BitField<StrictModeFlag, 0, 1> {}; |
| 5050 class ExtraICStateKeyedAccessStoreMode: | 5099 class ExtraICStateKeyedAccessStoreMode: |
| 5051 public BitField<KeyedAccessStoreMode, 1, 4> {}; // NOLINT | 5100 public BitField<KeyedAccessStoreMode, 1, 4> {}; // NOLINT |
| 5052 | 5101 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5177 static void MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate); | 5226 static void MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate); |
| 5178 void MakeOlder(MarkingParity); | 5227 void MakeOlder(MarkingParity); |
| 5179 static bool IsYoungSequence(byte* sequence); | 5228 static bool IsYoungSequence(byte* sequence); |
| 5180 bool IsOld(); | 5229 bool IsOld(); |
| 5181 int GetAge(); | 5230 int GetAge(); |
| 5182 | 5231 |
| 5183 void PrintDeoptLocation(int bailout_id); | 5232 void PrintDeoptLocation(int bailout_id); |
| 5184 bool CanDeoptAt(Address pc); | 5233 bool CanDeoptAt(Address pc); |
| 5185 | 5234 |
| 5186 #ifdef VERIFY_HEAP | 5235 #ifdef VERIFY_HEAP |
| 5187 void VerifyEmbeddedMapsDependency(); | 5236 void VerifyEmbeddedObjectsDependency(); |
| 5188 #endif | 5237 #endif |
| 5189 | 5238 |
| 5239 static bool IsWeakEmbeddedObject(Kind kind, Object* object); |
| 5240 |
| 5190 // Max loop nesting marker used to postpose OSR. We don't take loop | 5241 // Max loop nesting marker used to postpose OSR. We don't take loop |
| 5191 // nesting that is deeper than 5 levels into account. | 5242 // nesting that is deeper than 5 levels into account. |
| 5192 static const int kMaxLoopNestingMarker = 6; | 5243 static const int kMaxLoopNestingMarker = 6; |
| 5193 | 5244 |
| 5194 // Layout description. | 5245 // Layout description. |
| 5195 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; | 5246 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; |
| 5196 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; | 5247 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; |
| 5197 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; | 5248 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; |
| 5198 static const int kDeoptimizationDataOffset = | 5249 static const int kDeoptimizationDataOffset = |
| 5199 kHandlerTableOffset + kPointerSize; | 5250 kHandlerTableOffset + kPointerSize; |
| (...skipping 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7922 bool IsValid() { return allocation_site()->IsAllocationSite(); } | 7973 bool IsValid() { return allocation_site()->IsAllocationSite(); } |
| 7923 AllocationSite* GetAllocationSite() { | 7974 AllocationSite* GetAllocationSite() { |
| 7924 ASSERT(IsValid()); | 7975 ASSERT(IsValid()); |
| 7925 return AllocationSite::cast(allocation_site()); | 7976 return AllocationSite::cast(allocation_site()); |
| 7926 } | 7977 } |
| 7927 | 7978 |
| 7928 DECLARE_PRINTER(AllocationMemento) | 7979 DECLARE_PRINTER(AllocationMemento) |
| 7929 DECLARE_VERIFIER(AllocationMemento) | 7980 DECLARE_VERIFIER(AllocationMemento) |
| 7930 | 7981 |
| 7931 // Returns NULL if no AllocationMemento is available for object. | 7982 // Returns NULL if no AllocationMemento is available for object. |
| 7932 static AllocationMemento* FindForJSObject(JSObject* object); | 7983 static AllocationMemento* FindForJSObject(JSObject* object, |
| 7984 bool in_GC = false); |
| 7933 static inline AllocationMemento* cast(Object* obj); | 7985 static inline AllocationMemento* cast(Object* obj); |
| 7934 | 7986 |
| 7935 private: | 7987 private: |
| 7936 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationMemento); | 7988 DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationMemento); |
| 7937 }; | 7989 }; |
| 7938 | 7990 |
| 7939 | 7991 |
| 7940 // Representation of a slow alias as part of a non-strict arguments objects. | 7992 // Representation of a slow alias as part of a non-strict arguments objects. |
| 7941 // For fast aliases (if HasNonStrictArgumentsElements()): | 7993 // For fast aliases (if HasNonStrictArgumentsElements()): |
| 7942 // - the parameter map contains an index into the context | 7994 // - the parameter map contains an index into the context |
| (...skipping 2330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10273 } else { | 10325 } else { |
| 10274 value &= ~(1 << bit_position); | 10326 value &= ~(1 << bit_position); |
| 10275 } | 10327 } |
| 10276 return value; | 10328 return value; |
| 10277 } | 10329 } |
| 10278 }; | 10330 }; |
| 10279 | 10331 |
| 10280 } } // namespace v8::internal | 10332 } } // namespace v8::internal |
| 10281 | 10333 |
| 10282 #endif // V8_OBJECTS_H_ | 10334 #endif // V8_OBJECTS_H_ |
| OLD | NEW |