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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 130 } |
131 | 131 |
132 Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations, | 132 Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations, |
133 int flags, Handle<TypeFeedbackVector> feedback_vector) { | 133 int flags, Handle<TypeFeedbackVector> feedback_vector) { |
134 HandleScope scope(isolate); | 134 HandleScope scope(isolate); |
135 Handle<JSGlobalObject> global(isolate->global_object()); | 135 Handle<JSGlobalObject> global(isolate->global_object()); |
136 Handle<Context> context(isolate->context()); | 136 Handle<Context> context(isolate->context()); |
137 | 137 |
138 // Traverse the name/value pairs and set the properties. | 138 // Traverse the name/value pairs and set the properties. |
139 int length = declarations->length(); | 139 int length = declarations->length(); |
140 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < length, i += 3, { | 140 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < length, i += 4, { |
141 Handle<String> name(String::cast(declarations->get(i)), isolate); | 141 Handle<String> name(String::cast(declarations->get(i)), isolate); |
142 FeedbackVectorSlot slot(Smi::cast(declarations->get(i + 1))->value()); | 142 FeedbackVectorSlot slot(Smi::cast(declarations->get(i + 1))->value()); |
143 Handle<Object> initial_value(declarations->get(i + 2), isolate); | 143 Handle<Object> possibly_literal_slot(declarations->get(i + 2), isolate); |
| 144 Handle<Object> initial_value(declarations->get(i + 3), isolate); |
144 | 145 |
145 bool is_var = initial_value->IsUndefined(isolate); | 146 bool is_var = initial_value->IsUndefined(isolate); |
146 bool is_function = initial_value->IsSharedFunctionInfo(); | 147 bool is_function = initial_value->IsSharedFunctionInfo(); |
147 DCHECK_EQ(1, BoolToInt(is_var) + BoolToInt(is_function)); | 148 DCHECK_EQ(1, BoolToInt(is_var) + BoolToInt(is_function)); |
148 | 149 |
149 Handle<Object> value; | 150 Handle<Object> value; |
150 if (is_function) { | 151 if (is_function) { |
| 152 DCHECK(possibly_literal_slot->IsSmi()); |
151 // Copy the function and update its context. Use it as value. | 153 // Copy the function and update its context. Use it as value. |
152 Handle<SharedFunctionInfo> shared = | 154 Handle<SharedFunctionInfo> shared = |
153 Handle<SharedFunctionInfo>::cast(initial_value); | 155 Handle<SharedFunctionInfo>::cast(initial_value); |
| 156 FeedbackVectorSlot literals_slot( |
| 157 Smi::cast(*possibly_literal_slot)->value()); |
| 158 Handle<LiteralsArray> literals( |
| 159 LiteralsArray::cast(feedback_vector->Get(literals_slot)), isolate); |
154 Handle<JSFunction> function = | 160 Handle<JSFunction> function = |
155 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, | 161 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
156 TENURED); | 162 shared, context, literals, TENURED); |
157 value = function; | 163 value = function; |
158 } else { | 164 } else { |
159 value = isolate->factory()->undefined_value(); | 165 value = isolate->factory()->undefined_value(); |
160 } | 166 } |
161 | 167 |
162 // Compute the property attributes. According to ECMA-262, | 168 // Compute the property attributes. According to ECMA-262, |
163 // the property must be non-configurable except in eval. | 169 // the property must be non-configurable except in eval. |
164 bool is_native = DeclareGlobalsNativeFlag::decode(flags); | 170 bool is_native = DeclareGlobalsNativeFlag::decode(flags); |
165 bool is_eval = DeclareGlobalsEvalFlag::decode(flags); | 171 bool is_eval = DeclareGlobalsEvalFlag::decode(flags); |
166 int attr = NONE; | 172 int attr = NONE; |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { | 995 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { |
990 HandleScope scope(isolate); | 996 HandleScope scope(isolate); |
991 DCHECK_EQ(2, args.length()); | 997 DCHECK_EQ(2, args.length()); |
992 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 998 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
993 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 999 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
994 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); | 1000 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); |
995 } | 1001 } |
996 | 1002 |
997 } // namespace internal | 1003 } // namespace internal |
998 } // namespace v8 | 1004 } // namespace v8 |
OLD | NEW |