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

Side by Side Diff: src/objects.cc

Issue 12385014: Hydrogen stubs for array constructors (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: With all ports done Created 7 years, 8 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 7874 matching lines...) Expand 10 before | Expand all | Expand 10 after
7885 if (cell_contents->IsSmi()) { 7885 if (cell_contents->IsSmi()) {
7886 *kind = static_cast<ElementsKind>( 7886 *kind = static_cast<ElementsKind>(
7887 Smi::cast(cell_contents)->value()); 7887 Smi::cast(cell_contents)->value());
7888 return true; 7888 return true;
7889 } 7889 }
7890 } 7890 }
7891 return false; 7891 return false;
7892 } 7892 }
7893 7893
7894 7894
7895 // Heuristic: We only need to create allocation site info if the boilerplate
7896 // elements kind is the initial elements kind.
7897 AllocationSiteMode AllocationSiteInfo::GetMode(
7898 ElementsKind boilerplate_elements_kind) {
7899 if (FLAG_track_allocation_sites &&
7900 IsFastSmiElementsKind(boilerplate_elements_kind)) {
7901 return TRACK_ALLOCATION_SITE;
7902 }
7903
7904 return DONT_TRACK_ALLOCATION_SITE;
7905 }
7906
7907
7908 AllocationSiteMode AllocationSiteInfo::GetMode(ElementsKind from,
7909 ElementsKind to) {
7910 if (FLAG_track_allocation_sites &&
7911 IsFastSmiElementsKind(from) &&
7912 (IsFastObjectElementsKind(to) || IsFastDoubleElementsKind(to))) {
7913 return TRACK_ALLOCATION_SITE;
7914 }
7915
7916 return DONT_TRACK_ALLOCATION_SITE;
7917 }
7918
7919
7920 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { 7895 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) {
7921 // For array indexes mix the length into the hash as an array index could 7896 // For array indexes mix the length into the hash as an array index could
7922 // be zero. 7897 // be zero.
7923 ASSERT(length > 0); 7898 ASSERT(length > 0);
7924 ASSERT(length <= String::kMaxArrayIndexSize); 7899 ASSERT(length <= String::kMaxArrayIndexSize);
7925 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 7900 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
7926 (1 << String::kArrayIndexValueBits)); 7901 (1 << String::kArrayIndexValueBits));
7927 7902
7928 value <<= String::kHashShift; 7903 value <<= String::kHashShift;
7929 value |= length << String::kArrayIndexHashLengthShift; 7904 value |= length << String::kArrayIndexHashLengthShift;
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
8354 // so they remain fast. 8329 // so they remain fast.
8355 if (!HasFastProperties()) { 8330 if (!HasFastProperties()) {
8356 MaybeObject* new_proto = TransformToFastProperties(0); 8331 MaybeObject* new_proto = TransformToFastProperties(0);
8357 if (new_proto->IsFailure()) return new_proto; 8332 if (new_proto->IsFailure()) return new_proto;
8358 ASSERT(new_proto == this); 8333 ASSERT(new_proto == this);
8359 } 8334 }
8360 return this; 8335 return this;
8361 } 8336 }
8362 8337
8363 8338
8364 MUST_USE_RESULT static MaybeObject* CacheInitialJSArrayMaps( 8339 MUST_USE_RESULT MaybeObject* CacheInitialJSArrayMaps(
8365 Context* native_context, Map* initial_map) { 8340 Context* native_context, Map* initial_map) {
8366 // Replace all of the cached initial array maps in the native context with 8341 // Replace all of the cached initial array maps in the native context with
8367 // the appropriate transitioned elements kind maps. 8342 // the appropriate transitioned elements kind maps.
8368 Heap* heap = native_context->GetHeap(); 8343 Heap* heap = native_context->GetHeap();
8369 MaybeObject* maybe_maps = 8344 MaybeObject* maybe_maps =
8370 heap->AllocateFixedArrayWithHoles(kElementsKindCount); 8345 heap->AllocateFixedArrayWithHoles(kElementsKindCount, TENURED);
8371 FixedArray* maps; 8346 FixedArray* maps;
8372 if (!maybe_maps->To(&maps)) return maybe_maps; 8347 if (!maybe_maps->To(&maps)) return maybe_maps;
8373 8348
8374 Map* current_map = initial_map; 8349 Map* current_map = initial_map;
8375 ElementsKind kind = current_map->elements_kind(); 8350 ElementsKind kind = current_map->elements_kind();
8376 ASSERT(kind == GetInitialFastElementsKind()); 8351 ASSERT(kind == GetInitialFastElementsKind());
8377 maps->set(kind, current_map); 8352 maps->set(kind, current_map);
8378 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1; 8353 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1;
8379 i < kFastElementsKindCount; ++i) { 8354 i < kFastElementsKindCount; ++i) {
8380 Map* new_map; 8355 Map* new_map;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
8414 Map* new_map; 8389 Map* new_map;
8415 MaybeObject* maybe_object = initial_map()->Copy(); 8390 MaybeObject* maybe_object = initial_map()->Copy();
8416 if (!maybe_object->To(&new_map)) return maybe_object; 8391 if (!maybe_object->To(&new_map)) return maybe_object;
8417 new_map->set_prototype(value); 8392 new_map->set_prototype(value);
8418 8393
8419 // If the function is used as the global Array function, cache the 8394 // If the function is used as the global Array function, cache the
8420 // initial map (and transitioned versions) in the native context. 8395 // initial map (and transitioned versions) in the native context.
8421 Context* native_context = context()->native_context(); 8396 Context* native_context = context()->native_context();
8422 Object* array_function = native_context->get(Context::ARRAY_FUNCTION_INDEX); 8397 Object* array_function = native_context->get(Context::ARRAY_FUNCTION_INDEX);
8423 if (array_function->IsJSFunction() && 8398 if (array_function->IsJSFunction() &&
8424 this == JSFunction::cast(array_function)) { 8399 this == JSFunction::cast(array_function)) { // &&
8400 // native_context->js_array_maps()->IsUndefined()) {
Hannes Payer (out of office) 2013/04/18 11:14:39 are you planning to remove this?
mvstanton 2013/04/18 13:39:26 Done.
8425 MaybeObject* ok = CacheInitialJSArrayMaps(native_context, new_map); 8401 MaybeObject* ok = CacheInitialJSArrayMaps(native_context, new_map);
8426 if (ok->IsFailure()) return ok; 8402 if (ok->IsFailure()) return ok;
8427 } 8403 }
8428 8404
8429 set_initial_map(new_map); 8405 set_initial_map(new_map);
8430 } else { 8406 } else {
8431 // Put the value in the initial map field until an initial map is 8407 // Put the value in the initial map field until an initial map is
8432 // needed. At that point, a new initial map is created and the 8408 // needed. At that point, a new initial map is created and the
8433 // prototype is put into the initial map where it belongs. 8409 // prototype is put into the initial map where it belongs.
8434 set_prototype_or_initial_map(value); 8410 set_prototype_or_initial_map(value);
(...skipping 6043 matching lines...) Expand 10 before | Expand all | Expand 10 after
14478 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 14454 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
14479 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 14455 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
14480 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 14456 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
14481 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 14457 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
14482 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 14458 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
14483 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 14459 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
14484 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 14460 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
14485 } 14461 }
14486 14462
14487 } } // namespace v8::internal 14463 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698