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

Side by Side Diff: src/runtime/runtime-debug.cc

Issue 1542963002: [runtime] Introduce dedicated JSBoundFunction to represent bound functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@FunctionConstructor
Patch Set: [arm64] Poke does not preserve flags with --debug-code. Created 4 years, 12 months 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
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-function.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 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
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
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
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_EQ(1, args.length());
1481 1483
1482 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); 1484 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0);
1483 Handle<Object> name = JSFunction::GetDebugName(f); 1485
1486 if (function->IsJSBoundFunction()) {
1487 return Handle<JSBoundFunction>::cast(function)->name();
1488 }
1489 Handle<Object> name =
1490 JSFunction::GetDebugName(Handle<JSFunction>::cast(function));
1484 return *name; 1491 return *name;
1485 } 1492 }
1486 1493
1487 1494
1488 // A testing entry. Returns statement position which is the closest to 1495 // A testing entry. Returns statement position which is the closest to
1489 // source_position. 1496 // source_position.
1490 RUNTIME_FUNCTION(Runtime_GetFunctionCodePositionFromSource) { 1497 RUNTIME_FUNCTION(Runtime_GetFunctionCodePositionFromSource) {
1491 HandleScope scope(isolate); 1498 HandleScope scope(isolate);
1492 CHECK(isolate->debug()->live_edit_enabled()); 1499 CHECK(isolate->debug()->live_edit_enabled());
1493 DCHECK(args.length() == 2); 1500 DCHECK(args.length() == 2);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 return Smi::FromInt(isolate->debug()->is_active()); 1687 return Smi::FromInt(isolate->debug()->is_active());
1681 } 1688 }
1682 1689
1683 1690
1684 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { 1691 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
1685 UNIMPLEMENTED(); 1692 UNIMPLEMENTED();
1686 return NULL; 1693 return NULL;
1687 } 1694 }
1688 } // namespace internal 1695 } // namespace internal
1689 } // namespace v8 1696 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698