| 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/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) { | 202 RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) { |
| 203 HandleScope scope(isolate); | 203 HandleScope scope(isolate); |
| 204 DCHECK_EQ(4, args.length()); | 204 DCHECK_EQ(4, args.length()); |
| 205 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); | 205 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); |
| 206 CONVERT_SMI_ARG_CHECKED(index, 1); | 206 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 207 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); | 207 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); |
| 208 CONVERT_SMI_ARG_CHECKED(flags, 3); | 208 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 209 | 209 |
| 210 // Check if boilerplate exists. If not, create it first. | 210 // Check if boilerplate exists. If not, create it first. |
| 211 Handle<Object> boilerplate(closure->literals()->literal(index), isolate); | 211 Handle<Object> boilerplate(closure->literals()->literal(index), isolate); |
| 212 if (boilerplate->IsUndefined()) { | 212 if (boilerplate->IsUndefined(isolate)) { |
| 213 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 213 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 214 isolate, boilerplate, JSRegExp::New(pattern, JSRegExp::Flags(flags))); | 214 isolate, boilerplate, JSRegExp::New(pattern, JSRegExp::Flags(flags))); |
| 215 closure->literals()->set_literal(index, *boilerplate); | 215 closure->literals()->set_literal(index, *boilerplate); |
| 216 } | 216 } |
| 217 return *JSRegExp::Copy(Handle<JSRegExp>::cast(boilerplate)); | 217 return *JSRegExp::Copy(Handle<JSRegExp>::cast(boilerplate)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { | 221 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { |
| 222 HandleScope scope(isolate); | 222 HandleScope scope(isolate); |
| 223 DCHECK_EQ(4, args.length()); | 223 DCHECK_EQ(4, args.length()); |
| 224 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); | 224 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); |
| 225 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 225 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 226 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | 226 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); |
| 227 CONVERT_SMI_ARG_CHECKED(flags, 3); | 227 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 228 Handle<LiteralsArray> literals(closure->literals(), isolate); | 228 Handle<LiteralsArray> literals(closure->literals(), isolate); |
| 229 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 229 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
| 230 bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0; | 230 bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0; |
| 231 | 231 |
| 232 RUNTIME_ASSERT(literals_index >= 0 && | 232 RUNTIME_ASSERT(literals_index >= 0 && |
| 233 literals_index < literals->literals_count()); | 233 literals_index < literals->literals_count()); |
| 234 | 234 |
| 235 // Check if boilerplate exists. If not, create it first. | 235 // Check if boilerplate exists. If not, create it first. |
| 236 Handle<Object> literal_site(literals->literal(literals_index), isolate); | 236 Handle<Object> literal_site(literals->literal(literals_index), isolate); |
| 237 Handle<AllocationSite> site; | 237 Handle<AllocationSite> site; |
| 238 Handle<JSObject> boilerplate; | 238 Handle<JSObject> boilerplate; |
| 239 if (*literal_site == isolate->heap()->undefined_value()) { | 239 if (literal_site->IsUndefined(isolate)) { |
| 240 Handle<Object> raw_boilerplate; | 240 Handle<Object> raw_boilerplate; |
| 241 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 241 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 242 isolate, raw_boilerplate, | 242 isolate, raw_boilerplate, |
| 243 CreateObjectLiteralBoilerplate(isolate, literals, constant_properties, | 243 CreateObjectLiteralBoilerplate(isolate, literals, constant_properties, |
| 244 should_have_fast_elements)); | 244 should_have_fast_elements)); |
| 245 boilerplate = Handle<JSObject>::cast(raw_boilerplate); | 245 boilerplate = Handle<JSObject>::cast(raw_boilerplate); |
| 246 | 246 |
| 247 AllocationSiteCreationContext creation_context(isolate); | 247 AllocationSiteCreationContext creation_context(isolate); |
| 248 site = creation_context.EnterNewScope(); | 248 site = creation_context.EnterNewScope(); |
| 249 RETURN_FAILURE_ON_EXCEPTION( | 249 RETURN_FAILURE_ON_EXCEPTION( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 265 usage_context.ExitScope(site, boilerplate); | 265 usage_context.ExitScope(site, boilerplate); |
| 266 RETURN_RESULT_OR_FAILURE(isolate, maybe_copy); | 266 RETURN_RESULT_OR_FAILURE(isolate, maybe_copy); |
| 267 } | 267 } |
| 268 | 268 |
| 269 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( | 269 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( |
| 270 Isolate* isolate, Handle<LiteralsArray> literals, int literals_index, | 270 Isolate* isolate, Handle<LiteralsArray> literals, int literals_index, |
| 271 Handle<FixedArray> elements) { | 271 Handle<FixedArray> elements) { |
| 272 // Check if boilerplate exists. If not, create it first. | 272 // Check if boilerplate exists. If not, create it first. |
| 273 Handle<Object> literal_site(literals->literal(literals_index), isolate); | 273 Handle<Object> literal_site(literals->literal(literals_index), isolate); |
| 274 Handle<AllocationSite> site; | 274 Handle<AllocationSite> site; |
| 275 if (*literal_site == isolate->heap()->undefined_value()) { | 275 if (literal_site->IsUndefined(isolate)) { |
| 276 DCHECK(*elements != isolate->heap()->empty_fixed_array()); | 276 DCHECK(*elements != isolate->heap()->empty_fixed_array()); |
| 277 Handle<Object> boilerplate; | 277 Handle<Object> boilerplate; |
| 278 ASSIGN_RETURN_ON_EXCEPTION( | 278 ASSIGN_RETURN_ON_EXCEPTION( |
| 279 isolate, boilerplate, | 279 isolate, boilerplate, |
| 280 CreateArrayLiteralBoilerplate(isolate, literals, elements), | 280 CreateArrayLiteralBoilerplate(isolate, literals, elements), |
| 281 AllocationSite); | 281 AllocationSite); |
| 282 | 282 |
| 283 AllocationSiteCreationContext creation_context(isolate); | 283 AllocationSiteCreationContext creation_context(isolate); |
| 284 site = creation_context.EnterNewScope(); | 284 site = creation_context.EnterNewScope(); |
| 285 if (JSObject::DeepWalk(Handle<JSObject>::cast(boilerplate), | 285 if (JSObject::DeepWalk(Handle<JSObject>::cast(boilerplate), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 345 |
| 346 Handle<LiteralsArray> literals(closure->literals(), isolate); | 346 Handle<LiteralsArray> literals(closure->literals(), isolate); |
| 347 RETURN_RESULT_OR_FAILURE( | 347 RETURN_RESULT_OR_FAILURE( |
| 348 isolate, | 348 isolate, |
| 349 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, | 349 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
| 350 ArrayLiteral::kShallowElements)); | 350 ArrayLiteral::kShallowElements)); |
| 351 } | 351 } |
| 352 | 352 |
| 353 } // namespace internal | 353 } // namespace internal |
| 354 } // namespace v8 | 354 } // namespace v8 |
| OLD | NEW |