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-evaluate.h" | 8 #include "src/debug/debug-evaluate.h" |
9 #include "src/debug/debug-frames.h" | 9 #include "src/debug/debug-frames.h" |
10 #include "src/debug/debug-scopes.h" | 10 #include "src/debug/debug-scopes.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 | 130 |
131 case LookupIterator::DATA: | 131 case LookupIterator::DATA: |
132 return it->GetDataValue(); | 132 return it->GetDataValue(); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 return it->isolate()->factory()->undefined_value(); | 136 return it->isolate()->factory()->undefined_value(); |
137 } | 137 } |
138 | 138 |
139 | |
140 static Handle<Object> DebugGetProperty(Handle<Object> object, | |
141 Handle<Name> name) { | |
142 LookupIterator it(object, name); | |
143 return DebugGetProperty(&it); | |
144 } | |
145 | |
146 | |
147 template <class IteratorType> | 139 template <class IteratorType> |
148 static MaybeHandle<JSArray> GetIteratorInternalProperties( | 140 static MaybeHandle<JSArray> GetIteratorInternalProperties( |
149 Isolate* isolate, Handle<IteratorType> object) { | 141 Isolate* isolate, Handle<IteratorType> object) { |
150 Factory* factory = isolate->factory(); | 142 Factory* factory = isolate->factory(); |
151 Handle<IteratorType> iterator = Handle<IteratorType>::cast(object); | 143 Handle<IteratorType> iterator = Handle<IteratorType>::cast(object); |
152 CHECK(iterator->kind()->IsSmi()); | 144 CHECK(iterator->kind()->IsSmi()); |
153 const char* kind = NULL; | 145 const char* kind = NULL; |
154 switch (Smi::cast(iterator->kind())->value()) { | 146 switch (Smi::cast(iterator->kind())->value()) { |
155 case IteratorType::kKindKeys: | 147 case IteratorType::kKindKeys: |
156 kind = "keys"; | 148 kind = "keys"; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 factory->NewStringFromAsciiChecked("[[GeneratorFunction]]"); | 233 factory->NewStringFromAsciiChecked("[[GeneratorFunction]]"); |
242 result->set(2, *function); | 234 result->set(2, *function); |
243 result->set(3, generator->function()); | 235 result->set(3, generator->function()); |
244 | 236 |
245 Handle<String> receiver = | 237 Handle<String> receiver = |
246 factory->NewStringFromAsciiChecked("[[GeneratorReceiver]]"); | 238 factory->NewStringFromAsciiChecked("[[GeneratorReceiver]]"); |
247 result->set(4, *receiver); | 239 result->set(4, *receiver); |
248 result->set(5, generator->receiver()); | 240 result->set(5, generator->receiver()); |
249 return factory->NewJSArrayWithElements(result); | 241 return factory->NewJSArrayWithElements(result); |
250 } else if (object->IsJSPromise()) { | 242 } else if (object->IsJSPromise()) { |
251 Handle<JSObject> promise = Handle<JSObject>::cast(object); | 243 Handle<JSPromise> promise = Handle<JSPromise>::cast(object); |
252 | 244 const char* status = JSPromise::Status(promise->status()); |
253 Handle<Object> status_obj = | |
254 DebugGetProperty(promise, isolate->factory()->promise_state_symbol()); | |
255 CHECK(status_obj->IsSmi()); | |
256 const char* status = "rejected"; | |
257 int status_val = Handle<Smi>::cast(status_obj)->value(); | |
258 switch (status_val) { | |
259 case kPromiseFulfilled: | |
260 status = "resolved"; | |
261 break; | |
262 case kPromisePending: | |
263 status = "pending"; | |
264 break; | |
265 default: | |
266 DCHECK_EQ(kPromiseRejected, status_val); | |
267 } | |
268 | |
269 Handle<FixedArray> result = factory->NewFixedArray(2 * 2); | 245 Handle<FixedArray> result = factory->NewFixedArray(2 * 2); |
270 Handle<String> promise_status = | 246 Handle<String> promise_status = |
271 factory->NewStringFromAsciiChecked("[[PromiseStatus]]"); | 247 factory->NewStringFromAsciiChecked("[[PromiseStatus]]"); |
272 result->set(0, *promise_status); | 248 result->set(0, *promise_status); |
273 Handle<String> status_str = factory->NewStringFromAsciiChecked(status); | 249 Handle<String> status_str = factory->NewStringFromAsciiChecked(status); |
274 result->set(1, *status_str); | 250 result->set(1, *status_str); |
275 | 251 |
276 Handle<Object> value_obj = | 252 Handle<Object> value_obj(promise->result(), isolate); |
277 DebugGetProperty(promise, isolate->factory()->promise_result_symbol()); | |
278 Handle<String> promise_value = | 253 Handle<String> promise_value = |
279 factory->NewStringFromAsciiChecked("[[PromiseValue]]"); | 254 factory->NewStringFromAsciiChecked("[[PromiseValue]]"); |
280 result->set(2, *promise_value); | 255 result->set(2, *promise_value); |
281 result->set(3, *value_obj); | 256 result->set(3, *value_obj); |
282 return factory->NewJSArrayWithElements(result); | 257 return factory->NewJSArrayWithElements(result); |
283 } else if (object->IsJSProxy()) { | 258 } else if (object->IsJSProxy()) { |
284 Handle<JSProxy> js_proxy = Handle<JSProxy>::cast(object); | 259 Handle<JSProxy> js_proxy = Handle<JSProxy>::cast(object); |
285 Handle<FixedArray> result = factory->NewFixedArray(3 * 2); | 260 Handle<FixedArray> result = factory->NewFixedArray(3 * 2); |
286 | 261 |
287 Handle<String> handler_str = | 262 Handle<String> handler_str = |
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 } | 1923 } |
1949 | 1924 |
1950 | 1925 |
1951 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1926 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
1952 UNIMPLEMENTED(); | 1927 UNIMPLEMENTED(); |
1953 return NULL; | 1928 return NULL; |
1954 } | 1929 } |
1955 | 1930 |
1956 } // namespace internal | 1931 } // namespace internal |
1957 } // namespace v8 | 1932 } // namespace v8 |
OLD | NEW |