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

Side by Side Diff: src/runtime.cc

Issue 8820014: Support Smi->Double->HeapObject transitions in constructed Arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 9 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-inl.h ('k') | src/x64/builtins-x64.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 6278 matching lines...) Expand 10 before | Expand all | Expand 10 after
6289 if (static_cast<uint32_t>(indices.length()) < limit) { 6289 if (static_cast<uint32_t>(indices.length()) < limit) {
6290 indices.Add(subject_length); 6290 indices.Add(subject_length);
6291 } 6291 }
6292 6292
6293 // The list indices now contains the end of each part to create. 6293 // The list indices now contains the end of each part to create.
6294 6294
6295 // Create JSArray of substrings separated by separator. 6295 // Create JSArray of substrings separated by separator.
6296 int part_count = indices.length(); 6296 int part_count = indices.length();
6297 6297
6298 Handle<JSArray> result = isolate->factory()->NewJSArray(part_count); 6298 Handle<JSArray> result = isolate->factory()->NewJSArray(part_count);
6299 MaybeObject* maybe_result = result->EnsureCanContainNonSmiElements(); 6299 MaybeObject* maybe_result = result->EnsureCanContainHeapObjectElements();
6300 if (maybe_result->IsFailure()) return maybe_result; 6300 if (maybe_result->IsFailure()) return maybe_result;
6301 result->set_length(Smi::FromInt(part_count)); 6301 result->set_length(Smi::FromInt(part_count));
6302 6302
6303 ASSERT(result->HasFastElements()); 6303 ASSERT(result->HasFastElements());
6304 6304
6305 if (part_count == 1 && indices.at(0) == subject_length) { 6305 if (part_count == 1 && indices.at(0) == subject_length) {
6306 FixedArray::cast(result->elements())->set(0, *subject); 6306 FixedArray::cast(result->elements())->set(0, *subject);
6307 return *result; 6307 return *result;
6308 } 6308 }
6309 6309
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
6665 if (!args[1]->IsSmi()) { 6665 if (!args[1]->IsSmi()) {
6666 isolate->context()->mark_out_of_memory(); 6666 isolate->context()->mark_out_of_memory();
6667 return Failure::OutOfMemoryException(); 6667 return Failure::OutOfMemoryException();
6668 } 6668 }
6669 int array_length = args.smi_at(1); 6669 int array_length = args.smi_at(1);
6670 CONVERT_CHECKED(String, special, args[2]); 6670 CONVERT_CHECKED(String, special, args[2]);
6671 6671
6672 // This assumption is used by the slice encoding in one or two smis. 6672 // This assumption is used by the slice encoding in one or two smis.
6673 ASSERT(Smi::kMaxValue >= String::kMaxLength); 6673 ASSERT(Smi::kMaxValue >= String::kMaxLength);
6674 6674
6675 MaybeObject* maybe_result = array->EnsureCanContainNonSmiElements(); 6675 MaybeObject* maybe_result = array->EnsureCanContainHeapObjectElements();
6676 if (maybe_result->IsFailure()) return maybe_result; 6676 if (maybe_result->IsFailure()) return maybe_result;
6677 6677
6678 int special_length = special->length(); 6678 int special_length = special->length();
6679 if (!array->HasFastElements()) { 6679 if (!array->HasFastElements()) {
6680 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6680 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6681 } 6681 }
6682 FixedArray* fixed_array = FixedArray::cast(array->elements()); 6682 FixedArray* fixed_array = FixedArray::cast(array->elements());
6683 if (fixed_array->length() < array_length) { 6683 if (fixed_array->length() < array_length) {
6684 array_length = fixed_array->length(); 6684 array_length = fixed_array->length();
6685 } 6685 }
(...skipping 2613 matching lines...) Expand 10 before | Expand all | Expand 10 after
9299 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { 9299 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) {
9300 HandleScope scope(isolate); 9300 HandleScope scope(isolate);
9301 ASSERT(args.length() == 2); 9301 ASSERT(args.length() == 2);
9302 9302
9303 CONVERT_ARG_CHECKED(String, str, 0); 9303 CONVERT_ARG_CHECKED(String, str, 0);
9304 FlattenString(str); 9304 FlattenString(str);
9305 9305
9306 CONVERT_ARG_CHECKED(JSArray, output, 1); 9306 CONVERT_ARG_CHECKED(JSArray, output, 1);
9307 9307
9308 MaybeObject* maybe_result_array = 9308 MaybeObject* maybe_result_array =
9309 output->EnsureCanContainNonSmiElements(); 9309 output->EnsureCanContainHeapObjectElements();
9310 if (maybe_result_array->IsFailure()) return maybe_result_array; 9310 if (maybe_result_array->IsFailure()) return maybe_result_array;
9311 RUNTIME_ASSERT(output->HasFastElements()); 9311 RUNTIME_ASSERT(output->HasFastElements());
9312 9312
9313 AssertNoAllocation no_allocation; 9313 AssertNoAllocation no_allocation;
9314 9314
9315 FixedArray* output_array = FixedArray::cast(output->elements()); 9315 FixedArray* output_array = FixedArray::cast(output->elements());
9316 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); 9316 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE);
9317 bool result; 9317 bool result;
9318 String::FlatContent str_content = str->GetFlatContent(); 9318 String::FlatContent str_content = str->GetFlatContent();
9319 if (str_content.IsAscii()) { 9319 if (str_content.IsAscii()) {
(...skipping 4249 matching lines...) Expand 10 before | Expand all | Expand 10 after
13569 } else { 13569 } else {
13570 // Handle last resort GC and make sure to allow future allocations 13570 // Handle last resort GC and make sure to allow future allocations
13571 // to grow the heap without causing GCs (if possible). 13571 // to grow the heap without causing GCs (if possible).
13572 isolate->counters()->gc_last_resort_from_js()->Increment(); 13572 isolate->counters()->gc_last_resort_from_js()->Increment();
13573 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13573 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13574 } 13574 }
13575 } 13575 }
13576 13576
13577 13577
13578 } } // namespace v8::internal 13578 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698