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

Side by Side Diff: src/objects-inl.h

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | src/objects-printer.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 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 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 SetElementsKind(GetInitialFastElementsKind()); 1315 SetElementsKind(GetInitialFastElementsKind());
1316 set_nested_site(Smi::FromInt(0)); 1316 set_nested_site(Smi::FromInt(0));
1317 set_memento_create_count(Smi::FromInt(0)); 1317 set_memento_create_count(Smi::FromInt(0));
1318 set_memento_found_count(Smi::FromInt(0)); 1318 set_memento_found_count(Smi::FromInt(0));
1319 set_pretenure_decision(Smi::FromInt(0)); 1319 set_pretenure_decision(Smi::FromInt(0));
1320 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), 1320 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()),
1321 SKIP_WRITE_BARRIER); 1321 SKIP_WRITE_BARRIER);
1322 } 1322 }
1323 1323
1324 1324
1325 void AllocationSite::MarkZombie() {
1326 ASSERT(!IsZombie());
1327 set_pretenure_decision(Smi::FromInt(kZombie));
1328 // Clear all non-smi fields
1329 set_transition_info(Smi::FromInt(0));
1330 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()),
1331 SKIP_WRITE_BARRIER);
1332 }
1333
1334
1325 // Heuristic: We only need to create allocation site info if the boilerplate 1335 // Heuristic: We only need to create allocation site info if the boilerplate
1326 // elements kind is the initial elements kind. 1336 // elements kind is the initial elements kind.
1327 AllocationSiteMode AllocationSite::GetMode( 1337 AllocationSiteMode AllocationSite::GetMode(
1328 ElementsKind boilerplate_elements_kind) { 1338 ElementsKind boilerplate_elements_kind) {
1329 if (FLAG_track_allocation_sites && 1339 if (FLAG_track_allocation_sites &&
1330 IsFastSmiElementsKind(boilerplate_elements_kind)) { 1340 IsFastSmiElementsKind(boilerplate_elements_kind)) {
1331 return TRACK_ALLOCATION_SITE; 1341 return TRACK_ALLOCATION_SITE;
1332 } 1342 }
1333 1343
1334 return DONT_TRACK_ALLOCATION_SITE; 1344 return DONT_TRACK_ALLOCATION_SITE;
1335 } 1345 }
1336 1346
1337 1347
1338 AllocationSiteMode AllocationSite::GetMode(ElementsKind from, 1348 AllocationSiteMode AllocationSite::GetMode(ElementsKind from,
1339 ElementsKind to) { 1349 ElementsKind to) {
1340 if (FLAG_track_allocation_sites && 1350 if (FLAG_track_allocation_sites &&
1341 IsFastSmiElementsKind(from) && 1351 IsFastSmiElementsKind(from) &&
1342 IsMoreGeneralElementsKindTransition(from, to)) { 1352 IsMoreGeneralElementsKindTransition(from, to)) {
1343 return TRACK_ALLOCATION_SITE; 1353 return TRACK_ALLOCATION_SITE;
1344 } 1354 }
1345 1355
1346 return DONT_TRACK_ALLOCATION_SITE; 1356 return DONT_TRACK_ALLOCATION_SITE;
1347 } 1357 }
1348 1358
1349 1359
1350 inline bool AllocationSite::CanTrack(InstanceType type) { 1360 inline bool AllocationSite::CanTrack(InstanceType type) {
1361 if (FLAG_allocation_site_pretenuring) {
1362 return type == JS_ARRAY_TYPE || type == JS_OBJECT_TYPE;
1363 }
1351 return type == JS_ARRAY_TYPE; 1364 return type == JS_ARRAY_TYPE;
1352 } 1365 }
1353 1366
1354 1367
1355 inline DependentCode::DependencyGroup AllocationSite::ToDependencyGroup( 1368 inline DependentCode::DependencyGroup AllocationSite::ToDependencyGroup(
1356 Reason reason) { 1369 Reason reason) {
1357 switch (reason) { 1370 switch (reason) {
1358 case TENURING: 1371 case TENURING:
1359 return DependentCode::kAllocationSiteTenuringChangedGroup; 1372 return DependentCode::kAllocationSiteTenuringChangedGroup;
1360 break; 1373 break;
1361 case TRANSITIONS: 1374 case TRANSITIONS:
1362 return DependentCode::kAllocationSiteTransitionChangedGroup; 1375 return DependentCode::kAllocationSiteTransitionChangedGroup;
1363 break; 1376 break;
1364 } 1377 }
1365 UNREACHABLE(); 1378 UNREACHABLE();
1366 return DependentCode::kAllocationSiteTransitionChangedGroup; 1379 return DependentCode::kAllocationSiteTransitionChangedGroup;
1367 } 1380 }
1368 1381
1369 1382
1383 inline void AllocationSite::IncrementMementoFoundCount() {
1384 int value = memento_found_count()->value();
1385 set_memento_found_count(Smi::FromInt(value + 1));
1386 }
1387
1388
1389 inline void AllocationSite::IncrementMementoCreateCount() {
1390 ASSERT(FLAG_allocation_site_pretenuring);
1391 int value = memento_create_count()->value();
1392 set_memento_create_count(Smi::FromInt(value + 1));
1393 }
1394
1395
1396 inline bool AllocationSite::DigestPretenuringFeedback() {
1397 bool decision_made = false;
1398 if (!PretenuringDecisionMade()) {
1399 int create_count = memento_create_count()->value();
1400 if (create_count >= kPretenureMinimumCreated) {
1401 int found_count = memento_found_count()->value();
1402 double ratio = static_cast<double>(found_count) / create_count;
1403 if (FLAG_trace_track_allocation_sites) {
1404 PrintF("AllocationSite: %p (created, found, ratio) (%d, %d, %f)\n",
1405 static_cast<void*>(this), create_count, found_count, ratio);
1406 }
1407 int result = ratio >= kPretenureRatio ? kTenure : kDontTenure;
1408 set_pretenure_decision(Smi::FromInt(result));
1409 decision_made = true;
1410 // TODO(mvstanton): if the decision represents a change, any dependent
1411 // code registered for pretenuring changes should be deopted.
1412 }
1413 }
1414
1415 // Clear feedback calculation fields until the next gc.
1416 set_memento_found_count(Smi::FromInt(0));
1417 set_memento_create_count(Smi::FromInt(0));
1418 return decision_made;
1419 }
1420
1421
1370 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { 1422 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) {
1371 object->ValidateElements(); 1423 object->ValidateElements();
1372 ElementsKind elements_kind = object->map()->elements_kind(); 1424 ElementsKind elements_kind = object->map()->elements_kind();
1373 if (!IsFastObjectElementsKind(elements_kind)) { 1425 if (!IsFastObjectElementsKind(elements_kind)) {
1374 if (IsFastHoleyElementsKind(elements_kind)) { 1426 if (IsFastHoleyElementsKind(elements_kind)) {
1375 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS); 1427 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS);
1376 } else { 1428 } else {
1377 TransitionElementsKind(object, FAST_ELEMENTS); 1429 TransitionElementsKind(object, FAST_ELEMENTS);
1378 } 1430 }
1379 } 1431 }
(...skipping 2450 matching lines...) Expand 10 before | Expand all | Expand 10 after
3830 // Only allow uninitialized or debugger states for non-IC code 3882 // Only allow uninitialized or debugger states for non-IC code
3831 // objects. This is used in the debugger to determine whether or not 3883 // objects. This is used in the debugger to determine whether or not
3832 // a call to code object has been replaced with a debug break call. 3884 // a call to code object has been replaced with a debug break call.
3833 ASSERT(is_inline_cache_stub() || 3885 ASSERT(is_inline_cache_stub() ||
3834 result == UNINITIALIZED || 3886 result == UNINITIALIZED ||
3835 result == DEBUG_STUB); 3887 result == DEBUG_STUB);
3836 return result; 3888 return result;
3837 } 3889 }
3838 3890
3839 3891
3840 Code::ExtraICState Code::extra_ic_state() { 3892 ExtraICState Code::extra_ic_state() {
3841 ASSERT((is_inline_cache_stub() && !needs_extended_extra_ic_state(kind())) 3893 ASSERT((is_inline_cache_stub() && !needs_extended_extra_ic_state(kind()))
3842 || ic_state() == DEBUG_STUB); 3894 || ic_state() == DEBUG_STUB);
3843 return ExtractExtraICStateFromFlags(flags()); 3895 return ExtractExtraICStateFromFlags(flags());
3844 } 3896 }
3845 3897
3846 3898
3847 Code::ExtraICState Code::extended_extra_ic_state() { 3899 ExtraICState Code::extended_extra_ic_state() {
3848 ASSERT(is_inline_cache_stub() || ic_state() == DEBUG_STUB); 3900 ASSERT(is_inline_cache_stub() || ic_state() == DEBUG_STUB);
3849 ASSERT(needs_extended_extra_ic_state(kind())); 3901 ASSERT(needs_extended_extra_ic_state(kind()));
3850 return ExtractExtendedExtraICStateFromFlags(flags()); 3902 return ExtractExtendedExtraICStateFromFlags(flags());
3851 } 3903 }
3852 3904
3853 3905
3854 Code::StubType Code::type() { 3906 Code::StubType Code::type() {
3855 return ExtractTypeFromFlags(flags()); 3907 return ExtractTypeFromFlags(flags());
3856 } 3908 }
3857 3909
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3900 kind() == COMPARE_NIL_IC || 3952 kind() == COMPARE_NIL_IC ||
3901 kind() == LOAD_IC || 3953 kind() == LOAD_IC ||
3902 kind() == KEYED_LOAD_IC || 3954 kind() == KEYED_LOAD_IC ||
3903 kind() == STORE_IC || 3955 kind() == STORE_IC ||
3904 kind() == KEYED_STORE_IC || 3956 kind() == KEYED_STORE_IC ||
3905 kind() == KEYED_CALL_IC || 3957 kind() == KEYED_CALL_IC ||
3906 kind() == TO_BOOLEAN_IC; 3958 kind() == TO_BOOLEAN_IC;
3907 } 3959 }
3908 3960
3909 3961
3910 bool Code::is_pregenerated() {
3911 return (kind() == STUB && IsPregeneratedField::decode(flags()));
3912 }
3913
3914
3915 void Code::set_is_pregenerated(bool value) {
3916 ASSERT(kind() == STUB);
3917 Flags f = flags();
3918 f = static_cast<Flags>(IsPregeneratedField::update(f, value));
3919 set_flags(f);
3920 }
3921
3922
3923 bool Code::optimizable() { 3962 bool Code::optimizable() {
3924 ASSERT_EQ(FUNCTION, kind()); 3963 ASSERT_EQ(FUNCTION, kind());
3925 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; 3964 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1;
3926 } 3965 }
3927 3966
3928 3967
3929 void Code::set_optimizable(bool value) { 3968 void Code::set_optimizable(bool value) {
3930 ASSERT_EQ(FUNCTION, kind()); 3969 ASSERT_EQ(FUNCTION, kind());
3931 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0); 3970 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0);
3932 } 3971 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
4174 Code::Kind Code::ExtractKindFromFlags(Flags flags) { 4213 Code::Kind Code::ExtractKindFromFlags(Flags flags) {
4175 return KindField::decode(flags); 4214 return KindField::decode(flags);
4176 } 4215 }
4177 4216
4178 4217
4179 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { 4218 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) {
4180 return ICStateField::decode(flags); 4219 return ICStateField::decode(flags);
4181 } 4220 }
4182 4221
4183 4222
4184 Code::ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { 4223 ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) {
4185 return ExtraICStateField::decode(flags); 4224 return ExtraICStateField::decode(flags);
4186 } 4225 }
4187 4226
4188 4227
4189 Code::ExtraICState Code::ExtractExtendedExtraICStateFromFlags( 4228 ExtraICState Code::ExtractExtendedExtraICStateFromFlags(
4190 Flags flags) { 4229 Flags flags) {
4191 return ExtendedExtraICStateField::decode(flags); 4230 return ExtendedExtraICStateField::decode(flags);
4192 } 4231 }
4193 4232
4194 4233
4195 Code::StubType Code::ExtractTypeFromFlags(Flags flags) { 4234 Code::StubType Code::ExtractTypeFromFlags(Flags flags) {
4196 return TypeField::decode(flags); 4235 return TypeField::decode(flags);
4197 } 4236 }
4198 4237
4199 4238
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
6424 #undef WRITE_UINT32_FIELD 6463 #undef WRITE_UINT32_FIELD
6425 #undef READ_SHORT_FIELD 6464 #undef READ_SHORT_FIELD
6426 #undef WRITE_SHORT_FIELD 6465 #undef WRITE_SHORT_FIELD
6427 #undef READ_BYTE_FIELD 6466 #undef READ_BYTE_FIELD
6428 #undef WRITE_BYTE_FIELD 6467 #undef WRITE_BYTE_FIELD
6429 6468
6430 6469
6431 } } // namespace v8::internal 6470 } } // namespace v8::internal
6432 6471
6433 #endif // V8_OBJECTS_INL_H_ 6472 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698