Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/runtime/runtime-object.cc

Issue 2237983004: Merged: Squashed multiple commits. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.3
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api-interceptors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "src/messages.h" 11 #include "src/messages.h"
12 #include "src/property-descriptor.h" 12 #include "src/property-descriptor.h"
13 #include "src/runtime/runtime.h" 13 #include "src/runtime/runtime.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 MaybeHandle<Object> Runtime::GetObjectProperty( 18 MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
19 Isolate* isolate, Handle<Object> object, Handle<Object> key, 19 Handle<Object> object,
20 bool should_throw_reference_error) { 20 Handle<Object> key,
21 bool* is_found_out) {
21 if (object->IsUndefined(isolate) || object->IsNull(isolate)) { 22 if (object->IsUndefined(isolate) || object->IsNull(isolate)) {
22 THROW_NEW_ERROR( 23 THROW_NEW_ERROR(
23 isolate, 24 isolate,
24 NewTypeError(MessageTemplate::kNonObjectPropertyLoad, key, object), 25 NewTypeError(MessageTemplate::kNonObjectPropertyLoad, key, object),
25 Object); 26 Object);
26 } 27 }
27 28
28 bool success = false; 29 bool success = false;
29 LookupIterator it = 30 LookupIterator it =
30 LookupIterator::PropertyOrElement(isolate, object, key, &success); 31 LookupIterator::PropertyOrElement(isolate, object, key, &success);
31 if (!success) return MaybeHandle<Object>(); 32 if (!success) return MaybeHandle<Object>();
32 33
33 MaybeHandle<Object> result = Object::GetProperty(&it); 34 MaybeHandle<Object> result = Object::GetProperty(&it);
34 if (!result.is_null() && should_throw_reference_error && !it.IsFound()) { 35 if (is_found_out) *is_found_out = it.IsFound();
35 THROW_NEW_ERROR(
36 isolate, NewReferenceError(MessageTemplate::kNotDefined, key), Object);
37 }
38 return result; 36 return result;
39 } 37 }
40 38
41 static MaybeHandle<Object> KeyedGetObjectProperty(Isolate* isolate, 39 static MaybeHandle<Object> KeyedGetObjectProperty(Isolate* isolate,
42 Handle<Object> receiver_obj, 40 Handle<Object> receiver_obj,
43 Handle<Object> key_obj) { 41 Handle<Object> key_obj) {
44 // Fast cases for getting named properties of the receiver JSObject 42 // Fast cases for getting named properties of the receiver JSObject
45 // itself. 43 // itself.
46 // 44 //
47 // The global proxy objects has to be excluded since LookupOwn on 45 // The global proxy objects has to be excluded since LookupOwn on
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 HandleScope scope(isolate); 339 HandleScope scope(isolate);
342 DCHECK(args.length() == 2); 340 DCHECK(args.length() == 2);
343 341
344 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 342 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
345 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 343 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
346 344
347 RETURN_RESULT_OR_FAILURE(isolate, 345 RETURN_RESULT_OR_FAILURE(isolate,
348 Runtime::GetObjectProperty(isolate, object, key)); 346 Runtime::GetObjectProperty(isolate, object, key));
349 } 347 }
350 348
351 namespace {
352
353 Object* GetGlobal(Isolate* isolate, int slot, Handle<TypeFeedbackVector> vector,
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
361 Handle<JSGlobalObject> global = isolate->global_object();
362
363 Handle<ScriptContextTable> script_contexts(
364 global->native_context()->script_context_table());
365
366 ScriptContextTable::LookupResult lookup_result;
367 if (ScriptContextTable::Lookup(script_contexts, name, &lookup_result)) {
368 Handle<Context> script_context = ScriptContextTable::GetContext(
369 script_contexts, lookup_result.context_index);
370 Handle<Object> result =
371 FixedArray::get(*script_context, lookup_result.slot_index, isolate);
372 if (*result == *isolate->factory()->the_hole_value()) {
373 THROW_NEW_ERROR_RETURN_FAILURE(
374 isolate, NewReferenceError(MessageTemplate::kNotDefined, name));
375 }
376 return *result;
377 }
378
379 Handle<Object> result;
380 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
381 isolate, result,
382 Runtime::GetObjectProperty(isolate, global, name,
383 should_throw_reference_error));
384 return *result;
385 }
386
387 } // namespace
388
389 RUNTIME_FUNCTION(Runtime_GetGlobalInsideTypeof) {
390 HandleScope scope(isolate);
391 DCHECK_EQ(2, args.length());
392 CONVERT_SMI_ARG_CHECKED(slot, 0);
393 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1);
394 return GetGlobal(isolate, slot, vector, false);
395 }
396
397 RUNTIME_FUNCTION(Runtime_GetGlobalNotInsideTypeof) {
398 HandleScope scope(isolate);
399 DCHECK_EQ(2, args.length());
400 CONVERT_SMI_ARG_CHECKED(slot, 0);
401 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1);
402 return GetGlobal(isolate, slot, vector, true);
403 }
404
405 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. 349 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric.
406 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { 350 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
407 HandleScope scope(isolate); 351 HandleScope scope(isolate);
408 DCHECK(args.length() == 2); 352 DCHECK(args.length() == 2);
409 353
410 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); 354 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0);
411 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); 355 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1);
412 356
413 RETURN_RESULT_OR_FAILURE( 357 RETURN_RESULT_OR_FAILURE(
414 isolate, KeyedGetObjectProperty(isolate, receiver_obj, key_obj)); 358 isolate, KeyedGetObjectProperty(isolate, receiver_obj, key_obj));
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 isolate, o, key, &success, LookupIterator::OWN); 940 isolate, o, key, &success, LookupIterator::OWN);
997 if (!success) return isolate->heap()->exception(); 941 if (!success) return isolate->heap()->exception();
998 MAYBE_RETURN( 942 MAYBE_RETURN(
999 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), 943 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR),
1000 isolate->heap()->exception()); 944 isolate->heap()->exception());
1001 return *value; 945 return *value;
1002 } 946 }
1003 947
1004 } // namespace internal 948 } // namespace internal
1005 } // namespace v8 949 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api-interceptors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698