| 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/runtime/runtime-utils.h" | 10 #include "src/runtime/runtime-utils.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 HandleScope scope(isolate); | 99 HandleScope scope(isolate); |
| 100 Handle<String> name(String::cast(pairs->get(i))); | 100 Handle<String> name(String::cast(pairs->get(i))); |
| 101 Handle<Object> initial_value(pairs->get(i + 1), isolate); | 101 Handle<Object> initial_value(pairs->get(i + 1), isolate); |
| 102 | 102 |
| 103 // We have to declare a global const property. To capture we only | 103 // We have to declare a global const property. To capture we only |
| 104 // assign to it when evaluating the assignment for "const x = | 104 // assign to it when evaluating the assignment for "const x = |
| 105 // <expr>" the initial value is the hole. | 105 // <expr>" the initial value is the hole. |
| 106 bool is_var = initial_value->IsUndefined(); | 106 bool is_var = initial_value->IsUndefined(); |
| 107 bool is_const = initial_value->IsTheHole(); | 107 bool is_const = initial_value->IsTheHole(); |
| 108 bool is_function = initial_value->IsSharedFunctionInfo(); | 108 bool is_function = initial_value->IsSharedFunctionInfo(); |
| 109 DCHECK(is_var + is_const + is_function == 1); | 109 DCHECK_EQ(1, |
| 110 BoolToInt(is_var) + BoolToInt(is_const) + BoolToInt(is_function)); |
| 110 | 111 |
| 111 Handle<Object> value; | 112 Handle<Object> value; |
| 112 if (is_function) { | 113 if (is_function) { |
| 113 // Copy the function and update its context. Use it as value. | 114 // Copy the function and update its context. Use it as value. |
| 114 Handle<SharedFunctionInfo> shared = | 115 Handle<SharedFunctionInfo> shared = |
| 115 Handle<SharedFunctionInfo>::cast(initial_value); | 116 Handle<SharedFunctionInfo>::cast(initial_value); |
| 116 Handle<JSFunction> function = | 117 Handle<JSFunction> function = |
| 117 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, | 118 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, |
| 118 TENURED); | 119 TENURED); |
| 119 value = function; | 120 value = function; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 214 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
| 214 CONVERT_SMI_ARG_CHECKED(attr_arg, 2); | 215 CONVERT_SMI_ARG_CHECKED(attr_arg, 2); |
| 215 PropertyAttributes attr = static_cast<PropertyAttributes>(attr_arg); | 216 PropertyAttributes attr = static_cast<PropertyAttributes>(attr_arg); |
| 216 RUNTIME_ASSERT(attr == READ_ONLY || attr == NONE); | 217 RUNTIME_ASSERT(attr == READ_ONLY || attr == NONE); |
| 217 CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 3); | 218 CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 3); |
| 218 | 219 |
| 219 // TODO(verwaest): Unify the encoding indicating "var" with DeclareGlobals. | 220 // TODO(verwaest): Unify the encoding indicating "var" with DeclareGlobals. |
| 220 bool is_var = *initial_value == NULL; | 221 bool is_var = *initial_value == NULL; |
| 221 bool is_const = initial_value->IsTheHole(); | 222 bool is_const = initial_value->IsTheHole(); |
| 222 bool is_function = initial_value->IsJSFunction(); | 223 bool is_function = initial_value->IsJSFunction(); |
| 223 DCHECK(is_var + is_const + is_function == 1); | 224 DCHECK_EQ(1, |
| 225 BoolToInt(is_var) + BoolToInt(is_const) + BoolToInt(is_function)); |
| 224 | 226 |
| 225 int index; | 227 int index; |
| 226 PropertyAttributes attributes; | 228 PropertyAttributes attributes; |
| 227 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; | 229 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; |
| 228 BindingFlags binding_flags; | 230 BindingFlags binding_flags; |
| 229 Handle<Object> holder = | 231 Handle<Object> holder = |
| 230 context->Lookup(name, flags, &index, &attributes, &binding_flags); | 232 context->Lookup(name, flags, &index, &attributes, &binding_flags); |
| 231 | 233 |
| 232 Handle<JSObject> object; | 234 Handle<JSObject> object; |
| 233 Handle<Object> value = | 235 Handle<Object> value = |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 return Smi::FromInt(frame->GetArgumentsLength()); | 1081 return Smi::FromInt(frame->GetArgumentsLength()); |
| 1080 } | 1082 } |
| 1081 | 1083 |
| 1082 | 1084 |
| 1083 RUNTIME_FUNCTION(RuntimeReference_Arguments) { | 1085 RUNTIME_FUNCTION(RuntimeReference_Arguments) { |
| 1084 SealHandleScope shs(isolate); | 1086 SealHandleScope shs(isolate); |
| 1085 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); | 1087 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); |
| 1086 } | 1088 } |
| 1087 } | 1089 } |
| 1088 } // namespace v8::internal | 1090 } // namespace v8::internal |
| OLD | NEW |