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 9030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9084 // explicitly via a with-statement. | 9085 // explicitly via a with-statement. |
9085 Object* constructor = holder->map()->constructor(); | 9086 Object* constructor = holder->map()->constructor(); |
9086 if (constructor != context_extension_function) return holder; | 9087 if (constructor != context_extension_function) return holder; |
9087 // Fall back to using the global object as the implicit receiver if | 9088 // Fall back to using the global object as the implicit receiver if |
9088 // the property turns out to be a local variable allocated in a | 9089 // the property turns out to be a local variable allocated in a |
9089 // context extension object - introduced via eval. | 9090 // context extension object - introduced via eval. |
9090 return isolate->heap()->undefined_value(); | 9091 return isolate->heap()->undefined_value(); |
9091 } | 9092 } |
9092 | 9093 |
9093 | 9094 |
| 9095 static ObjectPair LoadWithContextSlot(Isolate* isolate, Handle<String> name, |
| 9096 Handle<JSReceiver> object, |
| 9097 Handle<Object> receiver_handle) { |
| 9098 UnscopableLookup lookup(isolate, name, object); |
| 9099 if (lookup.HasError()) { |
| 9100 return MakePair(isolate->heap()->exception(), NULL); |
| 9101 } |
| 9102 if (lookup.Found()) { |
| 9103 // The property might be a getter that is normally shadowed but due to the |
| 9104 // unscopables we found it further up the prototype chain. Therefore we need |
| 9105 // to ensure that we are using the right receiver and holder when we get the |
| 9106 // value. |
| 9107 Handle<Object> value; |
| 9108 LookupIterator it(object, name, lookup.GetHolder()); |
| 9109 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 9110 isolate, value, Object::GetProperty(&it), |
| 9111 MakePair(isolate->heap()->exception(), NULL)); |
| 9112 return MakePair(*value, *receiver_handle); |
| 9113 } |
| 9114 return MakePair(isolate->heap()->undefined_value(), |
| 9115 isolate->heap()->undefined_value()); |
| 9116 } |
| 9117 |
| 9118 |
9094 static ObjectPair LoadContextSlotHelper(Arguments args, | 9119 static ObjectPair LoadContextSlotHelper(Arguments args, |
9095 Isolate* isolate, | 9120 Isolate* isolate, |
9096 bool throw_error) { | 9121 bool throw_error) { |
9097 HandleScope scope(isolate); | 9122 HandleScope scope(isolate); |
9098 ASSERT_EQ(2, args.length()); | 9123 ASSERT_EQ(2, args.length()); |
9099 | 9124 |
9100 if (!args[0]->IsContext() || !args[1]->IsString()) { | 9125 if (!args[0]->IsContext() || !args[1]->IsString()) { |
9101 return MakePair(isolate->ThrowIllegalOperation(), NULL); | 9126 return MakePair(isolate->ThrowIllegalOperation(), NULL); |
9102 } | 9127 } |
9103 Handle<Context> context = args.at<Context>(0); | 9128 Handle<Context> context = args.at<Context>(0); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9158 Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder); | 9183 Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder); |
9159 ASSERT(object->IsJSProxy() || JSReceiver::HasProperty(object, name)); | 9184 ASSERT(object->IsJSProxy() || JSReceiver::HasProperty(object, name)); |
9160 // GetProperty below can cause GC. | 9185 // GetProperty below can cause GC. |
9161 Handle<Object> receiver_handle( | 9186 Handle<Object> receiver_handle( |
9162 object->IsGlobalObject() | 9187 object->IsGlobalObject() |
9163 ? Object::cast(isolate->heap()->undefined_value()) | 9188 ? Object::cast(isolate->heap()->undefined_value()) |
9164 : object->IsJSProxy() ? static_cast<Object*>(*object) | 9189 : object->IsJSProxy() ? static_cast<Object*>(*object) |
9165 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), | 9190 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), |
9166 isolate); | 9191 isolate); |
9167 | 9192 |
| 9193 if (FLAG_harmony_unscopables && context->IsWithContext()) { |
| 9194 return LoadWithContextSlot(isolate, name, object, receiver_handle); |
| 9195 } |
| 9196 |
9168 // No need to unhole the value here. This is taken care of by the | 9197 // No need to unhole the value here. This is taken care of by the |
9169 // GetProperty function. | 9198 // GetProperty function. |
9170 Handle<Object> value; | 9199 Handle<Object> value; |
9171 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 9200 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
9172 isolate, value, | 9201 isolate, value, |
9173 Object::GetProperty(object, name), | 9202 Object::GetProperty(object, name), |
9174 MakePair(isolate->heap()->exception(), NULL)); | 9203 MakePair(isolate->heap()->exception(), NULL)); |
9175 return MakePair(*value, *receiver_handle); | 9204 return MakePair(*value, *receiver_handle); |
9176 } | 9205 } |
9177 | 9206 |
(...skipping 5778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14956 } | 14985 } |
14957 return NULL; | 14986 return NULL; |
14958 } | 14987 } |
14959 | 14988 |
14960 | 14989 |
14961 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 14990 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
14962 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 14991 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
14963 } | 14992 } |
14964 | 14993 |
14965 } } // namespace v8::internal | 14994 } } // namespace v8::internal |
OLD | NEW |