| 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/v8.h" | 5 #include "src/v8.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.h" | 9 #include "src/debug.h" |
| 10 #include "src/runtime/runtime.h" | 10 #include "src/runtime/runtime.h" |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (name->AsArrayIndex(&index)) { | 235 if (name->AsArrayIndex(&index)) { |
| 236 return JSObject::SetElement(js_object, index, value, attr, SLOPPY, false, | 236 return JSObject::SetElement(js_object, index, value, attr, SLOPPY, false, |
| 237 DEFINE_PROPERTY); | 237 DEFINE_PROPERTY); |
| 238 } else { | 238 } else { |
| 239 return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value, | 239 return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value, |
| 240 attr); | 240 attr); |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 | 243 |
| 244 | 244 |
| 245 MaybeHandle<Object> Runtime::GetPrototype(Isolate* isolate, | 245 RUNTIME_FUNCTION(Runtime_GetPrototype) { |
| 246 Handle<Object> obj) { | 246 HandleScope scope(isolate); |
| 247 DCHECK(args.length() == 1); |
| 248 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
| 247 // We don't expect access checks to be needed on JSProxy objects. | 249 // We don't expect access checks to be needed on JSProxy objects. |
| 248 DCHECK(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 250 DCHECK(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
| 249 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); | 251 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); |
| 250 do { | 252 do { |
| 251 if (PrototypeIterator::GetCurrent(iter)->IsAccessCheckNeeded() && | 253 if (PrototypeIterator::GetCurrent(iter)->IsAccessCheckNeeded() && |
| 252 !isolate->MayNamedAccess( | 254 !isolate->MayNamedAccess( |
| 253 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), | 255 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), |
| 254 isolate->factory()->proto_string(), v8::ACCESS_GET)) { | 256 isolate->factory()->proto_string(), v8::ACCESS_GET)) { |
| 255 isolate->ReportFailedAccessCheck( | 257 isolate->ReportFailedAccessCheck( |
| 256 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), | 258 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), |
| 257 v8::ACCESS_GET); | 259 v8::ACCESS_GET); |
| 258 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 260 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 259 return isolate->factory()->undefined_value(); | 261 return isolate->heap()->undefined_value(); |
| 260 } | 262 } |
| 261 iter.AdvanceIgnoringProxies(); | 263 iter.AdvanceIgnoringProxies(); |
| 262 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { | 264 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { |
| 263 return PrototypeIterator::GetCurrent(iter); | 265 return *PrototypeIterator::GetCurrent(iter); |
| 264 } | 266 } |
| 265 } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)); | 267 } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)); |
| 266 return PrototypeIterator::GetCurrent(iter); | 268 return *PrototypeIterator::GetCurrent(iter); |
| 267 } | 269 } |
| 268 | 270 |
| 269 | 271 |
| 270 RUNTIME_FUNCTION(Runtime_GetPrototype) { | |
| 271 HandleScope scope(isolate); | |
| 272 DCHECK(args.length() == 1); | |
| 273 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | |
| 274 Handle<Object> result; | |
| 275 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
| 276 Runtime::GetPrototype(isolate, obj)); | |
| 277 return *result; | |
| 278 } | |
| 279 | |
| 280 | |
| 281 RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { | 272 RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { |
| 282 HandleScope scope(isolate); | 273 HandleScope scope(isolate); |
| 283 DCHECK(args.length() == 2); | 274 DCHECK(args.length() == 2); |
| 284 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 275 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 285 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 276 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
| 286 DCHECK(!obj->IsAccessCheckNeeded()); | 277 DCHECK(!obj->IsAccessCheckNeeded()); |
| 287 DCHECK(!obj->map()->is_observed()); | 278 DCHECK(!obj->map()->is_observed()); |
| 288 Handle<Object> result; | 279 Handle<Object> result; |
| 289 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 280 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 290 isolate, result, JSObject::SetPrototype(obj, prototype, false)); | 281 isolate, result, JSObject::SetPrototype(obj, prototype, false)); |
| (...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 | 1577 |
| 1587 RUNTIME_FUNCTION(RuntimeReference_ClassOf) { | 1578 RUNTIME_FUNCTION(RuntimeReference_ClassOf) { |
| 1588 SealHandleScope shs(isolate); | 1579 SealHandleScope shs(isolate); |
| 1589 DCHECK(args.length() == 1); | 1580 DCHECK(args.length() == 1); |
| 1590 CONVERT_ARG_CHECKED(Object, obj, 0); | 1581 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 1591 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); | 1582 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); |
| 1592 return JSReceiver::cast(obj)->class_name(); | 1583 return JSReceiver::cast(obj)->class_name(); |
| 1593 } | 1584 } |
| 1594 } | 1585 } |
| 1595 } // namespace v8::internal | 1586 } // namespace v8::internal |
| OLD | NEW |