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/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/debug/debug-coverage.h" | 9 #include "src/debug/debug-coverage.h" |
10 #include "src/debug/debug-evaluate.h" | 10 #include "src/debug/debug-evaluate.h" |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 | 914 |
915 RUNTIME_FUNCTION(Runtime_GetGeneratorScopeCount) { | 915 RUNTIME_FUNCTION(Runtime_GetGeneratorScopeCount) { |
916 HandleScope scope(isolate); | 916 HandleScope scope(isolate); |
917 DCHECK_EQ(1, args.length()); | 917 DCHECK_EQ(1, args.length()); |
918 | 918 |
919 if (!args[0]->IsJSGeneratorObject()) return Smi::kZero; | 919 if (!args[0]->IsJSGeneratorObject()) return Smi::kZero; |
920 | 920 |
921 // Check arguments. | 921 // Check arguments. |
922 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, gen, 0); | 922 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, gen, 0); |
923 | 923 |
| 924 // Only inspect suspended generator scopes. |
| 925 if (!gen->is_suspended()) { |
| 926 return Smi::kZero; |
| 927 } |
| 928 |
924 // Count the visible scopes. | 929 // Count the visible scopes. |
925 int n = 0; | 930 int n = 0; |
926 for (ScopeIterator it(isolate, gen); !it.Done(); it.Next()) { | 931 for (ScopeIterator it(isolate, gen); !it.Done(); it.Next()) { |
927 n++; | 932 n++; |
928 } | 933 } |
929 | 934 |
930 return Smi::FromInt(n); | 935 return Smi::FromInt(n); |
931 } | 936 } |
932 | 937 |
933 RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) { | 938 RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) { |
934 HandleScope scope(isolate); | 939 HandleScope scope(isolate); |
935 DCHECK_EQ(2, args.length()); | 940 DCHECK_EQ(2, args.length()); |
936 | 941 |
937 if (!args[0]->IsJSGeneratorObject()) { | 942 if (!args[0]->IsJSGeneratorObject()) { |
938 return isolate->heap()->undefined_value(); | 943 return isolate->heap()->undefined_value(); |
939 } | 944 } |
940 | 945 |
941 // Check arguments. | 946 // Check arguments. |
942 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, gen, 0); | 947 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, gen, 0); |
943 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 948 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
944 | 949 |
| 950 // Only inspect suspended generator scopes. |
| 951 if (!gen->is_suspended()) { |
| 952 return isolate->heap()->undefined_value(); |
| 953 } |
| 954 |
945 // Find the requested scope. | 955 // Find the requested scope. |
946 int n = 0; | 956 int n = 0; |
947 ScopeIterator it(isolate, gen); | 957 ScopeIterator it(isolate, gen); |
948 for (; !it.Done() && n < index; it.Next()) { | 958 for (; !it.Done() && n < index; it.Next()) { |
949 n++; | 959 n++; |
950 } | 960 } |
951 if (it.Done()) { | 961 if (it.Done()) { |
952 return isolate->heap()->undefined_value(); | 962 return isolate->heap()->undefined_value(); |
953 } | 963 } |
954 | 964 |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 RUNTIME_FUNCTION(Runtime_DebugTogglePreciseCoverage) { | 1970 RUNTIME_FUNCTION(Runtime_DebugTogglePreciseCoverage) { |
1961 SealHandleScope shs(isolate); | 1971 SealHandleScope shs(isolate); |
1962 CONVERT_BOOLEAN_ARG_CHECKED(enable, 0); | 1972 CONVERT_BOOLEAN_ARG_CHECKED(enable, 0); |
1963 Coverage::SelectMode(isolate, enable ? debug::Coverage::kPreciseCount | 1973 Coverage::SelectMode(isolate, enable ? debug::Coverage::kPreciseCount |
1964 : debug::Coverage::kBestEffort); | 1974 : debug::Coverage::kBestEffort); |
1965 return isolate->heap()->undefined_value(); | 1975 return isolate->heap()->undefined_value(); |
1966 } | 1976 } |
1967 | 1977 |
1968 } // namespace internal | 1978 } // namespace internal |
1969 } // namespace v8 | 1979 } // namespace v8 |
OLD | NEW |