| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 260 } |
| 261 | 261 |
| 262 bool Object::HasValidElements() { | 262 bool Object::HasValidElements() { |
| 263 // Dictionary is covered under FixedArray. | 263 // Dictionary is covered under FixedArray. |
| 264 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); | 264 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 | 267 |
| 268 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, | 268 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, |
| 269 Representation representation) { | 269 Representation representation) { |
| 270 if (FLAG_track_fields && representation.IsSmi() && IsUninitialized()) { |
| 271 return Smi::FromInt(0); |
| 272 } |
| 270 if (!FLAG_track_double_fields) return this; | 273 if (!FLAG_track_double_fields) return this; |
| 271 if (!representation.IsDouble()) return this; | 274 if (!representation.IsDouble()) return this; |
| 272 if (IsUninitialized()) { | 275 if (IsUninitialized()) { |
| 273 return heap->AllocateHeapNumber(0); | 276 return heap->AllocateHeapNumber(0); |
| 274 } | 277 } |
| 275 return heap->AllocateHeapNumber(Number()); | 278 return heap->AllocateHeapNumber(Number()); |
| 276 } | 279 } |
| 277 | 280 |
| 278 | 281 |
| 279 StringShape::StringShape(String* str) | 282 StringShape::StringShape(String* str) |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 void JSObject::ValidateElements() { | 1293 void JSObject::ValidateElements() { |
| 1291 #ifdef ENABLE_SLOW_ASSERTS | 1294 #ifdef ENABLE_SLOW_ASSERTS |
| 1292 if (FLAG_enable_slow_asserts) { | 1295 if (FLAG_enable_slow_asserts) { |
| 1293 ElementsAccessor* accessor = GetElementsAccessor(); | 1296 ElementsAccessor* accessor = GetElementsAccessor(); |
| 1294 accessor->Validate(this); | 1297 accessor->Validate(this); |
| 1295 } | 1298 } |
| 1296 #endif | 1299 #endif |
| 1297 } | 1300 } |
| 1298 | 1301 |
| 1299 | 1302 |
| 1300 bool JSObject::ShouldTrackAllocationInfo() { | |
| 1301 if (AllocationSite::CanTrack(map()->instance_type())) { | |
| 1302 if (!IsJSArray()) { | |
| 1303 return true; | |
| 1304 } | |
| 1305 | |
| 1306 return AllocationSite::GetMode(GetElementsKind()) == | |
| 1307 TRACK_ALLOCATION_SITE; | |
| 1308 } | |
| 1309 return false; | |
| 1310 } | |
| 1311 | |
| 1312 | |
| 1313 void AllocationSite::Initialize() { | 1303 void AllocationSite::Initialize() { |
| 1314 set_transition_info(Smi::FromInt(0)); | 1304 set_transition_info(Smi::FromInt(0)); |
| 1315 SetElementsKind(GetInitialFastElementsKind()); | 1305 SetElementsKind(GetInitialFastElementsKind()); |
| 1316 set_nested_site(Smi::FromInt(0)); | 1306 set_nested_site(Smi::FromInt(0)); |
| 1317 set_memento_create_count(Smi::FromInt(0)); | 1307 set_memento_create_count(Smi::FromInt(0)); |
| 1318 set_memento_found_count(Smi::FromInt(0)); | 1308 set_memento_found_count(Smi::FromInt(0)); |
| 1319 set_pretenure_decision(Smi::FromInt(0)); | 1309 set_pretenure_decision(Smi::FromInt(0)); |
| 1320 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), | 1310 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), |
| 1321 SKIP_WRITE_BARRIER); | 1311 SKIP_WRITE_BARRIER); |
| 1322 } | 1312 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1352 IsMoreGeneralElementsKindTransition(from, to)) { | 1342 IsMoreGeneralElementsKindTransition(from, to)) { |
| 1353 return TRACK_ALLOCATION_SITE; | 1343 return TRACK_ALLOCATION_SITE; |
| 1354 } | 1344 } |
| 1355 | 1345 |
| 1356 return DONT_TRACK_ALLOCATION_SITE; | 1346 return DONT_TRACK_ALLOCATION_SITE; |
| 1357 } | 1347 } |
| 1358 | 1348 |
| 1359 | 1349 |
| 1360 inline bool AllocationSite::CanTrack(InstanceType type) { | 1350 inline bool AllocationSite::CanTrack(InstanceType type) { |
| 1361 if (FLAG_allocation_site_pretenuring) { | 1351 if (FLAG_allocation_site_pretenuring) { |
| 1362 return type == JS_ARRAY_TYPE || type == JS_OBJECT_TYPE; | 1352 return type == JS_ARRAY_TYPE || |
| 1353 type == JS_OBJECT_TYPE || |
| 1354 type < FIRST_NONSTRING_TYPE; |
| 1363 } | 1355 } |
| 1364 return type == JS_ARRAY_TYPE; | 1356 return type == JS_ARRAY_TYPE; |
| 1365 } | 1357 } |
| 1366 | 1358 |
| 1367 | 1359 |
| 1368 inline DependentCode::DependencyGroup AllocationSite::ToDependencyGroup( | 1360 inline DependentCode::DependencyGroup AllocationSite::ToDependencyGroup( |
| 1369 Reason reason) { | 1361 Reason reason) { |
| 1370 switch (reason) { | 1362 switch (reason) { |
| 1371 case TENURING: | 1363 case TENURING: |
| 1372 return DependentCode::kAllocationSiteTenuringChangedGroup; | 1364 return DependentCode::kAllocationSiteTenuringChangedGroup; |
| 1373 break; | 1365 break; |
| 1374 case TRANSITIONS: | 1366 case TRANSITIONS: |
| 1375 return DependentCode::kAllocationSiteTransitionChangedGroup; | 1367 return DependentCode::kAllocationSiteTransitionChangedGroup; |
| 1376 break; | 1368 break; |
| 1377 } | 1369 } |
| 1378 UNREACHABLE(); | 1370 UNREACHABLE(); |
| 1379 return DependentCode::kAllocationSiteTransitionChangedGroup; | 1371 return DependentCode::kAllocationSiteTransitionChangedGroup; |
| 1380 } | 1372 } |
| 1381 | 1373 |
| 1382 | 1374 |
| 1383 inline void AllocationSite::IncrementMementoFoundCount() { | 1375 inline bool AllocationSite::IncrementMementoFoundCount() { |
| 1376 if (IsZombie()) return false; |
| 1377 |
| 1384 int value = memento_found_count()->value(); | 1378 int value = memento_found_count()->value(); |
| 1385 set_memento_found_count(Smi::FromInt(value + 1)); | 1379 set_memento_found_count(Smi::FromInt(value + 1)); |
| 1380 return value == 0; |
| 1386 } | 1381 } |
| 1387 | 1382 |
| 1388 | 1383 |
| 1389 inline void AllocationSite::IncrementMementoCreateCount() { | 1384 inline void AllocationSite::IncrementMementoCreateCount() { |
| 1390 ASSERT(FLAG_allocation_site_pretenuring); | 1385 ASSERT(FLAG_allocation_site_pretenuring); |
| 1391 int value = memento_create_count()->value(); | 1386 int value = memento_create_count()->value(); |
| 1392 set_memento_create_count(Smi::FromInt(value + 1)); | 1387 set_memento_create_count(Smi::FromInt(value + 1)); |
| 1393 } | 1388 } |
| 1394 | 1389 |
| 1395 | 1390 |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2364 if (number != TransitionArray::kNotFound) { | 2359 if (number != TransitionArray::kNotFound) { |
| 2365 return result->TransitionResult(holder, number); | 2360 return result->TransitionResult(holder, number); |
| 2366 } | 2361 } |
| 2367 } | 2362 } |
| 2368 result->NotFound(); | 2363 result->NotFound(); |
| 2369 } | 2364 } |
| 2370 | 2365 |
| 2371 | 2366 |
| 2372 Object** DescriptorArray::GetKeySlot(int descriptor_number) { | 2367 Object** DescriptorArray::GetKeySlot(int descriptor_number) { |
| 2373 ASSERT(descriptor_number < number_of_descriptors()); | 2368 ASSERT(descriptor_number < number_of_descriptors()); |
| 2374 return HeapObject::RawField( | 2369 return RawFieldOfElementAt(ToKeyIndex(descriptor_number)); |
| 2375 reinterpret_cast<HeapObject*>(this), | |
| 2376 OffsetOfElementAt(ToKeyIndex(descriptor_number))); | |
| 2377 } | 2370 } |
| 2378 | 2371 |
| 2379 | 2372 |
| 2380 Object** DescriptorArray::GetDescriptorStartSlot(int descriptor_number) { | 2373 Object** DescriptorArray::GetDescriptorStartSlot(int descriptor_number) { |
| 2381 return GetKeySlot(descriptor_number); | 2374 return GetKeySlot(descriptor_number); |
| 2382 } | 2375 } |
| 2383 | 2376 |
| 2384 | 2377 |
| 2385 Object** DescriptorArray::GetDescriptorEndSlot(int descriptor_number) { | 2378 Object** DescriptorArray::GetDescriptorEndSlot(int descriptor_number) { |
| 2386 return GetValueSlot(descriptor_number - 1) + 1; | 2379 return GetValueSlot(descriptor_number - 1) + 1; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2421 void DescriptorArray::InitializeRepresentations(Representation representation) { | 2414 void DescriptorArray::InitializeRepresentations(Representation representation) { |
| 2422 int length = number_of_descriptors(); | 2415 int length = number_of_descriptors(); |
| 2423 for (int i = 0; i < length; i++) { | 2416 for (int i = 0; i < length; i++) { |
| 2424 SetRepresentation(i, representation); | 2417 SetRepresentation(i, representation); |
| 2425 } | 2418 } |
| 2426 } | 2419 } |
| 2427 | 2420 |
| 2428 | 2421 |
| 2429 Object** DescriptorArray::GetValueSlot(int descriptor_number) { | 2422 Object** DescriptorArray::GetValueSlot(int descriptor_number) { |
| 2430 ASSERT(descriptor_number < number_of_descriptors()); | 2423 ASSERT(descriptor_number < number_of_descriptors()); |
| 2431 return HeapObject::RawField( | 2424 return RawFieldOfElementAt(ToValueIndex(descriptor_number)); |
| 2432 reinterpret_cast<HeapObject*>(this), | |
| 2433 OffsetOfElementAt(ToValueIndex(descriptor_number))); | |
| 2434 } | 2425 } |
| 2435 | 2426 |
| 2436 | 2427 |
| 2437 Object* DescriptorArray::GetValue(int descriptor_number) { | 2428 Object* DescriptorArray::GetValue(int descriptor_number) { |
| 2438 ASSERT(descriptor_number < number_of_descriptors()); | 2429 ASSERT(descriptor_number < number_of_descriptors()); |
| 2439 return get(ToValueIndex(descriptor_number)); | 2430 return get(ToValueIndex(descriptor_number)); |
| 2440 } | 2431 } |
| 2441 | 2432 |
| 2442 | 2433 |
| 2443 PropertyDetails DescriptorArray::GetDetails(int descriptor_number) { | 2434 PropertyDetails DescriptorArray::GetDetails(int descriptor_number) { |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3224 | 3215 |
| 3225 | 3216 |
| 3226 void JSFunctionResultCache::MakeZeroSize() { | 3217 void JSFunctionResultCache::MakeZeroSize() { |
| 3227 set_finger_index(kEntriesIndex); | 3218 set_finger_index(kEntriesIndex); |
| 3228 set_size(kEntriesIndex); | 3219 set_size(kEntriesIndex); |
| 3229 } | 3220 } |
| 3230 | 3221 |
| 3231 | 3222 |
| 3232 void JSFunctionResultCache::Clear() { | 3223 void JSFunctionResultCache::Clear() { |
| 3233 int cache_size = size(); | 3224 int cache_size = size(); |
| 3234 Object** entries_start = RawField(this, OffsetOfElementAt(kEntriesIndex)); | 3225 Object** entries_start = RawFieldOfElementAt(kEntriesIndex); |
| 3235 MemsetPointer(entries_start, | 3226 MemsetPointer(entries_start, |
| 3236 GetHeap()->the_hole_value(), | 3227 GetHeap()->the_hole_value(), |
| 3237 cache_size - kEntriesIndex); | 3228 cache_size - kEntriesIndex); |
| 3238 MakeZeroSize(); | 3229 MakeZeroSize(); |
| 3239 } | 3230 } |
| 3240 | 3231 |
| 3241 | 3232 |
| 3242 int JSFunctionResultCache::size() { | 3233 int JSFunctionResultCache::size() { |
| 3243 return Smi::cast(get(kCacheSizeIndex))->value(); | 3234 return Smi::cast(get(kCacheSizeIndex))->value(); |
| 3244 } | 3235 } |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3830 set(kCodesStartIndex + i, object); | 3821 set(kCodesStartIndex + i, object); |
| 3831 } | 3822 } |
| 3832 | 3823 |
| 3833 | 3824 |
| 3834 Object* DependentCode::object_at(int i) { | 3825 Object* DependentCode::object_at(int i) { |
| 3835 return get(kCodesStartIndex + i); | 3826 return get(kCodesStartIndex + i); |
| 3836 } | 3827 } |
| 3837 | 3828 |
| 3838 | 3829 |
| 3839 Object** DependentCode::slot_at(int i) { | 3830 Object** DependentCode::slot_at(int i) { |
| 3840 return HeapObject::RawField( | 3831 return RawFieldOfElementAt(kCodesStartIndex + i); |
| 3841 this, FixedArray::OffsetOfElementAt(kCodesStartIndex + i)); | |
| 3842 } | 3832 } |
| 3843 | 3833 |
| 3844 | 3834 |
| 3845 void DependentCode::clear_at(int i) { | 3835 void DependentCode::clear_at(int i) { |
| 3846 set_undefined(kCodesStartIndex + i); | 3836 set_undefined(kCodesStartIndex + i); |
| 3847 } | 3837 } |
| 3848 | 3838 |
| 3849 | 3839 |
| 3850 void DependentCode::copy(int from, int to) { | 3840 void DependentCode::copy(int from, int to) { |
| 3851 set(kCodesStartIndex + to, get(kCodesStartIndex + from)); | 3841 set(kCodesStartIndex + to, get(kCodesStartIndex + from)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3908 } | 3898 } |
| 3909 | 3899 |
| 3910 | 3900 |
| 3911 int Code::arguments_count() { | 3901 int Code::arguments_count() { |
| 3912 ASSERT(is_call_stub() || is_keyed_call_stub() || | 3902 ASSERT(is_call_stub() || is_keyed_call_stub() || |
| 3913 kind() == STUB || is_handler()); | 3903 kind() == STUB || is_handler()); |
| 3914 return ExtractArgumentsCountFromFlags(flags()); | 3904 return ExtractArgumentsCountFromFlags(flags()); |
| 3915 } | 3905 } |
| 3916 | 3906 |
| 3917 | 3907 |
| 3908 // For initialization. |
| 3909 void Code::set_raw_kind_specific_flags1(int value) { |
| 3910 WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value); |
| 3911 } |
| 3912 |
| 3913 |
| 3914 void Code::set_raw_kind_specific_flags2(int value) { |
| 3915 WRITE_INT_FIELD(this, kKindSpecificFlags2Offset, value); |
| 3916 } |
| 3917 |
| 3918 |
| 3918 inline bool Code::is_crankshafted() { | 3919 inline bool Code::is_crankshafted() { |
| 3919 return IsCrankshaftedField::decode( | 3920 return IsCrankshaftedField::decode( |
| 3920 READ_UINT32_FIELD(this, kKindSpecificFlags2Offset)); | 3921 READ_UINT32_FIELD(this, kKindSpecificFlags2Offset)); |
| 3921 } | 3922 } |
| 3922 | 3923 |
| 3923 | 3924 |
| 3924 inline void Code::set_is_crankshafted(bool value) { | 3925 inline void Code::set_is_crankshafted(bool value) { |
| 3925 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); | 3926 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
| 3926 int updated = IsCrankshaftedField::update(previous, value); | 3927 int updated = IsCrankshaftedField::update(previous, value); |
| 3927 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | 3928 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4169 bool Code::is_keyed_stub() { | 4170 bool Code::is_keyed_stub() { |
| 4170 return is_keyed_load_stub() || is_keyed_store_stub() || is_keyed_call_stub(); | 4171 return is_keyed_load_stub() || is_keyed_store_stub() || is_keyed_call_stub(); |
| 4171 } | 4172 } |
| 4172 | 4173 |
| 4173 | 4174 |
| 4174 bool Code::is_debug_stub() { | 4175 bool Code::is_debug_stub() { |
| 4175 return ic_state() == DEBUG_STUB; | 4176 return ic_state() == DEBUG_STUB; |
| 4176 } | 4177 } |
| 4177 | 4178 |
| 4178 | 4179 |
| 4180 ConstantPoolArray* Code::constant_pool() { |
| 4181 return ConstantPoolArray::cast(READ_FIELD(this, kConstantPoolOffset)); |
| 4182 } |
| 4183 |
| 4184 |
| 4185 void Code::set_constant_pool(Object* value) { |
| 4186 ASSERT(value->IsConstantPoolArray()); |
| 4187 WRITE_FIELD(this, kConstantPoolOffset, value); |
| 4188 WRITE_BARRIER(GetHeap(), this, kConstantPoolOffset, value); |
| 4189 } |
| 4190 |
| 4191 |
| 4179 Code::Flags Code::ComputeFlags(Kind kind, | 4192 Code::Flags Code::ComputeFlags(Kind kind, |
| 4180 InlineCacheState ic_state, | 4193 InlineCacheState ic_state, |
| 4181 ExtraICState extra_ic_state, | 4194 ExtraICState extra_ic_state, |
| 4182 StubType type, | 4195 StubType type, |
| 4183 int argc, | 4196 int argc, |
| 4184 InlineCacheHolderFlag holder) { | 4197 InlineCacheHolderFlag holder) { |
| 4185 ASSERT(argc <= Code::kMaxArguments); | 4198 ASSERT(argc <= Code::kMaxArguments); |
| 4186 // Since the extended extra ic state overlaps with the argument count | 4199 // Since the extended extra ic state overlaps with the argument count |
| 4187 // for CALL_ICs, do so checks to make sure that they don't interfere. | 4200 // for CALL_ICs, do so checks to make sure that they don't interfere. |
| 4188 ASSERT((kind != Code::CALL_IC && | 4201 ASSERT((kind != Code::CALL_IC && |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4939 CONDITIONAL_WRITE_BARRIER(GetHeap(), | 4952 CONDITIONAL_WRITE_BARRIER(GetHeap(), |
| 4940 this, | 4953 this, |
| 4941 kScopeInfoOffset, | 4954 kScopeInfoOffset, |
| 4942 reinterpret_cast<Object*>(value), | 4955 reinterpret_cast<Object*>(value), |
| 4943 mode); | 4956 mode); |
| 4944 } | 4957 } |
| 4945 | 4958 |
| 4946 | 4959 |
| 4947 bool SharedFunctionInfo::is_compiled() { | 4960 bool SharedFunctionInfo::is_compiled() { |
| 4948 return code() != | 4961 return code() != |
| 4949 GetIsolate()->builtins()->builtin(Builtins::kLazyCompile); | 4962 GetIsolate()->builtins()->builtin(Builtins::kCompileUnoptimized); |
| 4950 } | 4963 } |
| 4951 | 4964 |
| 4952 | 4965 |
| 4953 bool SharedFunctionInfo::IsApiFunction() { | 4966 bool SharedFunctionInfo::IsApiFunction() { |
| 4954 return function_data()->IsFunctionTemplateInfo(); | 4967 return function_data()->IsFunctionTemplateInfo(); |
| 4955 } | 4968 } |
| 4956 | 4969 |
| 4957 | 4970 |
| 4958 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() { | 4971 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() { |
| 4959 ASSERT(IsApiFunction()); | 4972 ASSERT(IsApiFunction()); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5062 bool JSFunction::IsOptimized() { | 5075 bool JSFunction::IsOptimized() { |
| 5063 return code()->kind() == Code::OPTIMIZED_FUNCTION; | 5076 return code()->kind() == Code::OPTIMIZED_FUNCTION; |
| 5064 } | 5077 } |
| 5065 | 5078 |
| 5066 | 5079 |
| 5067 bool JSFunction::IsOptimizable() { | 5080 bool JSFunction::IsOptimizable() { |
| 5068 return code()->kind() == Code::FUNCTION && code()->optimizable(); | 5081 return code()->kind() == Code::FUNCTION && code()->optimizable(); |
| 5069 } | 5082 } |
| 5070 | 5083 |
| 5071 | 5084 |
| 5072 bool JSFunction::IsMarkedForLazyRecompilation() { | 5085 bool JSFunction::IsMarkedForOptimization() { |
| 5073 return code() == GetIsolate()->builtins()->builtin(Builtins::kLazyRecompile); | 5086 return code() == GetIsolate()->builtins()->builtin( |
| 5087 Builtins::kCompileOptimized); |
| 5074 } | 5088 } |
| 5075 | 5089 |
| 5076 | 5090 |
| 5077 bool JSFunction::IsMarkedForConcurrentRecompilation() { | 5091 bool JSFunction::IsMarkedForConcurrentOptimization() { |
| 5078 return code() == GetIsolate()->builtins()->builtin( | 5092 return code() == GetIsolate()->builtins()->builtin( |
| 5079 Builtins::kConcurrentRecompile); | 5093 Builtins::kCompileOptimizedConcurrent); |
| 5080 } | 5094 } |
| 5081 | 5095 |
| 5082 | 5096 |
| 5083 bool JSFunction::IsInRecompileQueue() { | 5097 bool JSFunction::IsInOptimizationQueue() { |
| 5084 return code() == GetIsolate()->builtins()->builtin( | 5098 return code() == GetIsolate()->builtins()->builtin( |
| 5085 Builtins::kInRecompileQueue); | 5099 Builtins::kInOptimizationQueue); |
| 5086 } | 5100 } |
| 5087 | 5101 |
| 5088 | 5102 |
| 5089 Code* JSFunction::code() { | 5103 Code* JSFunction::code() { |
| 5090 return Code::cast( | 5104 return Code::cast( |
| 5091 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset))); | 5105 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset))); |
| 5092 } | 5106 } |
| 5093 | 5107 |
| 5094 | 5108 |
| 5095 void JSFunction::set_code(Code* value) { | 5109 void JSFunction::set_code(Code* value) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5107 ASSERT(!GetHeap()->InNewSpace(value)); | 5121 ASSERT(!GetHeap()->InNewSpace(value)); |
| 5108 Address entry = value->entry(); | 5122 Address entry = value->entry(); |
| 5109 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); | 5123 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); |
| 5110 } | 5124 } |
| 5111 | 5125 |
| 5112 | 5126 |
| 5113 void JSFunction::ReplaceCode(Code* code) { | 5127 void JSFunction::ReplaceCode(Code* code) { |
| 5114 bool was_optimized = IsOptimized(); | 5128 bool was_optimized = IsOptimized(); |
| 5115 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; | 5129 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; |
| 5116 | 5130 |
| 5131 if (was_optimized && is_optimized) { |
| 5132 shared()->EvictFromOptimizedCodeMap( |
| 5133 this->code(), "Replacing with another optimized code"); |
| 5134 } |
| 5135 |
| 5117 set_code(code); | 5136 set_code(code); |
| 5118 | 5137 |
| 5119 // Add/remove the function from the list of optimized functions for this | 5138 // Add/remove the function from the list of optimized functions for this |
| 5120 // context based on the state change. | 5139 // context based on the state change. |
| 5121 if (!was_optimized && is_optimized) { | 5140 if (!was_optimized && is_optimized) { |
| 5122 context()->native_context()->AddOptimizedFunction(this); | 5141 context()->native_context()->AddOptimizedFunction(this); |
| 5123 } | 5142 } |
| 5124 if (was_optimized && !is_optimized) { | 5143 if (was_optimized && !is_optimized) { |
| 5125 // TODO(titzer): linear in the number of optimized functions; fix! | 5144 // TODO(titzer): linear in the number of optimized functions; fix! |
| 5126 context()->native_context()->RemoveOptimizedFunction(this); | 5145 context()->native_context()->RemoveOptimizedFunction(this); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5185 return instance_prototype(); | 5204 return instance_prototype(); |
| 5186 } | 5205 } |
| 5187 | 5206 |
| 5188 | 5207 |
| 5189 bool JSFunction::should_have_prototype() { | 5208 bool JSFunction::should_have_prototype() { |
| 5190 return map()->function_with_prototype(); | 5209 return map()->function_with_prototype(); |
| 5191 } | 5210 } |
| 5192 | 5211 |
| 5193 | 5212 |
| 5194 bool JSFunction::is_compiled() { | 5213 bool JSFunction::is_compiled() { |
| 5195 return code() != GetIsolate()->builtins()->builtin(Builtins::kLazyCompile); | 5214 return code() != |
| 5215 GetIsolate()->builtins()->builtin(Builtins::kCompileUnoptimized); |
| 5196 } | 5216 } |
| 5197 | 5217 |
| 5198 | 5218 |
| 5199 FixedArray* JSFunction::literals() { | 5219 FixedArray* JSFunction::literals() { |
| 5200 ASSERT(!shared()->bound()); | 5220 ASSERT(!shared()->bound()); |
| 5201 return literals_or_bindings(); | 5221 return literals_or_bindings(); |
| 5202 } | 5222 } |
| 5203 | 5223 |
| 5204 | 5224 |
| 5205 void JSFunction::set_literals(FixedArray* literals) { | 5225 void JSFunction::set_literals(FixedArray* literals) { |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5884 | 5904 |
| 5885 PropertyAttributes JSReceiver::GetElementAttribute(uint32_t index) { | 5905 PropertyAttributes JSReceiver::GetElementAttribute(uint32_t index) { |
| 5886 if (IsJSProxy()) { | 5906 if (IsJSProxy()) { |
| 5887 return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index); | 5907 return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index); |
| 5888 } | 5908 } |
| 5889 return JSObject::cast(this)->GetElementAttributeWithReceiver( | 5909 return JSObject::cast(this)->GetElementAttributeWithReceiver( |
| 5890 this, index, true); | 5910 this, index, true); |
| 5891 } | 5911 } |
| 5892 | 5912 |
| 5893 | 5913 |
| 5894 // TODO(504): this may be useful in other places too where JSGlobalProxy | 5914 bool JSGlobalObject::IsDetached() { |
| 5895 // is used. | 5915 return JSGlobalProxy::cast(global_receiver())->IsDetachedFrom(this); |
| 5896 Object* JSObject::BypassGlobalProxy() { | |
| 5897 if (IsJSGlobalProxy()) { | |
| 5898 Object* proto = GetPrototype(); | |
| 5899 if (proto->IsNull()) return GetHeap()->undefined_value(); | |
| 5900 ASSERT(proto->IsJSGlobalObject()); | |
| 5901 return proto; | |
| 5902 } | |
| 5903 return this; | |
| 5904 } | 5916 } |
| 5905 | 5917 |
| 5906 | 5918 |
| 5919 bool JSGlobalProxy::IsDetachedFrom(GlobalObject* global) { |
| 5920 return GetPrototype() != global; |
| 5921 } |
| 5922 |
| 5923 |
| 5907 Handle<Object> JSReceiver::GetOrCreateIdentityHash(Handle<JSReceiver> object) { | 5924 Handle<Object> JSReceiver::GetOrCreateIdentityHash(Handle<JSReceiver> object) { |
| 5908 return object->IsJSProxy() | 5925 return object->IsJSProxy() |
| 5909 ? JSProxy::GetOrCreateIdentityHash(Handle<JSProxy>::cast(object)) | 5926 ? JSProxy::GetOrCreateIdentityHash(Handle<JSProxy>::cast(object)) |
| 5910 : JSObject::GetOrCreateIdentityHash(Handle<JSObject>::cast(object)); | 5927 : JSObject::GetOrCreateIdentityHash(Handle<JSObject>::cast(object)); |
| 5911 } | 5928 } |
| 5912 | 5929 |
| 5913 | 5930 |
| 5914 Object* JSReceiver::GetIdentityHash() { | 5931 Object* JSReceiver::GetIdentityHash() { |
| 5915 return IsJSProxy() | 5932 return IsJSProxy() |
| 5916 ? JSProxy::cast(this)->GetIdentityHash() | 5933 ? JSProxy::cast(this)->GetIdentityHash() |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6463 #undef WRITE_UINT32_FIELD | 6480 #undef WRITE_UINT32_FIELD |
| 6464 #undef READ_SHORT_FIELD | 6481 #undef READ_SHORT_FIELD |
| 6465 #undef WRITE_SHORT_FIELD | 6482 #undef WRITE_SHORT_FIELD |
| 6466 #undef READ_BYTE_FIELD | 6483 #undef READ_BYTE_FIELD |
| 6467 #undef WRITE_BYTE_FIELD | 6484 #undef WRITE_BYTE_FIELD |
| 6468 | 6485 |
| 6469 | 6486 |
| 6470 } } // namespace v8::internal | 6487 } } // namespace v8::internal |
| 6471 | 6488 |
| 6472 #endif // V8_OBJECTS_INL_H_ | 6489 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |