OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "src/liveedit.h" | 34 #include "src/liveedit.h" |
35 #include "src/misc-intrinsics.h" | 35 #include "src/misc-intrinsics.h" |
36 #include "src/parser.h" | 36 #include "src/parser.h" |
37 #include "src/prototype.h" | 37 #include "src/prototype.h" |
38 #include "src/runtime.h" | 38 #include "src/runtime.h" |
39 #include "src/runtime-profiler.h" | 39 #include "src/runtime-profiler.h" |
40 #include "src/scopeinfo.h" | 40 #include "src/scopeinfo.h" |
41 #include "src/smart-pointers.h" | 41 #include "src/smart-pointers.h" |
42 #include "src/string-search.h" | 42 #include "src/string-search.h" |
43 #include "src/stub-cache.h" | 43 #include "src/stub-cache.h" |
| 44 #include "src/unscopables.h" |
44 #include "src/uri.h" | 45 #include "src/uri.h" |
45 #include "src/v8threads.h" | 46 #include "src/v8threads.h" |
46 #include "src/vm-state-inl.h" | 47 #include "src/vm-state-inl.h" |
47 | 48 |
48 #ifdef V8_I18N_SUPPORT | 49 #ifdef V8_I18N_SUPPORT |
49 #include "src/i18n.h" | 50 #include "src/i18n.h" |
50 #include "unicode/brkiter.h" | 51 #include "unicode/brkiter.h" |
51 #include "unicode/calendar.h" | 52 #include "unicode/calendar.h" |
52 #include "unicode/coll.h" | 53 #include "unicode/coll.h" |
53 #include "unicode/curramt.h" | 54 #include "unicode/curramt.h" |
(...skipping 9078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9132 // explicitly via a with-statement. | 9133 // explicitly via a with-statement. |
9133 Object* constructor = holder->map()->constructor(); | 9134 Object* constructor = holder->map()->constructor(); |
9134 if (constructor != context_extension_function) return holder; | 9135 if (constructor != context_extension_function) return holder; |
9135 // Fall back to using the global object as the implicit receiver if | 9136 // Fall back to using the global object as the implicit receiver if |
9136 // the property turns out to be a local variable allocated in a | 9137 // the property turns out to be a local variable allocated in a |
9137 // context extension object - introduced via eval. | 9138 // context extension object - introduced via eval. |
9138 return isolate->heap()->undefined_value(); | 9139 return isolate->heap()->undefined_value(); |
9139 } | 9140 } |
9140 | 9141 |
9141 | 9142 |
| 9143 static ObjectPair LoadWithContextSlot(Isolate* isolate, Handle<String> name, |
| 9144 Handle<JSReceiver> object, |
| 9145 Handle<Object> receiver_handle) { |
| 9146 LookupIterator it(object, name); |
| 9147 Maybe<PropertyAttributes> maybe_attrs = UnscopableLookup(&it); |
| 9148 if (!maybe_attrs.has_value) { |
| 9149 return MakePair(isolate->heap()->exception(), NULL); |
| 9150 } |
| 9151 |
| 9152 if (maybe_attrs.value != ABSENT) { |
| 9153 Handle<Object> value; |
| 9154 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 9155 isolate, value, Object::GetProperty(&it), |
| 9156 MakePair(isolate->heap()->exception(), NULL)); |
| 9157 |
| 9158 return MakePair(*value, *receiver_handle); |
| 9159 } |
| 9160 |
| 9161 return MakePair(isolate->heap()->undefined_value(), |
| 9162 isolate->heap()->undefined_value()); |
| 9163 } |
| 9164 |
| 9165 |
9142 static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate, | 9166 static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate, |
9143 bool throw_error) { | 9167 bool throw_error) { |
9144 HandleScope scope(isolate); | 9168 HandleScope scope(isolate); |
9145 ASSERT_EQ(2, args.length()); | 9169 ASSERT_EQ(2, args.length()); |
9146 | 9170 |
9147 if (!args[0]->IsContext() || !args[1]->IsString()) { | 9171 if (!args[0]->IsContext() || !args[1]->IsString()) { |
9148 return MakePair(isolate->ThrowIllegalOperation(), NULL); | 9172 return MakePair(isolate->ThrowIllegalOperation(), NULL); |
9149 } | 9173 } |
9150 Handle<Context> context = args.at<Context>(0); | 9174 Handle<Context> context = args.at<Context>(0); |
9151 Handle<String> name = args.at<String>(1); | 9175 Handle<String> name = args.at<String>(1); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9211 } | 9235 } |
9212 #endif | 9236 #endif |
9213 // GetProperty below can cause GC. | 9237 // GetProperty below can cause GC. |
9214 Handle<Object> receiver_handle( | 9238 Handle<Object> receiver_handle( |
9215 object->IsGlobalObject() | 9239 object->IsGlobalObject() |
9216 ? Object::cast(isolate->heap()->undefined_value()) | 9240 ? Object::cast(isolate->heap()->undefined_value()) |
9217 : object->IsJSProxy() ? static_cast<Object*>(*object) | 9241 : object->IsJSProxy() ? static_cast<Object*>(*object) |
9218 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), | 9242 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), |
9219 isolate); | 9243 isolate); |
9220 | 9244 |
| 9245 if (FLAG_harmony_unscopables && context->IsWithContext()) { |
| 9246 return LoadWithContextSlot(isolate, name, object, receiver_handle); |
| 9247 } |
| 9248 |
9221 // No need to unhole the value here. This is taken care of by the | 9249 // No need to unhole the value here. This is taken care of by the |
9222 // GetProperty function. | 9250 // GetProperty function. |
9223 Handle<Object> value; | 9251 Handle<Object> value; |
9224 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 9252 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
9225 isolate, value, | 9253 isolate, value, |
9226 Object::GetProperty(object, name), | 9254 Object::GetProperty(object, name), |
9227 MakePair(isolate->heap()->exception(), NULL)); | 9255 MakePair(isolate->heap()->exception(), NULL)); |
9228 return MakePair(*value, *receiver_handle); | 9256 return MakePair(*value, *receiver_handle); |
9229 } | 9257 } |
9230 | 9258 |
(...skipping 5787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15018 } | 15046 } |
15019 return NULL; | 15047 return NULL; |
15020 } | 15048 } |
15021 | 15049 |
15022 | 15050 |
15023 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15051 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15024 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15052 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15025 } | 15053 } |
15026 | 15054 |
15027 } } // namespace v8::internal | 15055 } } // namespace v8::internal |
OLD | NEW |