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