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

Side by Side Diff: src/runtime.cc

Issue 218753005: Replace set_map_and_elements by MigrateToMap-based SetMapAndElements (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comment Created 6 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
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | 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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 holder->set_buffer(*buffer); 1003 holder->set_buffer(*buffer);
1004 holder->set_weak_next(buffer->weak_first_view()); 1004 holder->set_weak_next(buffer->weak_first_view());
1005 buffer->set_weak_first_view(*holder); 1005 buffer->set_weak_first_view(*holder);
1006 1006
1007 Handle<ExternalArray> elements = 1007 Handle<ExternalArray> elements =
1008 isolate->factory()->NewExternalArray( 1008 isolate->factory()->NewExternalArray(
1009 static_cast<int>(length), array_type, 1009 static_cast<int>(length), array_type,
1010 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); 1010 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
1011 Handle<Map> map = 1011 Handle<Map> map =
1012 JSObject::GetElementsTransitionMap(holder, external_elements_kind); 1012 JSObject::GetElementsTransitionMap(holder, external_elements_kind);
1013 holder->set_map_and_elements(*map, *elements); 1013 JSObject::SetMapAndElements(holder, map, elements);
1014 ASSERT(IsExternalArrayElementsKind(holder->map()->elements_kind())); 1014 ASSERT(IsExternalArrayElementsKind(holder->map()->elements_kind()));
1015 } else { 1015 } else {
1016 holder->set_buffer(Smi::FromInt(0)); 1016 holder->set_buffer(Smi::FromInt(0));
1017 holder->set_weak_next(isolate->heap()->undefined_value()); 1017 holder->set_weak_next(isolate->heap()->undefined_value());
1018 Handle<FixedTypedArrayBase> elements = 1018 Handle<FixedTypedArrayBase> elements =
1019 isolate->factory()->NewFixedTypedArray( 1019 isolate->factory()->NewFixedTypedArray(
1020 static_cast<int>(length), array_type); 1020 static_cast<int>(length), array_type);
1021 holder->set_elements(*elements); 1021 holder->set_elements(*elements);
1022 } 1022 }
1023 return isolate->heap()->undefined_value(); 1023 return isolate->heap()->undefined_value();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 holder->set_length(*length_obj); 1100 holder->set_length(*length_obj);
1101 holder->set_weak_next(buffer->weak_first_view()); 1101 holder->set_weak_next(buffer->weak_first_view());
1102 buffer->set_weak_first_view(*holder); 1102 buffer->set_weak_first_view(*holder);
1103 1103
1104 Handle<ExternalArray> elements = 1104 Handle<ExternalArray> elements =
1105 isolate->factory()->NewExternalArray( 1105 isolate->factory()->NewExternalArray(
1106 static_cast<int>(length), array_type, 1106 static_cast<int>(length), array_type,
1107 static_cast<uint8_t*>(buffer->backing_store())); 1107 static_cast<uint8_t*>(buffer->backing_store()));
1108 Handle<Map> map = JSObject::GetElementsTransitionMap( 1108 Handle<Map> map = JSObject::GetElementsTransitionMap(
1109 holder, external_elements_kind); 1109 holder, external_elements_kind);
1110 holder->set_map_and_elements(*map, *elements); 1110 JSObject::SetMapAndElements(holder, map, elements);
1111 1111
1112 if (source->IsJSTypedArray()) { 1112 if (source->IsJSTypedArray()) {
1113 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source)); 1113 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source));
1114 1114
1115 if (typed_array->type() == holder->type()) { 1115 if (typed_array->type() == holder->type()) {
1116 uint8_t* backing_store = 1116 uint8_t* backing_store =
1117 static_cast<uint8_t*>( 1117 static_cast<uint8_t*>(
1118 typed_array->GetBuffer()->backing_store()); 1118 typed_array->GetBuffer()->backing_store());
1119 size_t source_byte_offset = 1119 size_t source_byte_offset =
1120 NumberToSize(isolate, typed_array->byte_offset()); 1120 NumberToSize(isolate, typed_array->byte_offset());
(...skipping 9506 matching lines...) Expand 10 before | Expand all | Expand 10 after
10627 HandleScope scope(isolate); 10627 HandleScope scope(isolate);
10628 ASSERT(args.length() == 2); 10628 ASSERT(args.length() == 2);
10629 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 10629 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
10630 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); 10630 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
10631 return *JSObject::PrepareElementsForSort(object, limit); 10631 return *JSObject::PrepareElementsForSort(object, limit);
10632 } 10632 }
10633 10633
10634 10634
10635 // Move contents of argument 0 (an array) to argument 1 (an array) 10635 // Move contents of argument 0 (an array) to argument 1 (an array)
10636 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { 10636 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) {
10637 SealHandleScope shs(isolate); 10637 HandleScope scope(isolate);
10638 ASSERT(args.length() == 2); 10638 ASSERT(args.length() == 2);
10639 CONVERT_ARG_CHECKED(JSArray, from, 0); 10639 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0);
10640 CONVERT_ARG_CHECKED(JSArray, to, 1); 10640 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1);
10641 from->ValidateElements(); 10641 from->ValidateElements();
10642 to->ValidateElements(); 10642 to->ValidateElements();
10643 FixedArrayBase* new_elements = from->elements(); 10643
10644 Handle<FixedArrayBase> new_elements(from->elements());
10644 ElementsKind from_kind = from->GetElementsKind(); 10645 ElementsKind from_kind = from->GetElementsKind();
10645 MaybeObject* maybe_new_map; 10646 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind);
10646 maybe_new_map = to->GetElementsTransitionMap(isolate, from_kind); 10647 JSObject::SetMapAndElements(to, new_map, new_elements);
10647 Object* new_map;
10648 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
10649 to->set_map_and_elements(Map::cast(new_map), new_elements);
10650 to->set_length(from->length()); 10648 to->set_length(from->length());
10651 Object* obj; 10649
10652 { MaybeObject* maybe_obj = from->ResetElements(); 10650 JSObject::ResetElements(from);
10653 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
10654 }
10655 from->set_length(Smi::FromInt(0)); 10651 from->set_length(Smi::FromInt(0));
10652
10656 to->ValidateElements(); 10653 to->ValidateElements();
10657 return to; 10654 return *to;
10658 } 10655 }
10659 10656
10660 10657
10661 // How many elements does this object/array have? 10658 // How many elements does this object/array have?
10662 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { 10659 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) {
10663 SealHandleScope shs(isolate); 10660 SealHandleScope shs(isolate);
10664 ASSERT(args.length() == 1); 10661 ASSERT(args.length() == 1);
10665 CONVERT_ARG_CHECKED(JSObject, object, 0); 10662 CONVERT_ARG_CHECKED(JSObject, object, 0);
10666 HeapObject* elements = object->elements(); 10663 HeapObject* elements = object->elements();
10667 if (elements->IsDictionary()) { 10664 if (elements->IsDictionary()) {
(...skipping 4480 matching lines...) Expand 10 before | Expand all | Expand 10 after
15148 } 15145 }
15149 } 15146 }
15150 15147
15151 15148
15152 void Runtime::OutOfMemory() { 15149 void Runtime::OutOfMemory() {
15153 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15150 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15154 UNREACHABLE(); 15151 UNREACHABLE();
15155 } 15152 }
15156 15153
15157 } } // namespace v8::internal 15154 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698