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.h" | 9 #include "src/ast.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 elements, is_strong); | 231 elements, is_strong); |
232 default: | 232 default: |
233 UNREACHABLE(); | 233 UNREACHABLE(); |
234 return MaybeHandle<Object>(); | 234 return MaybeHandle<Object>(); |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 | 238 |
239 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { | 239 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { |
240 HandleScope scope(isolate); | 240 HandleScope scope(isolate); |
241 DCHECK(args.length() == 4); | 241 DCHECK_EQ(4, args.length()); |
242 CONVERT_ARG_HANDLE_CHECKED(LiteralsArray, literals, 0); | 242 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); |
243 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 243 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
244 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | 244 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); |
245 CONVERT_SMI_ARG_CHECKED(flags, 3); | 245 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 246 Handle<LiteralsArray> literals(closure->literals(), isolate); |
246 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 247 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
247 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 248 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
248 bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0; | 249 bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0; |
249 bool is_strong = (flags & ObjectLiteral::kIsStrong) != 0; | 250 bool is_strong = (flags & ObjectLiteral::kIsStrong) != 0; |
250 | 251 |
251 RUNTIME_ASSERT(literals_index >= 0 && | 252 RUNTIME_ASSERT(literals_index >= 0 && |
252 literals_index < literals->literals_count()); | 253 literals_index < literals->literals_count()); |
253 | 254 |
254 // Check if boilerplate exists. If not, create it first. | 255 // Check if boilerplate exists. If not, create it first. |
255 Handle<Object> literal_site(literals->literal(literals_index), isolate); | 256 Handle<Object> literal_site(literals->literal(literals_index), isolate); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 : JSObject::kObjectIsShallow; | 345 : JSObject::kObjectIsShallow; |
345 MaybeHandle<JSObject> copy = | 346 MaybeHandle<JSObject> copy = |
346 JSObject::DeepCopy(boilerplate, &usage_context, hints); | 347 JSObject::DeepCopy(boilerplate, &usage_context, hints); |
347 usage_context.ExitScope(site, boilerplate); | 348 usage_context.ExitScope(site, boilerplate); |
348 return copy; | 349 return copy; |
349 } | 350 } |
350 | 351 |
351 | 352 |
352 RUNTIME_FUNCTION(Runtime_CreateArrayLiteral) { | 353 RUNTIME_FUNCTION(Runtime_CreateArrayLiteral) { |
353 HandleScope scope(isolate); | 354 HandleScope scope(isolate); |
354 DCHECK(args.length() == 4); | 355 DCHECK_EQ(4, args.length()); |
355 CONVERT_ARG_HANDLE_CHECKED(LiteralsArray, literals, 0); | 356 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); |
356 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 357 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
357 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 358 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
358 CONVERT_SMI_ARG_CHECKED(flags, 3); | 359 CONVERT_SMI_ARG_CHECKED(flags, 3); |
359 | 360 |
360 Handle<JSObject> result; | 361 Handle<JSObject> result; |
| 362 Handle<LiteralsArray> literals(closure->literals(), isolate); |
361 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 363 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
362 isolate, result, CreateArrayLiteralImpl(isolate, literals, literals_index, | 364 isolate, result, CreateArrayLiteralImpl(isolate, literals, literals_index, |
363 elements, flags)); | 365 elements, flags)); |
364 return *result; | 366 return *result; |
365 } | 367 } |
366 | 368 |
367 | 369 |
368 RUNTIME_FUNCTION(Runtime_CreateArrayLiteralStubBailout) { | 370 RUNTIME_FUNCTION(Runtime_CreateArrayLiteralStubBailout) { |
369 HandleScope scope(isolate); | 371 HandleScope scope(isolate); |
370 DCHECK(args.length() == 3); | 372 DCHECK_EQ(3, args.length()); |
371 CONVERT_ARG_HANDLE_CHECKED(LiteralsArray, literals, 0); | 373 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); |
372 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 374 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
373 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 375 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
374 | 376 |
375 Handle<JSObject> result; | 377 Handle<JSObject> result; |
| 378 Handle<LiteralsArray> literals(closure->literals(), isolate); |
376 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 379 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
377 isolate, result, | 380 isolate, result, |
378 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, | 381 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
379 ArrayLiteral::kShallowElements)); | 382 ArrayLiteral::kShallowElements)); |
380 return *result; | 383 return *result; |
381 } | 384 } |
382 | 385 |
383 | 386 |
384 RUNTIME_FUNCTION(Runtime_StoreArrayLiteralElement) { | 387 RUNTIME_FUNCTION(Runtime_StoreArrayLiteralElement) { |
385 HandleScope scope(isolate); | 388 HandleScope scope(isolate); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); | 432 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); |
430 } | 433 } |
431 } | 434 } |
432 FixedArray* object_array = FixedArray::cast(object->elements()); | 435 FixedArray* object_array = FixedArray::cast(object->elements()); |
433 object_array->set(store_index, *value); | 436 object_array->set(store_index, *value); |
434 } | 437 } |
435 return *object; | 438 return *object; |
436 } | 439 } |
437 } // namespace internal | 440 } // namespace internal |
438 } // namespace v8 | 441 } // namespace v8 |
OLD | NEW |