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

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: More efficient code when number of arguments is known 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 7869 matching lines...) Expand 10 before | Expand all | Expand 10 after
7880 if (cell_contents->IsSmi()) { 7880 if (cell_contents->IsSmi()) {
7881 *kind = static_cast<ElementsKind>( 7881 *kind = static_cast<ElementsKind>(
7882 Smi::cast(cell_contents)->value()); 7882 Smi::cast(cell_contents)->value());
7883 return true; 7883 return true;
7884 } 7884 }
7885 } 7885 }
7886 return false; 7886 return false;
7887 } 7887 }
7888 7888
7889 7889
7890 // Heuristic: We only need to create allocation site info if the boilerplate
7891 // elements kind is the initial elements kind.
7892 AllocationSiteMode AllocationSiteInfo::GetMode(
7893 ElementsKind boilerplate_elements_kind) {
7894 if (FLAG_track_allocation_sites &&
7895 IsFastSmiElementsKind(boilerplate_elements_kind)) {
7896 return TRACK_ALLOCATION_SITE;
7897 }
7898
7899 return DONT_TRACK_ALLOCATION_SITE;
7900 }
7901
7902
7903 AllocationSiteMode AllocationSiteInfo::GetMode(ElementsKind from,
7904 ElementsKind to) {
7905 if (FLAG_track_allocation_sites &&
7906 IsFastSmiElementsKind(from) &&
7907 (IsFastObjectElementsKind(to) || IsFastDoubleElementsKind(to))) {
7908 return TRACK_ALLOCATION_SITE;
7909 }
7910
7911 return DONT_TRACK_ALLOCATION_SITE;
7912 }
7913
7914
7915 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { 7890 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) {
7916 // For array indexes mix the length into the hash as an array index could 7891 // For array indexes mix the length into the hash as an array index could
7917 // be zero. 7892 // be zero.
7918 ASSERT(length > 0); 7893 ASSERT(length > 0);
7919 ASSERT(length <= String::kMaxArrayIndexSize); 7894 ASSERT(length <= String::kMaxArrayIndexSize);
7920 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 7895 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
7921 (1 << String::kArrayIndexValueBits)); 7896 (1 << String::kArrayIndexValueBits));
7922 7897
7923 value <<= String::kHashShift; 7898 value <<= String::kHashShift;
7924 value |= length << String::kArrayIndexHashLengthShift; 7899 value |= length << String::kArrayIndexHashLengthShift;
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
8349 // so they remain fast. 8324 // so they remain fast.
8350 if (!HasFastProperties()) { 8325 if (!HasFastProperties()) {
8351 MaybeObject* new_proto = TransformToFastProperties(0); 8326 MaybeObject* new_proto = TransformToFastProperties(0);
8352 if (new_proto->IsFailure()) return new_proto; 8327 if (new_proto->IsFailure()) return new_proto;
8353 ASSERT(new_proto == this); 8328 ASSERT(new_proto == this);
8354 } 8329 }
8355 return this; 8330 return this;
8356 } 8331 }
8357 8332
8358 8333
8359 MUST_USE_RESULT static MaybeObject* CacheInitialJSArrayMaps( 8334 MUST_USE_RESULT MaybeObject* CacheInitialJSArrayMaps(
8360 Context* native_context, Map* initial_map) { 8335 Context* native_context, Map* initial_map) {
8361 // Replace all of the cached initial array maps in the native context with 8336 // Replace all of the cached initial array maps in the native context with
8362 // the appropriate transitioned elements kind maps. 8337 // the appropriate transitioned elements kind maps.
8363 Heap* heap = native_context->GetHeap(); 8338 Heap* heap = native_context->GetHeap();
8364 MaybeObject* maybe_maps = 8339 MaybeObject* maybe_maps =
8365 heap->AllocateFixedArrayWithHoles(kElementsKindCount); 8340 heap->AllocateFixedArrayWithHoles(kElementsKindCount, TENURED);
8366 FixedArray* maps; 8341 FixedArray* maps;
8367 if (!maybe_maps->To(&maps)) return maybe_maps; 8342 if (!maybe_maps->To(&maps)) return maybe_maps;
8368 8343
8369 Map* current_map = initial_map; 8344 Map* current_map = initial_map;
8370 ElementsKind kind = current_map->elements_kind(); 8345 ElementsKind kind = current_map->elements_kind();
8371 ASSERT(kind == GetInitialFastElementsKind()); 8346 ASSERT(kind == GetInitialFastElementsKind());
8372 maps->set(kind, current_map); 8347 maps->set(kind, current_map);
8373 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1; 8348 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1;
8374 i < kFastElementsKindCount; ++i) { 8349 i < kFastElementsKindCount; ++i) {
8375 Map* new_map; 8350 Map* new_map;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
8409 Map* new_map; 8384 Map* new_map;
8410 MaybeObject* maybe_object = initial_map()->Copy(); 8385 MaybeObject* maybe_object = initial_map()->Copy();
8411 if (!maybe_object->To(&new_map)) return maybe_object; 8386 if (!maybe_object->To(&new_map)) return maybe_object;
8412 new_map->set_prototype(value); 8387 new_map->set_prototype(value);
8413 8388
8414 // If the function is used as the global Array function, cache the 8389 // If the function is used as the global Array function, cache the
8415 // initial map (and transitioned versions) in the native context. 8390 // initial map (and transitioned versions) in the native context.
8416 Context* native_context = context()->native_context(); 8391 Context* native_context = context()->native_context();
8417 Object* array_function = native_context->get(Context::ARRAY_FUNCTION_INDEX); 8392 Object* array_function = native_context->get(Context::ARRAY_FUNCTION_INDEX);
8418 if (array_function->IsJSFunction() && 8393 if (array_function->IsJSFunction() &&
8419 this == JSFunction::cast(array_function)) { 8394 this == JSFunction::cast(array_function)) { // &&
8395 // native_context->js_array_maps()->IsUndefined()) {
8420 MaybeObject* ok = CacheInitialJSArrayMaps(native_context, new_map); 8396 MaybeObject* ok = CacheInitialJSArrayMaps(native_context, new_map);
8421 if (ok->IsFailure()) return ok; 8397 if (ok->IsFailure()) return ok;
8422 } 8398 }
8423 8399
8424 set_initial_map(new_map); 8400 set_initial_map(new_map);
8425 } else { 8401 } else {
8426 // Put the value in the initial map field until an initial map is 8402 // Put the value in the initial map field until an initial map is
8427 // needed. At that point, a new initial map is created and the 8403 // needed. At that point, a new initial map is created and the
8428 // prototype is put into the initial map where it belongs. 8404 // prototype is put into the initial map where it belongs.
8429 set_prototype_or_initial_map(value); 8405 set_prototype_or_initial_map(value);
(...skipping 6043 matching lines...) Expand 10 before | Expand all | Expand 10 after
14473 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 14449 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
14474 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 14450 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
14475 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 14451 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
14476 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 14452 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
14477 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 14453 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
14478 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 14454 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
14479 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 14455 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
14480 } 14456 }
14481 14457
14482 } } // namespace v8::internal 14458 } } // namespace v8::internal
OLDNEW
« src/ia32/code-stubs-ia32.cc ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698