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

Side by Side Diff: src/runtime.cc

Issue 5614004: Use the PushIfAbsent function for the JSON stringify stack.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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/json.js ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 7653 matching lines...) Expand 10 before | Expand all | Expand 10 after
7664 Object* allocation; 7664 Object* allocation;
7665 { MaybeObject* maybe_allocation = Heap::new_space()->AllocateRaw(size); 7665 { MaybeObject* maybe_allocation = Heap::new_space()->AllocateRaw(size);
7666 if (maybe_allocation->ToObject(&allocation)) { 7666 if (maybe_allocation->ToObject(&allocation)) {
7667 Heap::CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size); 7667 Heap::CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
7668 } 7668 }
7669 return maybe_allocation; 7669 return maybe_allocation;
7670 } 7670 }
7671 } 7671 }
7672 7672
7673 7673
7674 // Push an array unto an array of arrays if it is not already in the 7674 // Push an object unto an array of objects if it is not already in the
7675 // array. Returns true if the element was pushed on the stack and 7675 // array. Returns true if the element was pushed on the stack and
7676 // false otherwise. 7676 // false otherwise.
7677 static MaybeObject* Runtime_PushIfAbsent(Arguments args) { 7677 static MaybeObject* Runtime_PushIfAbsent(Arguments args) {
7678 ASSERT(args.length() == 2); 7678 ASSERT(args.length() == 2);
7679 CONVERT_CHECKED(JSArray, array, args[0]); 7679 CONVERT_CHECKED(JSArray, array, args[0]);
7680 CONVERT_CHECKED(JSArray, element, args[1]); 7680 CONVERT_CHECKED(JSObject, element, args[1]);
7681 RUNTIME_ASSERT(array->HasFastElements()); 7681 RUNTIME_ASSERT(array->HasFastElements());
7682 int length = Smi::cast(array->length())->value(); 7682 int length = Smi::cast(array->length())->value();
7683 FixedArray* elements = FixedArray::cast(array->elements()); 7683 FixedArray* elements = FixedArray::cast(array->elements());
7684 for (int i = 0; i < length; i++) { 7684 for (int i = 0; i < length; i++) {
7685 if (elements->get(i) == element) return Heap::false_value(); 7685 if (elements->get(i) == element) return Heap::false_value();
7686 } 7686 }
7687 Object* obj; 7687 Object* obj;
7688 { MaybeObject* maybe_obj = array->SetFastElement(length, element); 7688 { MaybeObject* maybe_obj = array->SetFastElement(length, element);
7689 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 7689 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
7690 } 7690 }
(...skipping 3093 matching lines...) Expand 10 before | Expand all | Expand 10 after
10784 } else { 10784 } else {
10785 // Handle last resort GC and make sure to allow future allocations 10785 // Handle last resort GC and make sure to allow future allocations
10786 // to grow the heap without causing GCs (if possible). 10786 // to grow the heap without causing GCs (if possible).
10787 Counters::gc_last_resort_from_js.Increment(); 10787 Counters::gc_last_resort_from_js.Increment();
10788 Heap::CollectAllGarbage(false); 10788 Heap::CollectAllGarbage(false);
10789 } 10789 }
10790 } 10790 }
10791 10791
10792 10792
10793 } } // namespace v8::internal 10793 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/json.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698