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

Side by Side Diff: src/runtime.cc

Issue 8747009: Optimize Crankshaft array literal initialization from boilerplate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: merge with latest 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/ia32/lithium-codegen-ia32.cc ('k') | src/x64/lithium-codegen-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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { 618 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
619 HandleScope scope(isolate); 619 HandleScope scope(isolate);
620 ASSERT(args.length() == 3); 620 ASSERT(args.length() == 3);
621 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 621 CONVERT_ARG_CHECKED(FixedArray, literals, 0);
622 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 622 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
623 CONVERT_ARG_CHECKED(FixedArray, elements, 2); 623 CONVERT_ARG_CHECKED(FixedArray, elements, 2);
624 624
625 // Check if boilerplate exists. If not, create it first. 625 // Check if boilerplate exists. If not, create it first.
626 Handle<Object> boilerplate(literals->get(literals_index), isolate); 626 Handle<Object> boilerplate(literals->get(literals_index), isolate);
627 if (*boilerplate == isolate->heap()->undefined_value()) { 627 if (*boilerplate == isolate->heap()->undefined_value()) {
628 ASSERT(*elements != isolate->heap()->empty_fixed_array());
628 boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements); 629 boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements);
629 if (boilerplate.is_null()) return Failure::Exception(); 630 if (boilerplate.is_null()) return Failure::Exception();
630 // Update the functions literal and return the boilerplate. 631 // Update the functions literal and return the boilerplate.
631 literals->set(literals_index, *boilerplate); 632 literals->set(literals_index, *boilerplate);
632 } 633 }
633 if (JSObject::cast(*boilerplate)->elements()->map() == 634 if (JSObject::cast(*boilerplate)->elements()->map() ==
634 isolate->heap()->fixed_cow_array_map()) { 635 isolate->heap()->fixed_cow_array_map()) {
635 isolate->counters()->cow_arrays_created_runtime()->Increment(); 636 isolate->counters()->cow_arrays_created_runtime()->Increment();
636 } 637 }
637 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); 638 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate));
(...skipping 4006 matching lines...) Expand 10 before | Expand all | Expand 10 after
4644 #if DEBUG 4645 #if DEBUG
4645 ElementsKind elements_kind = object->GetElementsKind(); 4646 ElementsKind elements_kind = object->GetElementsKind();
4646 #endif 4647 #endif
4647 ASSERT(elements_kind <= FAST_DOUBLE_ELEMENTS); 4648 ASSERT(elements_kind <= FAST_DOUBLE_ELEMENTS);
4648 // Smis should never trigger transitions. 4649 // Smis should never trigger transitions.
4649 ASSERT(!value->IsSmi()); 4650 ASSERT(!value->IsSmi());
4650 4651
4651 if (value->IsNumber()) { 4652 if (value->IsNumber()) {
4652 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS); 4653 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS);
4653 TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS); 4654 TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS);
4655 TransitionElementsKind(boilerplate_object, FAST_DOUBLE_ELEMENTS);
4654 ASSERT(object->GetElementsKind() == FAST_DOUBLE_ELEMENTS); 4656 ASSERT(object->GetElementsKind() == FAST_DOUBLE_ELEMENTS);
4655 FixedDoubleArray* double_array = 4657 FixedDoubleArray* double_array =
4656 FixedDoubleArray::cast(object->elements()); 4658 FixedDoubleArray::cast(object->elements());
4657 HeapNumber* number = HeapNumber::cast(*value); 4659 HeapNumber* number = HeapNumber::cast(*value);
4658 double_array->set(store_index, number->Number()); 4660 double_array->set(store_index, number->Number());
4659 } else { 4661 } else {
4660 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS || 4662 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS ||
4661 elements_kind == FAST_DOUBLE_ELEMENTS); 4663 elements_kind == FAST_DOUBLE_ELEMENTS);
4662 TransitionElementsKind(object, FAST_ELEMENTS); 4664 TransitionElementsKind(object, FAST_ELEMENTS);
4665 TransitionElementsKind(boilerplate_object, FAST_ELEMENTS);
4663 FixedArray* object_array = 4666 FixedArray* object_array =
4664 FixedArray::cast(object->elements()); 4667 FixedArray::cast(object->elements());
4665 object_array->set(store_index, *value); 4668 object_array->set(store_index, *value);
4666 } 4669 }
4667 return *object; 4670 return *object;
4668 } 4671 }
4669 4672
4670 4673
4671 // Set a local property, even if it is READ_ONLY. If the property does not 4674 // Set a local property, even if it is READ_ONLY. If the property does not
4672 // exist, it will be added with attributes NONE. 4675 // exist, it will be added with attributes NONE.
(...skipping 8889 matching lines...) Expand 10 before | Expand all | Expand 10 after
13562 } else { 13565 } else {
13563 // Handle last resort GC and make sure to allow future allocations 13566 // Handle last resort GC and make sure to allow future allocations
13564 // to grow the heap without causing GCs (if possible). 13567 // to grow the heap without causing GCs (if possible).
13565 isolate->counters()->gc_last_resort_from_js()->Increment(); 13568 isolate->counters()->gc_last_resort_from_js()->Increment();
13566 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13569 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13567 } 13570 }
13568 } 13571 }
13569 13572
13570 13573
13571 } } // namespace v8::internal 13574 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698