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/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 HandleScope scope(isolate); | 370 HandleScope scope(isolate); |
371 DCHECK(args.length() == 2); | 371 DCHECK(args.length() == 2); |
372 | 372 |
373 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 373 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
374 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 374 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
375 | 375 |
376 RETURN_RESULT_OR_FAILURE(isolate, | 376 RETURN_RESULT_OR_FAILURE(isolate, |
377 Runtime::GetObjectProperty(isolate, object, key)); | 377 Runtime::GetObjectProperty(isolate, object, key)); |
378 } | 378 } |
379 | 379 |
| 380 RUNTIME_FUNCTION(Runtime_GetGlobal) { |
| 381 HandleScope scope(isolate); |
| 382 DCHECK(args.length() == 1); |
| 383 |
| 384 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 385 |
| 386 Handle<JSGlobalObject> global = isolate->global_object(); |
| 387 |
| 388 Handle<ScriptContextTable> script_contexts( |
| 389 global->native_context()->script_context_table()); |
| 390 |
| 391 ScriptContextTable::LookupResult lookup_result; |
| 392 if (ScriptContextTable::Lookup(script_contexts, name, &lookup_result)) { |
| 393 Handle<Context> script_context = ScriptContextTable::GetContext( |
| 394 script_contexts, lookup_result.context_index); |
| 395 Handle<Object> result = |
| 396 FixedArray::get(*script_context, lookup_result.slot_index, isolate); |
| 397 if (*result == *isolate->factory()->the_hole_value()) { |
| 398 THROW_NEW_ERROR_RETURN_FAILURE( |
| 399 isolate, NewReferenceError(MessageTemplate::kNotDefined, name)); |
| 400 } |
| 401 |
| 402 return *result; |
| 403 } |
| 404 |
| 405 Handle<Object> result; |
| 406 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 407 isolate, result, Runtime::GetObjectProperty(isolate, global, name)); |
| 408 return *result; |
| 409 } |
380 | 410 |
381 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 411 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
382 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { | 412 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { |
383 HandleScope scope(isolate); | 413 HandleScope scope(isolate); |
384 DCHECK(args.length() == 2); | 414 DCHECK(args.length() == 2); |
385 | 415 |
386 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); | 416 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); |
387 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); | 417 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); |
388 | 418 |
389 RETURN_RESULT_OR_FAILURE( | 419 RETURN_RESULT_OR_FAILURE( |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 isolate, o, key, &success, LookupIterator::OWN); | 1004 isolate, o, key, &success, LookupIterator::OWN); |
975 if (!success) return isolate->heap()->exception(); | 1005 if (!success) return isolate->heap()->exception(); |
976 MAYBE_RETURN( | 1006 MAYBE_RETURN( |
977 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 1007 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
978 isolate->heap()->exception()); | 1008 isolate->heap()->exception()); |
979 return *value; | 1009 return *value; |
980 } | 1010 } |
981 | 1011 |
982 } // namespace internal | 1012 } // namespace internal |
983 } // namespace v8 | 1013 } // namespace v8 |
OLD | NEW |