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 <stdlib.h> | 7 #include <stdlib.h> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 RUNTIME_FUNCTION(Runtime_ThrowIfStaticPrototype) { | 68 RUNTIME_FUNCTION(Runtime_ThrowIfStaticPrototype) { |
69 HandleScope scope(isolate); | 69 HandleScope scope(isolate); |
70 DCHECK(args.length() == 1); | 70 DCHECK(args.length() == 1); |
71 CONVERT_ARG_HANDLE_CHECKED(Name, name, 0); | 71 CONVERT_ARG_HANDLE_CHECKED(Name, name, 0); |
72 if (Name::Equals(name, isolate->factory()->prototype_string())) { | 72 if (Name::Equals(name, isolate->factory()->prototype_string())) { |
73 return ThrowStaticPrototypeError(isolate); | 73 return ThrowStaticPrototypeError(isolate); |
74 } | 74 } |
75 return *name; | 75 return *name; |
76 } | 76 } |
77 | 77 |
| 78 RUNTIME_FUNCTION(Runtime_ThrowIfMissingPrivateField) { |
| 79 // TODO(bakkot) it would be better if this were done as part of the property |
| 80 // lookup, instead of prior to it. |
| 81 // Currently the parser emits code which looks like |
| 82 // %ThrowIfMissingPrivateField(x, field)[field] |
| 83 HandleScope scope(isolate); |
| 84 DCHECK(args.length() == 2); |
| 85 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 86 CONVERT_ARG_HANDLE_CHECKED(Symbol, name, 1); |
| 87 DCHECK(name->is_private()); |
| 88 |
| 89 if (!object->IsJSReceiver() || |
| 90 !JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(object), name) |
| 91 .FromMaybe(false)) { // Note that this does not trigger proxy traps |
| 92 // when name is a private symbol. |
| 93 THROW_NEW_ERROR_RETURN_FAILURE( |
| 94 isolate, NewTypeError(MessageTemplate::kMissingPrivateField)); |
| 95 } |
| 96 return *object; // This is used; after calling this method the field is |
| 97 // immediately accessed. |
| 98 } |
78 | 99 |
79 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) { | 100 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) { |
80 DCHECK(args.length() == 0); | 101 DCHECK(args.length() == 0); |
81 return isolate->heap()->home_object_symbol(); | 102 return isolate->heap()->home_object_symbol(); |
82 } | 103 } |
83 | 104 |
84 static MaybeHandle<Object> DefineClass(Isolate* isolate, | 105 static MaybeHandle<Object> DefineClass(Isolate* isolate, |
85 Handle<Object> super_class, | 106 Handle<Object> super_class, |
86 Handle<JSFunction> constructor, | 107 Handle<JSFunction> constructor, |
87 int start_position, int end_position) { | 108 int start_position, int end_position) { |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 411 |
391 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { | 412 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { |
392 SealHandleScope shs(isolate); | 413 SealHandleScope shs(isolate); |
393 DCHECK_EQ(1, args.length()); | 414 DCHECK_EQ(1, args.length()); |
394 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); | 415 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); |
395 return active_function->map()->prototype(); | 416 return active_function->map()->prototype(); |
396 } | 417 } |
397 | 418 |
398 } // namespace internal | 419 } // namespace internal |
399 } // namespace v8 | 420 } // namespace v8 |
OLD | NEW |