OLD | NEW |
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 9170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9181 } | 9181 } |
9182 } | 9182 } |
9183 | 9183 |
9184 | 9184 |
9185 // Push an object unto an array of objects if it is not already in the | 9185 // Push an object unto an array of objects if it is not already in the |
9186 // array. Returns true if the element was pushed on the stack and | 9186 // array. Returns true if the element was pushed on the stack and |
9187 // false otherwise. | 9187 // false otherwise. |
9188 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { | 9188 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { |
9189 ASSERT(args.length() == 2); | 9189 ASSERT(args.length() == 2); |
9190 CONVERT_ARG_CHECKED(JSArray, array, 0); | 9190 CONVERT_ARG_CHECKED(JSArray, array, 0); |
9191 CONVERT_ARG_CHECKED(JSObject, element, 1); | 9191 CONVERT_ARG_CHECKED(JSReceiver, element, 1); |
9192 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); | 9192 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); |
9193 int length = Smi::cast(array->length())->value(); | 9193 int length = Smi::cast(array->length())->value(); |
9194 FixedArray* elements = FixedArray::cast(array->elements()); | 9194 FixedArray* elements = FixedArray::cast(array->elements()); |
9195 for (int i = 0; i < length; i++) { | 9195 for (int i = 0; i < length; i++) { |
9196 if (elements->get(i) == element) return isolate->heap()->false_value(); | 9196 if (elements->get(i) == element) return isolate->heap()->false_value(); |
9197 } | 9197 } |
9198 Object* obj; | 9198 Object* obj; |
9199 // Strict not needed. Used for cycle detection in Array join implementation. | 9199 // Strict not needed. Used for cycle detection in Array join implementation. |
9200 { MaybeObject* maybe_obj = | 9200 { MaybeObject* maybe_obj = |
9201 array->SetFastElement(length, element, kNonStrictMode, true); | 9201 array->SetFastElement(length, element, kNonStrictMode, true); |
(...skipping 4099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13301 // Handle last resort GC and make sure to allow future allocations | 13301 // Handle last resort GC and make sure to allow future allocations |
13302 // to grow the heap without causing GCs (if possible). | 13302 // to grow the heap without causing GCs (if possible). |
13303 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13303 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13304 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13304 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13305 "Runtime::PerformGC"); | 13305 "Runtime::PerformGC"); |
13306 } | 13306 } |
13307 } | 13307 } |
13308 | 13308 |
13309 | 13309 |
13310 } } // namespace v8::internal | 13310 } } // namespace v8::internal |
OLD | NEW |