// Copyright 2014 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/v8.h" #include "src/arguments.h" #include "src/debug.h" #include "src/liveedit.h" #include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { namespace internal { static int FindSharedFunctionInfosForScript(HeapIterator* iterator, Script* script, FixedArray* buffer) { DisallowHeapAllocation no_allocation; int counter = 0; int buffer_size = buffer->length(); for (HeapObject* obj = iterator->next(); obj != NULL; obj = iterator->next()) { DCHECK(obj != NULL); if (!obj->IsSharedFunctionInfo()) { continue; } SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); if (shared->script() != script) { continue; } if (counter < buffer_size) { buffer->set(counter, shared); } counter++; } return counter; } // For a script finds all SharedFunctionInfo's in the heap that points // to this script. Returns JSArray of SharedFunctionInfo wrapped // in OpaqueReferences. RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) { HandleScope scope(isolate); CHECK(isolate->debug()->live_edit_enabled()); DCHECK(args.length() == 1); CONVERT_ARG_CHECKED(JSValue, script_value, 0); RUNTIME_ASSERT(script_value->value()->IsScript()); Handle