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

Side by Side Diff: src/runtime.cc

Issue 66803002: Handlify JSObject::SetElement & brethren (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: sync Created 7 years, 1 month 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.cc ('k') | test/cctest/test-heap.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 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 9803 matching lines...) Expand 10 before | Expand all | Expand 10 after
9814 ASSERT(args.length() == 1); 9814 ASSERT(args.length() == 1);
9815 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); 9815 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0);
9816 return Allocate(isolate, size_smi->value(), OLD_DATA_SPACE); 9816 return Allocate(isolate, size_smi->value(), OLD_DATA_SPACE);
9817 } 9817 }
9818 9818
9819 9819
9820 // Push an object unto an array of objects if it is not already in the 9820 // Push an object unto an array of objects if it is not already in the
9821 // array. Returns true if the element was pushed on the stack and 9821 // array. Returns true if the element was pushed on the stack and
9822 // false otherwise. 9822 // false otherwise.
9823 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { 9823 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) {
9824 SealHandleScope shs(isolate); 9824 HandleScope scope(isolate);
9825 ASSERT(args.length() == 2); 9825 ASSERT(args.length() == 2);
9826 CONVERT_ARG_CHECKED(JSArray, array, 0); 9826 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
9827 CONVERT_ARG_CHECKED(JSReceiver, element, 1); 9827 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1);
9828 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); 9828 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements());
9829 int length = Smi::cast(array->length())->value(); 9829 int length = Smi::cast(array->length())->value();
9830 FixedArray* elements = FixedArray::cast(array->elements()); 9830 FixedArray* elements = FixedArray::cast(array->elements());
9831 for (int i = 0; i < length; i++) { 9831 for (int i = 0; i < length; i++) {
9832 if (elements->get(i) == element) return isolate->heap()->false_value(); 9832 if (elements->get(i) == *element) return isolate->heap()->false_value();
9833 } 9833 }
9834 Object* obj; 9834
9835 // Strict not needed. Used for cycle detection in Array join implementation. 9835 // Strict not needed. Used for cycle detection in Array join implementation.
9836 { MaybeObject* maybe_obj = 9836 RETURN_IF_EMPTY_HANDLE(isolate, JSObject::SetFastElement(array, length,
9837 array->SetFastElement(length, element, kNonStrictMode, true); 9837 element,
9838 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 9838 kNonStrictMode,
9839 } 9839 true));
9840 return isolate->heap()->true_value(); 9840 return isolate->heap()->true_value();
9841 } 9841 }
9842 9842
9843 9843
9844 /** 9844 /**
9845 * A simple visitor visits every element of Array's. 9845 * A simple visitor visits every element of Array's.
9846 * The backend storage can be a fixed array for fast elements case, 9846 * The backend storage can be a fixed array for fast elements case,
9847 * or a dictionary for sparse array. Since Dictionary is a subtype 9847 * or a dictionary for sparse array. Since Dictionary is a subtype
9848 * of FixedArray, the class can be used by both fast and slow cases. 9848 * of FixedArray, the class can be used by both fast and slow cases.
9849 * The second parameter of the constructor, fast_elements, specifies 9849 * The second parameter of the constructor, fast_elements, specifies
(...skipping 5040 matching lines...) Expand 10 before | Expand all | Expand 10 after
14890 // Handle last resort GC and make sure to allow future allocations 14890 // Handle last resort GC and make sure to allow future allocations
14891 // to grow the heap without causing GCs (if possible). 14891 // to grow the heap without causing GCs (if possible).
14892 isolate->counters()->gc_last_resort_from_js()->Increment(); 14892 isolate->counters()->gc_last_resort_from_js()->Increment();
14893 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14893 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14894 "Runtime::PerformGC"); 14894 "Runtime::PerformGC");
14895 } 14895 }
14896 } 14896 }
14897 14897
14898 14898
14899 } } // namespace v8::internal 14899 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698