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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 0); | 181 CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 0); |
182 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1); | 182 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1); |
183 CONVERT_SMI_ARG_CHECKED(start_position, 2); | 183 CONVERT_SMI_ARG_CHECKED(start_position, 2); |
184 CONVERT_SMI_ARG_CHECKED(end_position, 3); | 184 CONVERT_SMI_ARG_CHECKED(end_position, 3); |
185 | 185 |
186 RETURN_RESULT_OR_FAILURE( | 186 RETURN_RESULT_OR_FAILURE( |
187 isolate, DefineClass(isolate, super_class, constructor, start_position, | 187 isolate, DefineClass(isolate, super_class, constructor, start_position, |
188 end_position)); | 188 end_position)); |
189 } | 189 } |
190 | 190 |
| 191 |
| 192 RUNTIME_FUNCTION(Runtime_DefineClassNameProperty) { |
| 193 HandleScope scope(isolate); |
| 194 DCHECK(args.length() == 2); |
| 195 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 196 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
| 197 |
| 198 // Abort if "name" is undefined. |
| 199 if (name->length() == 0) return *object; |
| 200 |
| 201 // If a property named "name" is already defined, exit. |
| 202 Handle<Name> key = isolate->factory()->name_string(); |
| 203 if (JSObject::HasRealNamedProperty(object, key).FromMaybe(false)) |
| 204 return *object; |
| 205 |
| 206 // Define the "name" property. |
| 207 PropertyAttributes attrs = |
| 208 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY); |
| 209 // Cannot fail since this should only be called when creating an object |
| 210 // literal. |
| 211 DCHECK(!JSObject::SetOwnPropertyIgnoreAttributes(object, key, name, attrs) |
| 212 .is_null()); |
| 213 return *object; |
| 214 } |
| 215 |
191 namespace { | 216 namespace { |
192 | 217 |
193 enum class SuperMode { kLoad, kStore }; | 218 enum class SuperMode { kLoad, kStore }; |
194 | 219 |
195 MaybeHandle<JSReceiver> GetSuperHolder( | 220 MaybeHandle<JSReceiver> GetSuperHolder( |
196 Isolate* isolate, Handle<Object> receiver, Handle<JSObject> home_object, | 221 Isolate* isolate, Handle<Object> receiver, Handle<JSObject> home_object, |
197 SuperMode mode, MaybeHandle<Name> maybe_name, uint32_t index) { | 222 SuperMode mode, MaybeHandle<Name> maybe_name, uint32_t index) { |
198 if (home_object->IsAccessCheckNeeded() && | 223 if (home_object->IsAccessCheckNeeded() && |
199 !isolate->MayAccess(handle(isolate->context()), home_object)) { | 224 !isolate->MayAccess(handle(isolate->context()), home_object)) { |
200 isolate->ReportFailedAccessCheck(home_object); | 225 isolate->ReportFailedAccessCheck(home_object); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 426 |
402 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { | 427 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { |
403 SealHandleScope shs(isolate); | 428 SealHandleScope shs(isolate); |
404 DCHECK_EQ(1, args.length()); | 429 DCHECK_EQ(1, args.length()); |
405 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); | 430 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); |
406 return active_function->map()->prototype(); | 431 return active_function->map()->prototype(); |
407 } | 432 } |
408 | 433 |
409 } // namespace internal | 434 } // namespace internal |
410 } // namespace v8 | 435 } // namespace v8 |
OLD | NEW |