| 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.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/ast/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
| 10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 is_var, is_const, is_function); | 142 is_var, is_const, is_function); |
| 143 if (isolate->has_pending_exception()) return result; | 143 if (isolate->has_pending_exception()) return result; |
| 144 }); | 144 }); |
| 145 | 145 |
| 146 return isolate->heap()->undefined_value(); | 146 return isolate->heap()->undefined_value(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 | 149 |
| 150 RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) { | 150 RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) { |
| 151 HandleScope scope(isolate); | 151 HandleScope scope(isolate); |
| 152 // args[0] == name | 152 DCHECK_EQ(3, args.length()); |
| 153 // args[1] == language_mode | |
| 154 // args[2] == value (optional) | |
| 155 | |
| 156 // Determine if we need to assign to the variable if it already | |
| 157 // exists (based on the number of arguments). | |
| 158 RUNTIME_ASSERT(args.length() == 3); | |
| 159 | |
| 160 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 153 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 161 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 1); | 154 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 1); |
| 162 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 155 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 163 | 156 |
| 164 Handle<JSGlobalObject> global(isolate->context()->global_object()); | 157 Handle<JSGlobalObject> global(isolate->context()->global_object()); |
| 165 RETURN_RESULT_OR_FAILURE( | 158 RETURN_RESULT_OR_FAILURE( |
| 166 isolate, Object::SetProperty(global, name, value, language_mode)); | 159 isolate, Object::SetProperty(global, name, value, language_mode)); |
| 167 } | 160 } |
| 168 | 161 |
| 169 | 162 |
| 170 RUNTIME_FUNCTION(Runtime_InitializeConstGlobal) { | 163 RUNTIME_FUNCTION(Runtime_InitializeConstGlobal) { |
| 171 HandleScope handle_scope(isolate); | 164 HandleScope handle_scope(isolate); |
| 172 // All constants are declared with an initial value. The name | 165 DCHECK_EQ(2, args.length()); |
| 173 // of the constant is the first argument and the initial value | |
| 174 // is the second. | |
| 175 RUNTIME_ASSERT(args.length() == 2); | |
| 176 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 166 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 177 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 167 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
| 178 | 168 |
| 179 Handle<JSGlobalObject> global = isolate->global_object(); | 169 Handle<JSGlobalObject> global = isolate->global_object(); |
| 180 | 170 |
| 181 // Lookup the property as own on the global object. | 171 // Lookup the property as own on the global object. |
| 182 LookupIterator it(global, name, global, LookupIterator::OWN_SKIP_INTERCEPTOR); | 172 LookupIterator it(global, name, global, LookupIterator::OWN_SKIP_INTERCEPTOR); |
| 183 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 173 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
| 184 DCHECK(maybe.IsJust()); | 174 DCHECK(maybe.IsJust()); |
| 185 PropertyAttributes old_attributes = maybe.FromJust(); | 175 PropertyAttributes old_attributes = maybe.FromJust(); |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { | 1011 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { |
| 1022 HandleScope scope(isolate); | 1012 HandleScope scope(isolate); |
| 1023 DCHECK_EQ(2, args.length()); | 1013 DCHECK_EQ(2, args.length()); |
| 1024 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 1014 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 1025 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 1015 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
| 1026 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); | 1016 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); |
| 1027 } | 1017 } |
| 1028 | 1018 |
| 1029 } // namespace internal | 1019 } // namespace internal |
| 1030 } // namespace v8 | 1020 } // namespace v8 |
| OLD | NEW |