Chromium Code Reviews| 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
| 11 #include "src/runtime/runtime.h" | 11 #include "src/runtime/runtime.h" |
| 12 #include "src/runtime/runtime-utils.h" | 12 #include "src/runtime/runtime-utils.h" |
| 13 | 13 |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 | 18 |
| 19 RUNTIME_FUNCTION(Runtime_ThrowNonMethodError) { | |
| 20 HandleScope scope(isolate); | |
| 21 DCHECK(args.length() == 0); | |
| 22 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 23 isolate, NewReferenceError("non_method", HandleVector<Object>(NULL, 0))); | |
| 24 } | |
| 25 | |
| 26 | |
| 27 static Object* ThrowUnsupportedSuper(Isolate* isolate) { | |
| 28 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 29 isolate, | |
| 30 NewReferenceError("unsupported_super", HandleVector<Object>(NULL, 0))); | |
| 31 } | |
| 32 | |
| 33 | |
| 34 RUNTIME_FUNCTION(Runtime_ThrowUnsupportedSuperError) { | |
| 35 HandleScope scope(isolate); | |
| 36 DCHECK(args.length() == 0); | |
| 37 return ThrowUnsupportedSuper(isolate); | |
| 38 } | |
| 39 | |
| 40 | |
| 19 RUNTIME_FUNCTION(Runtime_ToMethod) { | 41 RUNTIME_FUNCTION(Runtime_ToMethod) { |
| 20 HandleScope scope(isolate); | 42 HandleScope scope(isolate); |
| 21 DCHECK(args.length() == 2); | 43 DCHECK(args.length() == 2); |
| 22 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 44 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
| 23 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 45 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
| 24 Handle<JSFunction> clone = JSFunction::CloneClosure(fun); | 46 Handle<JSFunction> clone = JSFunction::CloneClosure(fun); |
| 25 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol()); | 47 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol()); |
| 26 JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol, | 48 JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol, |
| 27 home_object, DONT_ENUM).Assert(); | 49 home_object, DONT_ENUM).Assert(); |
| 28 return *clone; | 50 return *clone; |
| 29 } | 51 } |
| 30 | 52 |
| 31 | 53 |
| 32 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) { | 54 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) { |
| 33 DCHECK(args.length() == 0); | 55 DCHECK(args.length() == 0); |
| 34 return isolate->heap()->home_object_symbol(); | 56 return isolate->heap()->home_object_symbol(); |
| 35 } | 57 } |
| 36 | 58 |
| 37 | 59 |
| 38 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { | 60 static Object* LoadFromSuper(Isolate* isolate, Handle<Object> receiver, |
| 39 HandleScope scope(isolate); | 61 Handle<JSObject> home_object, Handle<Name> name) { |
| 40 DCHECK(args.length() == 3); | |
| 41 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | |
| 42 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | |
| 43 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | |
| 44 | |
| 45 if (home_object->IsAccessCheckNeeded() && | 62 if (home_object->IsAccessCheckNeeded() && |
| 46 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_GET)) { | 63 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_GET)) { |
| 47 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_GET); | 64 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_GET); |
| 48 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 65 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 49 } | 66 } |
| 50 | 67 |
| 51 PrototypeIterator iter(isolate, home_object); | 68 PrototypeIterator iter(isolate, home_object); |
| 52 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); | 69 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); |
| 53 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value(); | 70 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value(); |
| 54 | 71 |
| 55 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto)); | 72 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto)); |
| 56 Handle<Object> result; | 73 Handle<Object> result; |
| 57 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 74 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); |
| 58 return *result; | 75 return *result; |
| 59 } | 76 } |
| 60 | 77 |
| 61 | 78 |
| 79 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { | |
| 80 HandleScope scope(isolate); | |
| 81 DCHECK(args.length() == 3); | |
| 82 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | |
| 83 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | |
| 84 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | |
| 85 | |
| 86 return LoadFromSuper(isolate, receiver, home_object, name); | |
| 87 } | |
| 88 | |
| 89 | |
| 90 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { | |
| 91 HandleScope scope(isolate); | |
| 92 DCHECK(args.length() == 3); | |
| 93 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | |
| 94 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | |
| 95 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | |
| 96 | |
| 97 Handle<Name> name; | |
| 98 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | |
| 99 Runtime::ToName(isolate, key)); | |
| 100 uint32_t index; | |
| 101 if (name->AsArrayIndex(&index)) { | |
| 102 return ThrowUnsupportedSuper(isolate); | |
|
arv (Not doing code reviews)
2014/10/02 16:54:24
Add a FIXME/tracking bug?
| |
| 103 } | |
| 104 return LoadFromSuper(isolate, receiver, home_object, name); | |
| 105 } | |
| 106 | |
| 107 | |
| 62 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, | 108 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, |
| 63 Handle<Object> receiver, Handle<Name> name, | 109 Handle<Object> receiver, Handle<Name> name, |
| 64 Handle<Object> value, StrictMode strict_mode) { | 110 Handle<Object> value, StrictMode strict_mode) { |
| 65 if (home_object->IsAccessCheckNeeded() && | 111 if (home_object->IsAccessCheckNeeded() && |
| 66 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_SET)) { | 112 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_SET)) { |
| 67 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_SET); | 113 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_SET); |
| 68 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 114 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 69 } | 115 } |
| 70 | 116 |
| 71 PrototypeIterator iter(isolate, home_object); | 117 PrototypeIterator iter(isolate, home_object); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 100 DCHECK(args.length() == 4); | 146 DCHECK(args.length() == 4); |
| 101 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 147 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
| 102 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 148 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
| 103 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 149 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 104 CONVERT_ARG_HANDLE_CHECKED(Name, name, 3); | 150 CONVERT_ARG_HANDLE_CHECKED(Name, name, 3); |
| 105 | 151 |
| 106 return StoreToSuper(isolate, home_object, receiver, name, value, SLOPPY); | 152 return StoreToSuper(isolate, home_object, receiver, name, value, SLOPPY); |
| 107 } | 153 } |
| 108 } | 154 } |
| 109 } // namespace v8::internal | 155 } // namespace v8::internal |
| OLD | NEW |