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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 343 |
344 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 344 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
345 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 345 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
346 | 346 |
347 RETURN_RESULT_OR_FAILURE(isolate, | 347 RETURN_RESULT_OR_FAILURE(isolate, |
348 Runtime::GetObjectProperty(isolate, object, key)); | 348 Runtime::GetObjectProperty(isolate, object, key)); |
349 } | 349 } |
350 | 350 |
351 namespace { | 351 namespace { |
352 | 352 |
353 Object* GetGlobal(Isolate* isolate, Handle<String> name, | 353 Object* GetGlobal(Isolate* isolate, int slot, Handle<TypeFeedbackVector> vector, |
354 bool should_throw_reference_error) { | 354 bool should_throw_reference_error) { |
| 355 FeedbackVectorSlot vector_slot = vector->ToSlot(slot); |
| 356 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, |
| 357 vector->GetKind(vector_slot)); |
| 358 Handle<String> name(vector->GetName(vector_slot), isolate); |
| 359 DCHECK_NE(*name, *isolate->factory()->empty_string()); |
| 360 |
355 Handle<JSGlobalObject> global = isolate->global_object(); | 361 Handle<JSGlobalObject> global = isolate->global_object(); |
356 | 362 |
357 Handle<ScriptContextTable> script_contexts( | 363 Handle<ScriptContextTable> script_contexts( |
358 global->native_context()->script_context_table()); | 364 global->native_context()->script_context_table()); |
359 | 365 |
360 ScriptContextTable::LookupResult lookup_result; | 366 ScriptContextTable::LookupResult lookup_result; |
361 if (ScriptContextTable::Lookup(script_contexts, name, &lookup_result)) { | 367 if (ScriptContextTable::Lookup(script_contexts, name, &lookup_result)) { |
362 Handle<Context> script_context = ScriptContextTable::GetContext( | 368 Handle<Context> script_context = ScriptContextTable::GetContext( |
363 script_contexts, lookup_result.context_index); | 369 script_contexts, lookup_result.context_index); |
364 Handle<Object> result = | 370 Handle<Object> result = |
(...skipping 10 matching lines...) Expand all Loading... |
375 isolate, result, | 381 isolate, result, |
376 Runtime::GetObjectProperty(isolate, global, name, | 382 Runtime::GetObjectProperty(isolate, global, name, |
377 should_throw_reference_error)); | 383 should_throw_reference_error)); |
378 return *result; | 384 return *result; |
379 } | 385 } |
380 | 386 |
381 } // namespace | 387 } // namespace |
382 | 388 |
383 RUNTIME_FUNCTION(Runtime_GetGlobalInsideTypeof) { | 389 RUNTIME_FUNCTION(Runtime_GetGlobalInsideTypeof) { |
384 HandleScope scope(isolate); | 390 HandleScope scope(isolate); |
385 DCHECK_EQ(1, args.length()); | 391 DCHECK_EQ(2, args.length()); |
386 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 392 CONVERT_SMI_ARG_CHECKED(slot, 0); |
387 return GetGlobal(isolate, name, false); | 393 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1); |
| 394 return GetGlobal(isolate, slot, vector, false); |
388 } | 395 } |
389 | 396 |
390 RUNTIME_FUNCTION(Runtime_GetGlobalNotInsideTypeof) { | 397 RUNTIME_FUNCTION(Runtime_GetGlobalNotInsideTypeof) { |
391 HandleScope scope(isolate); | 398 HandleScope scope(isolate); |
392 DCHECK_EQ(1, args.length()); | 399 DCHECK_EQ(2, args.length()); |
393 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 400 CONVERT_SMI_ARG_CHECKED(slot, 0); |
394 return GetGlobal(isolate, name, true); | 401 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1); |
| 402 return GetGlobal(isolate, slot, vector, true); |
395 } | 403 } |
396 | 404 |
397 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 405 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
398 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { | 406 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { |
399 HandleScope scope(isolate); | 407 HandleScope scope(isolate); |
400 DCHECK(args.length() == 2); | 408 DCHECK(args.length() == 2); |
401 | 409 |
402 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); | 410 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); |
403 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); | 411 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); |
404 | 412 |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 isolate, o, key, &success, LookupIterator::OWN); | 998 isolate, o, key, &success, LookupIterator::OWN); |
991 if (!success) return isolate->heap()->exception(); | 999 if (!success) return isolate->heap()->exception(); |
992 MAYBE_RETURN( | 1000 MAYBE_RETURN( |
993 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 1001 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
994 isolate->heap()->exception()); | 1002 isolate->heap()->exception()); |
995 return *value; | 1003 return *value; |
996 } | 1004 } |
997 | 1005 |
998 } // namespace internal | 1006 } // namespace internal |
999 } // namespace v8 | 1007 } // namespace v8 |
OLD | NEW |