| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 Handle<Object> args[1] = { name }; | 2110 Handle<Object> args[1] = { name }; |
| 2111 Handle<Object> error = isolate->factory()->NewTypeError( | 2111 Handle<Object> error = isolate->factory()->NewTypeError( |
| 2112 "var_redeclaration", HandleVector(args, 1)); | 2112 "var_redeclaration", HandleVector(args, 1)); |
| 2113 return isolate->Throw(*error); | 2113 return isolate->Throw(*error); |
| 2114 } | 2114 } |
| 2115 | 2115 |
| 2116 | 2116 |
| 2117 RUNTIME_FUNCTION(Runtime_DeclareGlobals) { | 2117 RUNTIME_FUNCTION(Runtime_DeclareGlobals) { |
| 2118 HandleScope scope(isolate); | 2118 HandleScope scope(isolate); |
| 2119 ASSERT(args.length() == 3); | 2119 ASSERT(args.length() == 3); |
| 2120 Handle<GlobalObject> global = Handle<GlobalObject>( | 2120 Handle<GlobalObject> global(isolate->global_object()); |
| 2121 isolate->context()->global_object()); | |
| 2122 | 2121 |
| 2123 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 2122 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
| 2124 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); | 2123 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); |
| 2125 CONVERT_SMI_ARG_CHECKED(flags, 2); | 2124 CONVERT_SMI_ARG_CHECKED(flags, 2); |
| 2126 | 2125 |
| 2127 // Traverse the name/value pairs and set the properties. | 2126 // Traverse the name/value pairs and set the properties. |
| 2128 int length = pairs->length(); | 2127 int length = pairs->length(); |
| 2129 for (int i = 0; i < length; i += 2) { | 2128 for (int i = 0; i < length; i += 2) { |
| 2130 HandleScope scope(isolate); | 2129 HandleScope scope(isolate); |
| 2131 Handle<String> name(String::cast(pairs->get(i))); | 2130 Handle<String> name(String::cast(pairs->get(i))); |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 } | 2735 } |
| 2737 JSFunction* function = JSFunction::cast(callable); | 2736 JSFunction* function = JSFunction::cast(callable); |
| 2738 | 2737 |
| 2739 SharedFunctionInfo* shared = function->shared(); | 2738 SharedFunctionInfo* shared = function->shared(); |
| 2740 if (shared->native() || shared->strict_mode() == STRICT) { | 2739 if (shared->native() || shared->strict_mode() == STRICT) { |
| 2741 return isolate->heap()->undefined_value(); | 2740 return isolate->heap()->undefined_value(); |
| 2742 } | 2741 } |
| 2743 // Returns undefined for strict or native functions, or | 2742 // Returns undefined for strict or native functions, or |
| 2744 // the associated global receiver for "normal" functions. | 2743 // the associated global receiver for "normal" functions. |
| 2745 | 2744 |
| 2746 Context* native_context = | 2745 return function->global_proxy(); |
| 2747 function->context()->global_object()->native_context(); | |
| 2748 return native_context->global_object()->global_receiver(); | |
| 2749 } | 2746 } |
| 2750 | 2747 |
| 2751 | 2748 |
| 2752 RUNTIME_FUNCTION(Runtime_MaterializeRegExpLiteral) { | 2749 RUNTIME_FUNCTION(Runtime_MaterializeRegExpLiteral) { |
| 2753 HandleScope scope(isolate); | 2750 HandleScope scope(isolate); |
| 2754 ASSERT(args.length() == 4); | 2751 ASSERT(args.length() == 4); |
| 2755 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 2752 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 2756 CONVERT_SMI_ARG_CHECKED(index, 1); | 2753 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 2757 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); | 2754 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); |
| 2758 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); | 2755 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); |
| (...skipping 5455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8214 // called using 'new' and creates a new JSFunction object that | 8211 // called using 'new' and creates a new JSFunction object that |
| 8215 // is returned. The receiver object is only used for error | 8212 // is returned. The receiver object is only used for error |
| 8216 // reporting if an error occurs when constructing the new | 8213 // reporting if an error occurs when constructing the new |
| 8217 // JSFunction. Factory::NewJSObject() should not be used to | 8214 // JSFunction. Factory::NewJSObject() should not be used to |
| 8218 // allocate JSFunctions since it does not properly initialize | 8215 // allocate JSFunctions since it does not properly initialize |
| 8219 // the shared part of the function. Since the receiver is | 8216 // the shared part of the function. Since the receiver is |
| 8220 // ignored anyway, we use the global object as the receiver | 8217 // ignored anyway, we use the global object as the receiver |
| 8221 // instead of a new JSFunction object. This way, errors are | 8218 // instead of a new JSFunction object. This way, errors are |
| 8222 // reported the same way whether or not 'Function' is called | 8219 // reported the same way whether or not 'Function' is called |
| 8223 // using 'new'. | 8220 // using 'new'. |
| 8224 return isolate->context()->global_proxy(); | 8221 return isolate->global_proxy(); |
| 8225 } | 8222 } |
| 8226 } | 8223 } |
| 8227 | 8224 |
| 8228 // The function should be compiled for the optimization hints to be | 8225 // The function should be compiled for the optimization hints to be |
| 8229 // available. | 8226 // available. |
| 8230 Compiler::EnsureCompiled(function, CLEAR_EXCEPTION); | 8227 Compiler::EnsureCompiled(function, CLEAR_EXCEPTION); |
| 8231 | 8228 |
| 8232 Handle<JSObject> result; | 8229 Handle<JSObject> result; |
| 8233 if (site.is_null()) { | 8230 if (site.is_null()) { |
| 8234 result = isolate->factory()->NewJSObject(function); | 8231 result = isolate->factory()->NewJSObject(function); |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8888 HandleVector(&handle, 1)); | 8885 HandleVector(&handle, 1)); |
| 8889 return isolate->Throw(*result); | 8886 return isolate->Throw(*result); |
| 8890 } | 8887 } |
| 8891 } | 8888 } |
| 8892 | 8889 |
| 8893 Handle<JSFunction> function; | 8890 Handle<JSFunction> function; |
| 8894 if (args[1]->IsSmi()) { | 8891 if (args[1]->IsSmi()) { |
| 8895 // A smi sentinel indicates a context nested inside global code rather | 8892 // A smi sentinel indicates a context nested inside global code rather |
| 8896 // than some function. There is a canonical empty function that can be | 8893 // than some function. There is a canonical empty function that can be |
| 8897 // gotten from the native context. | 8894 // gotten from the native context. |
| 8898 function = handle(isolate->context()->native_context()->closure()); | 8895 function = handle(isolate->native_context()->closure()); |
| 8899 } else { | 8896 } else { |
| 8900 function = args.at<JSFunction>(1); | 8897 function = args.at<JSFunction>(1); |
| 8901 } | 8898 } |
| 8902 | 8899 |
| 8903 Handle<Context> current(isolate->context()); | 8900 Handle<Context> current(isolate->context()); |
| 8904 Handle<Context> context = isolate->factory()->NewWithContext( | 8901 Handle<Context> context = isolate->factory()->NewWithContext( |
| 8905 function, current, extension_object); | 8902 function, current, extension_object); |
| 8906 isolate->set_context(*context); | 8903 isolate->set_context(*context); |
| 8907 return *context; | 8904 return *context; |
| 8908 } | 8905 } |
| 8909 | 8906 |
| 8910 | 8907 |
| 8911 RUNTIME_FUNCTION(Runtime_PushCatchContext) { | 8908 RUNTIME_FUNCTION(Runtime_PushCatchContext) { |
| 8912 HandleScope scope(isolate); | 8909 HandleScope scope(isolate); |
| 8913 ASSERT(args.length() == 3); | 8910 ASSERT(args.length() == 3); |
| 8914 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 8911 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 8915 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); | 8912 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); |
| 8916 Handle<JSFunction> function; | 8913 Handle<JSFunction> function; |
| 8917 if (args[2]->IsSmi()) { | 8914 if (args[2]->IsSmi()) { |
| 8918 // A smi sentinel indicates a context nested inside global code rather | 8915 // A smi sentinel indicates a context nested inside global code rather |
| 8919 // than some function. There is a canonical empty function that can be | 8916 // than some function. There is a canonical empty function that can be |
| 8920 // gotten from the native context. | 8917 // gotten from the native context. |
| 8921 function = handle(isolate->context()->native_context()->closure()); | 8918 function = handle(isolate->native_context()->closure()); |
| 8922 } else { | 8919 } else { |
| 8923 function = args.at<JSFunction>(2); | 8920 function = args.at<JSFunction>(2); |
| 8924 } | 8921 } |
| 8925 Handle<Context> current(isolate->context()); | 8922 Handle<Context> current(isolate->context()); |
| 8926 Handle<Context> context = isolate->factory()->NewCatchContext( | 8923 Handle<Context> context = isolate->factory()->NewCatchContext( |
| 8927 function, current, name, thrown_object); | 8924 function, current, name, thrown_object); |
| 8928 isolate->set_context(*context); | 8925 isolate->set_context(*context); |
| 8929 return *context; | 8926 return *context; |
| 8930 } | 8927 } |
| 8931 | 8928 |
| 8932 | 8929 |
| 8933 RUNTIME_FUNCTION(Runtime_PushBlockContext) { | 8930 RUNTIME_FUNCTION(Runtime_PushBlockContext) { |
| 8934 HandleScope scope(isolate); | 8931 HandleScope scope(isolate); |
| 8935 ASSERT(args.length() == 2); | 8932 ASSERT(args.length() == 2); |
| 8936 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); | 8933 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); |
| 8937 Handle<JSFunction> function; | 8934 Handle<JSFunction> function; |
| 8938 if (args[1]->IsSmi()) { | 8935 if (args[1]->IsSmi()) { |
| 8939 // A smi sentinel indicates a context nested inside global code rather | 8936 // A smi sentinel indicates a context nested inside global code rather |
| 8940 // than some function. There is a canonical empty function that can be | 8937 // than some function. There is a canonical empty function that can be |
| 8941 // gotten from the native context. | 8938 // gotten from the native context. |
| 8942 function = handle(isolate->context()->native_context()->closure()); | 8939 function = handle(isolate->native_context()->closure()); |
| 8943 } else { | 8940 } else { |
| 8944 function = args.at<JSFunction>(1); | 8941 function = args.at<JSFunction>(1); |
| 8945 } | 8942 } |
| 8946 Handle<Context> current(isolate->context()); | 8943 Handle<Context> current(isolate->context()); |
| 8947 Handle<Context> context = isolate->factory()->NewBlockContext( | 8944 Handle<Context> context = isolate->factory()->NewBlockContext( |
| 8948 function, current, scope_info); | 8945 function, current, scope_info); |
| 8949 isolate->set_context(*context); | 8946 isolate->set_context(*context); |
| 8950 return *context; | 8947 return *context; |
| 8951 } | 8948 } |
| 8952 | 8949 |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9618 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 9615 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( |
| 9619 EternalHandles::DATE_CACHE_VERSION)); | 9616 EternalHandles::DATE_CACHE_VERSION)); |
| 9620 // Return result as a JS array. | 9617 // Return result as a JS array. |
| 9621 Handle<JSObject> result = | 9618 Handle<JSObject> result = |
| 9622 isolate->factory()->NewJSObject(isolate->array_function()); | 9619 isolate->factory()->NewJSObject(isolate->array_function()); |
| 9623 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version); | 9620 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version); |
| 9624 return *result; | 9621 return *result; |
| 9625 } | 9622 } |
| 9626 | 9623 |
| 9627 | 9624 |
| 9628 RUNTIME_FUNCTION(Runtime_GlobalReceiver) { | 9625 RUNTIME_FUNCTION(Runtime_GlobalProxy) { |
| 9629 SealHandleScope shs(isolate); | 9626 SealHandleScope shs(isolate); |
| 9630 ASSERT(args.length() == 1); | 9627 ASSERT(args.length() == 1); |
| 9631 CONVERT_ARG_CHECKED(Object, global, 0); | 9628 CONVERT_ARG_CHECKED(Object, global, 0); |
| 9632 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9629 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
| 9633 return JSGlobalObject::cast(global)->global_receiver(); | 9630 return JSGlobalObject::cast(global)->global_proxy(); |
| 9634 } | 9631 } |
| 9635 | 9632 |
| 9636 | 9633 |
| 9637 RUNTIME_FUNCTION(Runtime_IsAttachedGlobal) { | 9634 RUNTIME_FUNCTION(Runtime_IsAttachedGlobal) { |
| 9638 SealHandleScope shs(isolate); | 9635 SealHandleScope shs(isolate); |
| 9639 ASSERT(args.length() == 1); | 9636 ASSERT(args.length() == 1); |
| 9640 CONVERT_ARG_CHECKED(Object, global, 0); | 9637 CONVERT_ARG_CHECKED(Object, global, 0); |
| 9641 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value(); | 9638 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value(); |
| 9642 return isolate->heap()->ToBoolean( | 9639 return isolate->heap()->ToBoolean( |
| 9643 !JSGlobalObject::cast(global)->IsDetached()); | 9640 !JSGlobalObject::cast(global)->IsDetached()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9730 } | 9727 } |
| 9731 | 9728 |
| 9732 | 9729 |
| 9733 RUNTIME_FUNCTION(Runtime_CompileString) { | 9730 RUNTIME_FUNCTION(Runtime_CompileString) { |
| 9734 HandleScope scope(isolate); | 9731 HandleScope scope(isolate); |
| 9735 ASSERT(args.length() == 2); | 9732 ASSERT(args.length() == 2); |
| 9736 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 9733 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
| 9737 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); | 9734 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); |
| 9738 | 9735 |
| 9739 // Extract native context. | 9736 // Extract native context. |
| 9740 Handle<Context> context(isolate->context()->native_context()); | 9737 Handle<Context> context(isolate->native_context()); |
| 9741 | 9738 |
| 9742 // Filter cross security context calls. | 9739 // Filter cross security context calls. |
| 9743 if (!TokensMatchForCompileString(isolate)) { | 9740 if (!TokensMatchForCompileString(isolate)) { |
| 9744 return isolate->heap()->undefined_value(); | 9741 return isolate->heap()->undefined_value(); |
| 9745 } | 9742 } |
| 9746 | 9743 |
| 9747 // Check if native context allows code generation from | 9744 // Check if native context allows code generation from |
| 9748 // strings. Throw an exception if it doesn't. | 9745 // strings. Throw an exception if it doesn't. |
| 9749 if (context->allow_code_gen_from_strings()->IsFalse() && | 9746 if (context->allow_code_gen_from_strings()->IsFalse() && |
| 9750 !CodeGenerationFromStringsAllowed(isolate, context)) { | 9747 !CodeGenerationFromStringsAllowed(isolate, context)) { |
| (...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11333 shared->strict_mode() == SLOPPY && | 11330 shared->strict_mode() == SLOPPY && |
| 11334 !function->IsBuiltin()) { | 11331 !function->IsBuiltin()) { |
| 11335 // If the receiver is not a JSObject and the function is not a | 11332 // If the receiver is not a JSObject and the function is not a |
| 11336 // builtin or strict-mode we have hit an optimization where a | 11333 // builtin or strict-mode we have hit an optimization where a |
| 11337 // value object is not converted into a wrapped JS objects. To | 11334 // value object is not converted into a wrapped JS objects. To |
| 11338 // hide this optimization from the debugger, we wrap the receiver | 11335 // hide this optimization from the debugger, we wrap the receiver |
| 11339 // by creating correct wrapper object based on the calling frame's | 11336 // by creating correct wrapper object based on the calling frame's |
| 11340 // native context. | 11337 // native context. |
| 11341 it.Advance(); | 11338 it.Advance(); |
| 11342 if (receiver->IsUndefined()) { | 11339 if (receiver->IsUndefined()) { |
| 11343 Context* context = function->context(); | 11340 receiver = handle(function->global_proxy()); |
| 11344 receiver = handle(context->global_object()->global_receiver()); | |
| 11345 } else { | 11341 } else { |
| 11346 ASSERT(!receiver->IsNull()); | 11342 ASSERT(!receiver->IsNull()); |
| 11347 Context* context = Context::cast(it.frame()->context()); | 11343 Context* context = Context::cast(it.frame()->context()); |
| 11348 Handle<Context> native_context(Context::cast(context->native_context())); | 11344 Handle<Context> native_context(Context::cast(context->native_context())); |
| 11349 receiver = Object::ToObject( | 11345 receiver = Object::ToObject( |
| 11350 isolate, receiver, native_context).ToHandleChecked(); | 11346 isolate, receiver, native_context).ToHandleChecked(); |
| 11351 } | 11347 } |
| 11352 } | 11348 } |
| 11353 details->set(kFrameDetailsReceiverIndex, *receiver); | 11349 details->set(kFrameDetailsReceiverIndex, *receiver); |
| 11354 | 11350 |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12905 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { | 12901 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { |
| 12906 top = top->prev(); | 12902 top = top->prev(); |
| 12907 } | 12903 } |
| 12908 if (top != NULL) { | 12904 if (top != NULL) { |
| 12909 isolate->set_context(*top->context()); | 12905 isolate->set_context(*top->context()); |
| 12910 } | 12906 } |
| 12911 | 12907 |
| 12912 // Get the native context now set to the top context from before the | 12908 // Get the native context now set to the top context from before the |
| 12913 // debugger was invoked. | 12909 // debugger was invoked. |
| 12914 Handle<Context> context = isolate->native_context(); | 12910 Handle<Context> context = isolate->native_context(); |
| 12915 Handle<Object> receiver = isolate->global_object(); | 12911 Handle<JSObject> receiver(context->global_proxy()); |
| 12916 Handle<Object> result; | 12912 Handle<Object> result; |
| 12917 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 12913 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 12918 isolate, result, | 12914 isolate, result, |
| 12919 DebugEvaluate(isolate, context, context_extension, receiver, source)); | 12915 DebugEvaluate(isolate, context, context_extension, receiver, source)); |
| 12920 return *result; | 12916 return *result; |
| 12921 } | 12917 } |
| 12922 | 12918 |
| 12923 | 12919 |
| 12924 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { | 12920 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { |
| 12925 HandleScope scope(isolate); | 12921 HandleScope scope(isolate); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13031 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); | 13027 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); |
| 13032 CONVERT_ARG_HANDLE_CHECKED(Object, instance_filter, 1); | 13028 CONVERT_ARG_HANDLE_CHECKED(Object, instance_filter, 1); |
| 13033 RUNTIME_ASSERT(instance_filter->IsUndefined() || | 13029 RUNTIME_ASSERT(instance_filter->IsUndefined() || |
| 13034 instance_filter->IsJSObject()); | 13030 instance_filter->IsJSObject()); |
| 13035 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); | 13031 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); |
| 13036 RUNTIME_ASSERT(max_references >= 0); | 13032 RUNTIME_ASSERT(max_references >= 0); |
| 13037 | 13033 |
| 13038 | 13034 |
| 13039 // Get the constructor function for context extension and arguments array. | 13035 // Get the constructor function for context extension and arguments array. |
| 13040 Handle<JSObject> arguments_boilerplate( | 13036 Handle<JSObject> arguments_boilerplate( |
| 13041 isolate->context()->native_context()->sloppy_arguments_boilerplate()); | 13037 isolate->sloppy_arguments_boilerplate()); |
| 13042 Handle<JSFunction> arguments_function( | 13038 Handle<JSFunction> arguments_function( |
| 13043 JSFunction::cast(arguments_boilerplate->map()->constructor())); | 13039 JSFunction::cast(arguments_boilerplate->map()->constructor())); |
| 13044 | 13040 |
| 13045 // Get the number of referencing objects. | 13041 // Get the number of referencing objects. |
| 13046 int count; | 13042 int count; |
| 13047 // First perform a full GC in order to avoid dead objects and to make the heap | 13043 // First perform a full GC in order to avoid dead objects and to make the heap |
| 13048 // iterable. | 13044 // iterable. |
| 13049 Heap* heap = isolate->heap(); | 13045 Heap* heap = isolate->heap(); |
| 13050 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy"); | 13046 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy"); |
| 13051 { | 13047 { |
| 13052 HeapIterator heap_iterator(heap); | 13048 HeapIterator heap_iterator(heap); |
| 13053 count = DebugReferencedBy(&heap_iterator, | 13049 count = DebugReferencedBy(&heap_iterator, |
| 13054 *target, *instance_filter, max_references, | 13050 *target, *instance_filter, max_references, |
| 13055 NULL, 0, *arguments_function); | 13051 NULL, 0, *arguments_function); |
| 13056 } | 13052 } |
| 13057 | 13053 |
| 13058 // Allocate an array to hold the result. | 13054 // Allocate an array to hold the result. |
| 13059 Handle<FixedArray> instances = isolate->factory()->NewFixedArray(count); | 13055 Handle<FixedArray> instances = isolate->factory()->NewFixedArray(count); |
| 13060 | 13056 |
| 13061 // Fill the referencing objects. | 13057 // Fill the referencing objects. |
| 13062 { | 13058 { |
| 13063 HeapIterator heap_iterator(heap); | 13059 HeapIterator heap_iterator(heap); |
| 13064 count = DebugReferencedBy(&heap_iterator, | 13060 count = DebugReferencedBy(&heap_iterator, |
| 13065 *target, *instance_filter, max_references, | 13061 *target, *instance_filter, max_references, |
| 13066 *instances, count, *arguments_function); | 13062 *instances, count, *arguments_function); |
| 13067 } | 13063 } |
| 13068 | 13064 |
| 13069 // Return result as JS array. | 13065 // Return result as JS array. |
| 13070 Handle<JSFunction> constructor( | 13066 Handle<JSFunction> constructor = isolate->array_function(); |
| 13071 isolate->context()->native_context()->array_function()); | |
| 13072 | 13067 |
| 13073 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor); | 13068 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor); |
| 13074 JSArray::SetContent(Handle<JSArray>::cast(result), instances); | 13069 JSArray::SetContent(Handle<JSArray>::cast(result), instances); |
| 13075 return *result; | 13070 return *result; |
| 13076 } | 13071 } |
| 13077 | 13072 |
| 13078 | 13073 |
| 13079 // Helper function used by Runtime_DebugConstructedBy below. | 13074 // Helper function used by Runtime_DebugConstructedBy below. |
| 13080 static int DebugConstructedBy(HeapIterator* iterator, | 13075 static int DebugConstructedBy(HeapIterator* iterator, |
| 13081 JSFunction* constructor, | 13076 JSFunction* constructor, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13143 { | 13138 { |
| 13144 HeapIterator heap_iterator2(heap); | 13139 HeapIterator heap_iterator2(heap); |
| 13145 count = DebugConstructedBy(&heap_iterator2, | 13140 count = DebugConstructedBy(&heap_iterator2, |
| 13146 *constructor, | 13141 *constructor, |
| 13147 max_references, | 13142 max_references, |
| 13148 *instances, | 13143 *instances, |
| 13149 count); | 13144 count); |
| 13150 } | 13145 } |
| 13151 | 13146 |
| 13152 // Return result as JS array. | 13147 // Return result as JS array. |
| 13153 Handle<JSFunction> array_function( | 13148 Handle<JSFunction> array_function = isolate->array_function(); |
| 13154 isolate->context()->native_context()->array_function()); | |
| 13155 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function); | 13149 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function); |
| 13156 JSArray::SetContent(Handle<JSArray>::cast(result), instances); | 13150 JSArray::SetContent(Handle<JSArray>::cast(result), instances); |
| 13157 return *result; | 13151 return *result; |
| 13158 } | 13152 } |
| 13159 | 13153 |
| 13160 | 13154 |
| 13161 // Find the effective prototype object as returned by __proto__. | 13155 // Find the effective prototype object as returned by __proto__. |
| 13162 // args[0]: the object to find the prototype for. | 13156 // args[0]: the object to find the prototype for. |
| 13163 RUNTIME_FUNCTION(Runtime_DebugGetPrototype) { | 13157 RUNTIME_FUNCTION(Runtime_DebugGetPrototype) { |
| 13164 HandleScope shs(isolate); | 13158 HandleScope shs(isolate); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13557 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { | 13551 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { |
| 13558 HandleScope scope(isolate); | 13552 HandleScope scope(isolate); |
| 13559 ASSERT(args.length() == 2); | 13553 ASSERT(args.length() == 2); |
| 13560 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 13554 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 13561 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); | 13555 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); |
| 13562 | 13556 |
| 13563 MaybeHandle<Object> maybe_result; | 13557 MaybeHandle<Object> maybe_result; |
| 13564 if (without_debugger) { | 13558 if (without_debugger) { |
| 13565 maybe_result = Execution::Call(isolate, | 13559 maybe_result = Execution::Call(isolate, |
| 13566 function, | 13560 function, |
| 13567 isolate->global_object(), | 13561 handle(function->global_proxy()), |
| 13568 0, | 13562 0, |
| 13569 NULL); | 13563 NULL); |
| 13570 } else { | 13564 } else { |
| 13571 DebugScope debug_scope(isolate->debug()); | 13565 DebugScope debug_scope(isolate->debug()); |
| 13572 maybe_result = Execution::Call(isolate, | 13566 maybe_result = Execution::Call(isolate, |
| 13573 function, | 13567 function, |
| 13574 isolate->global_object(), | 13568 handle(function->global_proxy()), |
| 13575 0, | 13569 0, |
| 13576 NULL); | 13570 NULL); |
| 13577 } | 13571 } |
| 13578 Handle<Object> result; | 13572 Handle<Object> result; |
| 13579 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); | 13573 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); |
| 13580 return *result; | 13574 return *result; |
| 13581 } | 13575 } |
| 13582 | 13576 |
| 13583 | 13577 |
| 13584 // Sets a v8 flag. | 13578 // Sets a v8 flag. |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14569 // There is no value in the cache. Invoke the function and cache result. | 14563 // There is no value in the cache. Invoke the function and cache result. |
| 14570 HandleScope scope(isolate); | 14564 HandleScope scope(isolate); |
| 14571 | 14565 |
| 14572 Handle<JSFunctionResultCache> cache_handle(cache); | 14566 Handle<JSFunctionResultCache> cache_handle(cache); |
| 14573 Handle<Object> key_handle(key, isolate); | 14567 Handle<Object> key_handle(key, isolate); |
| 14574 Handle<Object> value; | 14568 Handle<Object> value; |
| 14575 { | 14569 { |
| 14576 Handle<JSFunction> factory(JSFunction::cast( | 14570 Handle<JSFunction> factory(JSFunction::cast( |
| 14577 cache_handle->get(JSFunctionResultCache::kFactoryIndex))); | 14571 cache_handle->get(JSFunctionResultCache::kFactoryIndex))); |
| 14578 // TODO(antonm): consider passing a receiver when constructing a cache. | 14572 // TODO(antonm): consider passing a receiver when constructing a cache. |
| 14579 Handle<Object> receiver(isolate->native_context()->global_object(), | 14573 Handle<JSObject> receiver(isolate->global_proxy()); |
| 14580 isolate); | |
| 14581 // This handle is nor shared, nor used later, so it's safe. | 14574 // This handle is nor shared, nor used later, so it's safe. |
| 14582 Handle<Object> argv[] = { key_handle }; | 14575 Handle<Object> argv[] = { key_handle }; |
| 14583 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14576 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 14584 isolate, value, | 14577 isolate, value, |
| 14585 Execution::Call(isolate, factory, receiver, ARRAY_SIZE(argv), argv)); | 14578 Execution::Call(isolate, factory, receiver, ARRAY_SIZE(argv), argv)); |
| 14586 } | 14579 } |
| 14587 | 14580 |
| 14588 #ifdef VERIFY_HEAP | 14581 #ifdef VERIFY_HEAP |
| 14589 if (FLAG_verify_heap) { | 14582 if (FLAG_verify_heap) { |
| 14590 cache_handle->JSFunctionResultCacheVerify(); | 14583 cache_handle->JSFunctionResultCacheVerify(); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14821 } | 14814 } |
| 14822 | 14815 |
| 14823 | 14816 |
| 14824 RUNTIME_FUNCTION(Runtime_ObserverObjectAndRecordHaveSameOrigin) { | 14817 RUNTIME_FUNCTION(Runtime_ObserverObjectAndRecordHaveSameOrigin) { |
| 14825 HandleScope scope(isolate); | 14818 HandleScope scope(isolate); |
| 14826 ASSERT(args.length() == 3); | 14819 ASSERT(args.length() == 3); |
| 14827 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); | 14820 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); |
| 14828 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); | 14821 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); |
| 14829 CONVERT_ARG_HANDLE_CHECKED(JSObject, record, 2); | 14822 CONVERT_ARG_HANDLE_CHECKED(JSObject, record, 2); |
| 14830 | 14823 |
| 14831 Handle<Context> observer_context(observer->context()->native_context(), | 14824 Handle<Context> observer_context(observer->context()->native_context()); |
| 14832 isolate); | |
| 14833 Handle<Context> object_context(object->GetCreationContext()); | 14825 Handle<Context> object_context(object->GetCreationContext()); |
| 14834 Handle<Context> record_context(record->GetCreationContext()); | 14826 Handle<Context> record_context(record->GetCreationContext()); |
| 14835 | 14827 |
| 14836 return isolate->heap()->ToBoolean( | 14828 return isolate->heap()->ToBoolean( |
| 14837 ContextsHaveSameOrigin(object_context, observer_context) && | 14829 ContextsHaveSameOrigin(object_context, observer_context) && |
| 14838 ContextsHaveSameOrigin(object_context, record_context)); | 14830 ContextsHaveSameOrigin(object_context, record_context)); |
| 14839 } | 14831 } |
| 14840 | 14832 |
| 14841 | 14833 |
| 14842 RUNTIME_FUNCTION(Runtime_ObjectWasCreatedInCurrentOrigin) { | 14834 RUNTIME_FUNCTION(Runtime_ObjectWasCreatedInCurrentOrigin) { |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15082 } | 15074 } |
| 15083 return NULL; | 15075 return NULL; |
| 15084 } | 15076 } |
| 15085 | 15077 |
| 15086 | 15078 |
| 15087 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15079 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
| 15088 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15080 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
| 15089 } | 15081 } |
| 15090 | 15082 |
| 15091 } } // namespace v8::internal | 15083 } } // namespace v8::internal |
| OLD | NEW |