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

Side by Side Diff: src/runtime.cc

Issue 9950095: Fix array boilerplate object transitioning. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed moar comments by Daniel Clifford. Created 8 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 | « no previous file | test/mjsunit/regress/regress-2055.js » ('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 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 4651 matching lines...) Expand 10 before | Expand all | Expand 10 after
4662 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { 4662 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
4663 RUNTIME_ASSERT(args.length() == 5); 4663 RUNTIME_ASSERT(args.length() == 5);
4664 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 4664 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
4665 CONVERT_SMI_ARG_CHECKED(store_index, 1); 4665 CONVERT_SMI_ARG_CHECKED(store_index, 1);
4666 Handle<Object> value = args.at<Object>(2); 4666 Handle<Object> value = args.at<Object>(2);
4667 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); 4667 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3);
4668 CONVERT_SMI_ARG_CHECKED(literal_index, 4); 4668 CONVERT_SMI_ARG_CHECKED(literal_index, 4);
4669 HandleScope scope; 4669 HandleScope scope;
4670 4670
4671 Object* raw_boilerplate_object = literals->get(literal_index); 4671 Object* raw_boilerplate_object = literals->get(literal_index);
4672 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object)); 4672 Handle<JSArray> boilerplate(JSArray::cast(raw_boilerplate_object));
4673 #if DEBUG 4673 #if DEBUG
4674 ElementsKind elements_kind = object->GetElementsKind(); 4674 ElementsKind elements_kind = object->GetElementsKind();
4675 #endif 4675 #endif
4676 ASSERT(elements_kind <= FAST_DOUBLE_ELEMENTS); 4676 ASSERT(elements_kind <= FAST_DOUBLE_ELEMENTS);
4677 // Smis should never trigger transitions. 4677 // Smis should never trigger transitions.
4678 ASSERT(!value->IsSmi()); 4678 ASSERT(!value->IsSmi());
4679 4679
4680 if (value->IsNumber()) { 4680 if (value->IsNumber()) {
4681 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS); 4681 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS);
4682 JSObject::TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS); 4682 JSObject::TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS);
4683 JSObject::TransitionElementsKind(boilerplate_object, FAST_DOUBLE_ELEMENTS); 4683 if (IsMoreGeneralElementsKindTransition(boilerplate->GetElementsKind(),
4684 FAST_DOUBLE_ELEMENTS)) {
4685 JSObject::TransitionElementsKind(boilerplate, FAST_DOUBLE_ELEMENTS);
4686 }
4684 ASSERT(object->GetElementsKind() == FAST_DOUBLE_ELEMENTS); 4687 ASSERT(object->GetElementsKind() == FAST_DOUBLE_ELEMENTS);
4685 FixedDoubleArray* double_array = 4688 FixedDoubleArray* double_array = FixedDoubleArray::cast(object->elements());
4686 FixedDoubleArray::cast(object->elements());
4687 HeapNumber* number = HeapNumber::cast(*value); 4689 HeapNumber* number = HeapNumber::cast(*value);
4688 double_array->set(store_index, number->Number()); 4690 double_array->set(store_index, number->Number());
4689 } else { 4691 } else {
4690 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS || 4692 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS ||
4691 elements_kind == FAST_DOUBLE_ELEMENTS); 4693 elements_kind == FAST_DOUBLE_ELEMENTS);
4692 JSObject::TransitionElementsKind(object, FAST_ELEMENTS); 4694 JSObject::TransitionElementsKind(object, FAST_ELEMENTS);
4693 JSObject::TransitionElementsKind(boilerplate_object, FAST_ELEMENTS); 4695 if (IsMoreGeneralElementsKindTransition(boilerplate->GetElementsKind(),
4694 FixedArray* object_array = 4696 FAST_ELEMENTS)) {
4695 FixedArray::cast(object->elements()); 4697 JSObject::TransitionElementsKind(boilerplate, FAST_ELEMENTS);
4698 }
4699 FixedArray* object_array = FixedArray::cast(object->elements());
4696 object_array->set(store_index, *value); 4700 object_array->set(store_index, *value);
4697 } 4701 }
4698 return *object; 4702 return *object;
4699 } 4703 }
4700 4704
4701 4705
4702 // Set a local property, even if it is READ_ONLY. If the property does not 4706 // Set a local property, even if it is READ_ONLY. If the property does not
4703 // exist, it will be added with attributes NONE. 4707 // exist, it will be added with attributes NONE.
4704 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { 4708 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) {
4705 NoHandleAllocation ha; 4709 NoHandleAllocation ha;
(...skipping 8636 matching lines...) Expand 10 before | Expand all | Expand 10 after
13342 // Handle last resort GC and make sure to allow future allocations 13346 // Handle last resort GC and make sure to allow future allocations
13343 // to grow the heap without causing GCs (if possible). 13347 // to grow the heap without causing GCs (if possible).
13344 isolate->counters()->gc_last_resort_from_js()->Increment(); 13348 isolate->counters()->gc_last_resort_from_js()->Increment();
13345 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13349 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13346 "Runtime::PerformGC"); 13350 "Runtime::PerformGC");
13347 } 13351 }
13348 } 13352 }
13349 13353
13350 13354
13351 } } // namespace v8::internal 13355 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-2055.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698