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

Side by Side Diff: src/objects.cc

Issue 11817017: Additional work to get array literal allocation tracking working, even with --always-opt (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed unnecessary class specifiers Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
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 7490 matching lines...) Expand 10 before | Expand all | Expand 10 after
7501 AllocationSiteInfo* info = AllocationSiteInfo::cast( 7501 AllocationSiteInfo* info = AllocationSiteInfo::cast(
7502 reinterpret_cast<Object*>(ptr_end + 1)); 7502 reinterpret_cast<Object*>(ptr_end + 1));
7503 return info; 7503 return info;
7504 } 7504 }
7505 } 7505 }
7506 } 7506 }
7507 return NULL; 7507 return NULL;
7508 } 7508 }
7509 7509
7510 7510
7511 AllocationSiteInfoMode AllocationSiteInfo::GetMode() {
7512 return FLAG_track_allocation_sites
7513 ? TRACK_ALLOCATION_SITE_INFO
7514 : DONT_TRACK_ALLOCATION_SITE_INFO;
7515 }
7516
7517
7518 AllocationSiteInfoMode AllocationSiteInfo::GetMode(
7519 ElementsKind boilerplate_elements_kind) {
7520 if (FLAG_track_allocation_sites) {
Toon Verwaest 2013/01/16 10:53:42 FLAG_track_allocation_sites && IsFastSmi...
mvstanton 2013/01/16 13:01:56 Done.
7521 if (IsFastSmiElementsKind(boilerplate_elements_kind)) {
7522 return TRACK_ALLOCATION_SITE_INFO;
7523 }
7524 }
7525
7526 return DONT_TRACK_ALLOCATION_SITE_INFO;
7527 }
7528
7529
7530 AllocationSiteInfoMode AllocationSiteInfo::GetMode(ElementsKind from,
7531 ElementsKind to) {
7532 if (FLAG_track_allocation_sites) {
7533 if (IsFastSmiElementsKind(from) && (IsFastObjectElementsKind(to) ||
Toon Verwaest 2013/01/16 10:53:42 Try to put statements between (..) on one line by
mvstanton 2013/01/16 13:01:56 Done.
7534 IsFastDoubleElementsKind(to))) {
7535 return TRACK_ALLOCATION_SITE_INFO;
7536 }
7537 }
7538
7539 return DONT_TRACK_ALLOCATION_SITE_INFO;
7540 }
7541
7542
7511 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { 7543 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) {
7512 // For array indexes mix the length into the hash as an array index could 7544 // For array indexes mix the length into the hash as an array index could
7513 // be zero. 7545 // be zero.
7514 ASSERT(length > 0); 7546 ASSERT(length > 0);
7515 ASSERT(length <= String::kMaxArrayIndexSize); 7547 ASSERT(length <= String::kMaxArrayIndexSize);
7516 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 7548 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
7517 (1 << String::kArrayIndexValueBits)); 7549 (1 << String::kArrayIndexValueBits));
7518 7550
7519 value <<= String::kHashShift; 7551 value <<= String::kHashShift;
7520 value |= length << String::kArrayIndexHashLengthShift; 7552 value |= length << String::kArrayIndexHashLengthShift;
(...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after
9868 FixedDoubleArray::cast(elements())->set(index, value->Number()); 9900 FixedDoubleArray::cast(elements())->set(index, value->Number());
9869 ValidateElements(); 9901 ValidateElements();
9870 return value; 9902 return value;
9871 } 9903 }
9872 // Change elements kind from Smi-only to generic FAST if necessary. 9904 // Change elements kind from Smi-only to generic FAST if necessary.
9873 if (HasFastSmiElements() && !value->IsSmi()) { 9905 if (HasFastSmiElements() && !value->IsSmi()) {
9874 Map* new_map; 9906 Map* new_map;
9875 ElementsKind kind = HasFastHoleyElements() 9907 ElementsKind kind = HasFastHoleyElements()
9876 ? FAST_HOLEY_ELEMENTS 9908 ? FAST_HOLEY_ELEMENTS
9877 : FAST_ELEMENTS; 9909 : FAST_ELEMENTS;
9910
9911 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(kind);
9912 if (trans->IsFailure()) return trans;
9913
9878 MaybeObject* maybe_new_map = GetElementsTransitionMap(GetIsolate(), 9914 MaybeObject* maybe_new_map = GetElementsTransitionMap(GetIsolate(),
9879 kind); 9915 kind);
9880 if (!maybe_new_map->To(&new_map)) return maybe_new_map; 9916 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
9881 9917
9882 set_map(new_map); 9918 set_map(new_map);
9883 } 9919 }
9884 // Increase backing store capacity if that's been decided previously. 9920 // Increase backing store capacity if that's been decided previously.
9885 if (new_capacity != capacity) { 9921 if (new_capacity != capacity) {
9886 FixedArray* new_elements; 9922 FixedArray* new_elements;
9887 SetFastElementsCapacitySmiMode smi_mode = 9923 SetFastElementsCapacitySmiMode smi_mode =
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
10399 ElementsKind to_kind) { 10435 ElementsKind to_kind) {
10400 CALL_HEAP_FUNCTION(object->GetIsolate(), 10436 CALL_HEAP_FUNCTION(object->GetIsolate(),
10401 object->TransitionElementsKind(to_kind), 10437 object->TransitionElementsKind(to_kind),
10402 Object); 10438 Object);
10403 } 10439 }
10404 10440
10405 10441
10406 MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( 10442 MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate(
10407 ElementsKind to_kind) { 10443 ElementsKind to_kind) {
10408 MaybeObject* ret = NULL; 10444 MaybeObject* ret = NULL;
10409 if (IsJSArray()) { 10445 if (!FLAG_track_allocation_sites || !IsJSArray()) {
10410 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); 10446 return ret;
10411 if (info != NULL) { 10447 }
10412 JSObject* payload = JSObject::cast(info->payload()); 10448
10413 if (payload->GetElementsKind() != to_kind) { 10449 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this);
10414 if (IsMoreGeneralElementsKindTransition(payload->GetElementsKind(), 10450 if (info == NULL) {
10415 to_kind)) { 10451 return ret;
10416 ret = payload->TransitionElementsKind(to_kind); 10452 }
10417 } 10453
10454 ASSERT(info->payload()->IsJSArray());
10455 JSArray* payload = JSArray::cast(info->payload());
10456 ElementsKind kind = payload->GetElementsKind();
10457 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {
10458 // If the array is huge, it's not likely to be defined in a local
10459 // function, so we shouldn't make new instances of it very often.
10460 uint32_t length = 0;
10461 CHECK(payload->length()->ToArrayIndex(&length));
10462 if (length <= 8 * 1024) {
10463 ret = payload->TransitionElementsKind(to_kind);
10464 if (FLAG_trace_track_allocation_sites) {
10465 PrintF(
10466 "AllocationSiteInfo: JSArray %p boilerplate updated %s->%s\n",
10467 reinterpret_cast<void*>(this),
10468 ElementsKindToString(kind),
10469 ElementsKindToString(to_kind));
10418 } 10470 }
10419 } 10471 }
10420 } 10472 }
10421 return ret; 10473 return ret;
10422 } 10474 }
10423 10475
10424 10476
10425 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { 10477 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) {
10426 ASSERT(!map()->is_observed()); 10478 ASSERT(!map()->is_observed());
10427 ElementsKind from_kind = map()->elements_kind(); 10479 ElementsKind from_kind = map()->elements_kind();
(...skipping 3351 matching lines...) Expand 10 before | Expand all | Expand 10 after
13779 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13831 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13780 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13832 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13781 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13833 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13782 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13834 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13783 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13835 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13784 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13836 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13785 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13837 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13786 } 13838 }
13787 13839
13788 } } // namespace v8::internal 13840 } } // namespace v8::internal
OLDNEW
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698