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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 bool is_function = initial_value->IsJSFunction(); | 223 bool is_function = initial_value->IsJSFunction(); |
224 DCHECK_EQ(1, | 224 DCHECK_EQ(1, |
225 BoolToInt(is_var) + BoolToInt(is_const) + BoolToInt(is_function)); | 225 BoolToInt(is_var) + BoolToInt(is_const) + BoolToInt(is_function)); |
226 | 226 |
227 int index; | 227 int index; |
228 PropertyAttributes attributes; | 228 PropertyAttributes attributes; |
229 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; | 229 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; |
230 BindingFlags binding_flags; | 230 BindingFlags binding_flags; |
231 Handle<Object> holder = | 231 Handle<Object> holder = |
232 context->Lookup(name, flags, &index, &attributes, &binding_flags); | 232 context->Lookup(name, flags, &index, &attributes, &binding_flags); |
233 // In case of JSProxy, an exception might have been thrown. | |
234 if (isolate->has_pending_exception()) return isolate->heap()->exception(); | |
Yang
2015/07/08 07:55:18
This looks hacky. I.e. we should have returned a M
| |
233 | 235 |
234 Handle<JSObject> object; | 236 Handle<JSObject> object; |
235 Handle<Object> value = | 237 Handle<Object> value = |
236 is_function ? initial_value | 238 is_function ? initial_value |
237 : Handle<Object>::cast(isolate->factory()->undefined_value()); | 239 : Handle<Object>::cast(isolate->factory()->undefined_value()); |
238 | 240 |
239 // TODO(verwaest): This case should probably not be covered by this function, | 241 // TODO(verwaest): This case should probably not be covered by this function, |
240 // but by DeclareGlobals instead. | 242 // but by DeclareGlobals instead. |
241 if (attributes != ABSENT && holder->IsJSGlobalObject()) { | 243 if (attributes != ABSENT && holder->IsJSGlobalObject()) { |
242 return DeclareGlobals(isolate, Handle<JSGlobalObject>::cast(holder), name, | 244 return DeclareGlobals(isolate, Handle<JSGlobalObject>::cast(holder), name, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1); | 303 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1); |
302 Handle<Context> context(context_arg->declaration_context()); | 304 Handle<Context> context(context_arg->declaration_context()); |
303 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); | 305 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); |
304 | 306 |
305 int index; | 307 int index; |
306 PropertyAttributes attributes; | 308 PropertyAttributes attributes; |
307 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; | 309 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; |
308 BindingFlags binding_flags; | 310 BindingFlags binding_flags; |
309 Handle<Object> holder = | 311 Handle<Object> holder = |
310 context->Lookup(name, flags, &index, &attributes, &binding_flags); | 312 context->Lookup(name, flags, &index, &attributes, &binding_flags); |
313 // In case of JSProxy, an exception might have been thrown. | |
314 if (isolate->has_pending_exception()) return isolate->heap()->exception(); | |
311 | 315 |
312 if (index >= 0) { | 316 if (index >= 0) { |
313 DCHECK(holder->IsContext()); | 317 DCHECK(holder->IsContext()); |
314 // Property was found in a context. Perform the assignment if the constant | 318 // Property was found in a context. Perform the assignment if the constant |
315 // was uninitialized. | 319 // was uninitialized. |
316 Handle<Context> context = Handle<Context>::cast(holder); | 320 Handle<Context> context = Handle<Context>::cast(holder); |
317 DCHECK((attributes & READ_ONLY) != 0); | 321 DCHECK((attributes & READ_ONLY) != 0); |
318 if (context->get(index)->IsTheHole()) context->set(index, *value); | 322 if (context->get(index)->IsTheHole()) context->set(index, *value); |
319 return *value; | 323 return *value; |
320 } | 324 } |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 | 852 |
849 int index; | 853 int index; |
850 PropertyAttributes attributes; | 854 PropertyAttributes attributes; |
851 ContextLookupFlags flags = FOLLOW_CHAINS; | 855 ContextLookupFlags flags = FOLLOW_CHAINS; |
852 BindingFlags binding_flags; | 856 BindingFlags binding_flags; |
853 Handle<Object> holder = | 857 Handle<Object> holder = |
854 context->Lookup(name, flags, &index, &attributes, &binding_flags); | 858 context->Lookup(name, flags, &index, &attributes, &binding_flags); |
855 | 859 |
856 // If the slot was not found the result is true. | 860 // If the slot was not found the result is true. |
857 if (holder.is_null()) { | 861 if (holder.is_null()) { |
862 // In case of JSProxy, an exception might have been thrown. | |
863 if (isolate->has_pending_exception()) return isolate->heap()->exception(); | |
858 return isolate->heap()->true_value(); | 864 return isolate->heap()->true_value(); |
859 } | 865 } |
860 | 866 |
861 // If the slot was found in a context, it should be DONT_DELETE. | 867 // If the slot was found in a context, it should be DONT_DELETE. |
862 if (holder->IsContext()) { | 868 if (holder->IsContext()) { |
863 return isolate->heap()->false_value(); | 869 return isolate->heap()->false_value(); |
864 } | 870 } |
865 | 871 |
866 // The slot was found in a JSObject, either a context extension object, | 872 // The slot was found in a JSObject, either a context extension object, |
867 // the global object, or the subject of a with. Try to delete it | 873 // the global object, or the subject of a with. Try to delete it |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 return Smi::FromInt(frame->GetArgumentsLength()); | 1138 return Smi::FromInt(frame->GetArgumentsLength()); |
1133 } | 1139 } |
1134 | 1140 |
1135 | 1141 |
1136 RUNTIME_FUNCTION(Runtime_Arguments) { | 1142 RUNTIME_FUNCTION(Runtime_Arguments) { |
1137 SealHandleScope shs(isolate); | 1143 SealHandleScope shs(isolate); |
1138 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); | 1144 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); |
1139 } | 1145 } |
1140 } // namespace internal | 1146 } // namespace internal |
1141 } // namespace v8 | 1147 } // namespace v8 |
OLD | NEW |