| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/debug/debug-evaluate.h" | 9 #include "src/debug/debug-evaluate.h" |
| 10 #include "src/debug/debug-frames.h" | 10 #include "src/debug/debug-frames.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 result->set(4, *iterator_kind); | 143 result->set(4, *iterator_kind); |
| 144 Handle<String> kind_str = factory->NewStringFromAsciiChecked(kind); | 144 Handle<String> kind_str = factory->NewStringFromAsciiChecked(kind); |
| 145 result->set(5, *kind_str); | 145 result->set(5, *kind_str); |
| 146 return factory->NewJSArrayWithElements(result); | 146 return factory->NewJSArrayWithElements(result); |
| 147 } | 147 } |
| 148 | 148 |
| 149 | 149 |
| 150 MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate, | 150 MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate, |
| 151 Handle<Object> object) { | 151 Handle<Object> object) { |
| 152 Factory* factory = isolate->factory(); | 152 Factory* factory = isolate->factory(); |
| 153 if (object->IsJSFunction()) { | 153 if (object->IsJSBoundFunction()) { |
| 154 Handle<JSFunction> function = Handle<JSFunction>::cast(object); | 154 Handle<JSBoundFunction> function = Handle<JSBoundFunction>::cast(object); |
| 155 if (function->shared()->bound()) { | |
| 156 RUNTIME_ASSERT_HANDLIFIED(function->function_bindings()->IsFixedArray(), | |
| 157 JSArray); | |
| 158 | 155 |
| 159 Handle<BindingsArray> bindings(function->function_bindings()); | 156 Handle<FixedArray> result = factory->NewFixedArray(2 * 3); |
| 157 Handle<String> target = |
| 158 factory->NewStringFromAsciiChecked("[[TargetFunction]]"); |
| 159 result->set(0, *target); |
| 160 result->set(1, function->bound_target_function()); |
| 160 | 161 |
| 161 Handle<FixedArray> result = factory->NewFixedArray(2 * 3); | 162 Handle<String> bound_this = |
| 162 Handle<String> target = | 163 factory->NewStringFromAsciiChecked("[[BoundThis]]"); |
| 163 factory->NewStringFromAsciiChecked("[[TargetFunction]]"); | 164 result->set(2, *bound_this); |
| 164 result->set(0, *target); | 165 result->set(3, function->bound_this()); |
| 165 result->set(1, bindings->bound_function()); | |
| 166 | 166 |
| 167 Handle<String> bound_this = | 167 Handle<String> bound_args = |
| 168 factory->NewStringFromAsciiChecked("[[BoundThis]]"); | 168 factory->NewStringFromAsciiChecked("[[BoundArgs]]"); |
| 169 result->set(2, *bound_this); | 169 result->set(4, *bound_args); |
| 170 result->set(3, bindings->bound_this()); | 170 Handle<FixedArray> bound_arguments = |
| 171 | 171 factory->CopyFixedArray(handle(function->bound_arguments(), isolate)); |
| 172 Handle<String> bound_args = | 172 Handle<JSArray> arguments_array = |
| 173 factory->NewStringFromAsciiChecked("[[BoundArgs]]"); | 173 factory->NewJSArrayWithElements(bound_arguments); |
| 174 result->set(4, *bound_args); | 174 result->set(5, *arguments_array); |
| 175 Handle<JSArray> arguments_array = | 175 return factory->NewJSArrayWithElements(result); |
| 176 BindingsArray::CreateBoundArguments(bindings); | |
| 177 result->set(5, *arguments_array); | |
| 178 return factory->NewJSArrayWithElements(result); | |
| 179 } | |
| 180 } else if (object->IsJSMapIterator()) { | 176 } else if (object->IsJSMapIterator()) { |
| 181 Handle<JSMapIterator> iterator = Handle<JSMapIterator>::cast(object); | 177 Handle<JSMapIterator> iterator = Handle<JSMapIterator>::cast(object); |
| 182 return GetIteratorInternalProperties(isolate, iterator); | 178 return GetIteratorInternalProperties(isolate, iterator); |
| 183 } else if (object->IsJSSetIterator()) { | 179 } else if (object->IsJSSetIterator()) { |
| 184 Handle<JSSetIterator> iterator = Handle<JSSetIterator>::cast(object); | 180 Handle<JSSetIterator> iterator = Handle<JSSetIterator>::cast(object); |
| 185 return GetIteratorInternalProperties(isolate, iterator); | 181 return GetIteratorInternalProperties(isolate, iterator); |
| 186 } else if (object->IsJSGeneratorObject()) { | 182 } else if (object->IsJSGeneratorObject()) { |
| 187 Handle<JSGeneratorObject> generator = | 183 Handle<JSGeneratorObject> generator = |
| 188 Handle<JSGeneratorObject>::cast(object); | 184 Handle<JSGeneratorObject>::cast(object); |
| 189 | 185 |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); | 862 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); |
| 867 for (int i = 0; i < result.length(); ++i) { | 863 for (int i = 0; i < result.length(); ++i) { |
| 868 array->set(i, *result[i]); | 864 array->set(i, *result[i]); |
| 869 } | 865 } |
| 870 return *isolate->factory()->NewJSArrayWithElements(array); | 866 return *isolate->factory()->NewJSArrayWithElements(array); |
| 871 } | 867 } |
| 872 | 868 |
| 873 | 869 |
| 874 RUNTIME_FUNCTION(Runtime_GetFunctionScopeCount) { | 870 RUNTIME_FUNCTION(Runtime_GetFunctionScopeCount) { |
| 875 HandleScope scope(isolate); | 871 HandleScope scope(isolate); |
| 876 DCHECK(args.length() == 1); | 872 DCHECK_EQ(1, args.length()); |
| 877 | 873 |
| 878 // Check arguments. | 874 // Check arguments. |
| 879 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 875 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
| 880 | 876 |
| 881 // Count the visible scopes. | 877 // Count the visible scopes. |
| 882 int n = 0; | 878 int n = 0; |
| 883 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) { | 879 if (function->IsJSFunction()) { |
| 884 n++; | 880 for (ScopeIterator it(isolate, Handle<JSFunction>::cast(function)); |
| 881 !it.Done(); it.Next()) { |
| 882 n++; |
| 883 } |
| 885 } | 884 } |
| 886 | 885 |
| 887 return Smi::FromInt(n); | 886 return Smi::FromInt(n); |
| 888 } | 887 } |
| 889 | 888 |
| 890 | 889 |
| 891 RUNTIME_FUNCTION(Runtime_GetFunctionScopeDetails) { | 890 RUNTIME_FUNCTION(Runtime_GetFunctionScopeDetails) { |
| 892 HandleScope scope(isolate); | 891 HandleScope scope(isolate); |
| 893 DCHECK(args.length() == 2); | 892 DCHECK(args.length() == 2); |
| 894 | 893 |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 int compilation_state = script->compilation_state(); | 1460 int compilation_state = script->compilation_state(); |
| 1462 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); | 1461 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); |
| 1463 script->set_source(*source); | 1462 script->set_source(*source); |
| 1464 | 1463 |
| 1465 return isolate->heap()->undefined_value(); | 1464 return isolate->heap()->undefined_value(); |
| 1466 } | 1465 } |
| 1467 | 1466 |
| 1468 | 1467 |
| 1469 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { | 1468 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { |
| 1470 SealHandleScope shs(isolate); | 1469 SealHandleScope shs(isolate); |
| 1471 DCHECK(args.length() == 1); | 1470 DCHECK_EQ(1, args.length()); |
| 1472 | 1471 |
| 1473 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1472 CONVERT_ARG_CHECKED(Object, f, 0); |
| 1474 return f->shared()->inferred_name(); | 1473 if (f->IsJSFunction()) { |
| 1474 return JSFunction::cast(f)->shared()->inferred_name(); |
| 1475 } |
| 1476 return isolate->heap()->empty_string(); |
| 1475 } | 1477 } |
| 1476 | 1478 |
| 1477 | 1479 |
| 1478 RUNTIME_FUNCTION(Runtime_FunctionGetDebugName) { | 1480 RUNTIME_FUNCTION(Runtime_FunctionGetDebugName) { |
| 1479 HandleScope scope(isolate); | 1481 HandleScope scope(isolate); |
| 1480 DCHECK(args.length() == 1); | 1482 DCHECK(args.length() == 1); |
| 1481 | 1483 |
| 1482 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); | 1484 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); |
| 1483 Handle<Object> name = JSFunction::GetDebugName(f); | 1485 Handle<Object> name = JSFunction::GetDebugName(f); |
| 1484 return *name; | 1486 return *name; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 return Smi::FromInt(isolate->debug()->is_active()); | 1682 return Smi::FromInt(isolate->debug()->is_active()); |
| 1681 } | 1683 } |
| 1682 | 1684 |
| 1683 | 1685 |
| 1684 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1686 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
| 1685 UNIMPLEMENTED(); | 1687 UNIMPLEMENTED(); |
| 1686 return NULL; | 1688 return NULL; |
| 1687 } | 1689 } |
| 1688 } // namespace internal | 1690 } // namespace internal |
| 1689 } // namespace v8 | 1691 } // namespace v8 |
| OLD | NEW |