OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 // Update the functions literal and return the boilerplate. | 499 // Update the functions literal and return the boilerplate. |
500 literals->set(literals_index, *boilerplate); | 500 literals->set(literals_index, *boilerplate); |
501 } | 501 } |
502 | 502 |
503 Handle<Object> copy = JSObject::DeepCopy(Handle<JSObject>::cast(boilerplate)); | 503 Handle<Object> copy = JSObject::DeepCopy(Handle<JSObject>::cast(boilerplate)); |
504 RETURN_IF_EMPTY_HANDLE(isolate, copy); | 504 RETURN_IF_EMPTY_HANDLE(isolate, copy); |
505 return *copy; | 505 return *copy; |
506 } | 506 } |
507 | 507 |
508 | 508 |
509 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) { | |
510 HandleScope scope(isolate); | |
511 ASSERT(args.length() == 4); | |
512 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | |
513 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | |
514 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | |
515 CONVERT_SMI_ARG_CHECKED(flags, 3); | |
516 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | |
517 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | |
518 | |
519 // Check if boilerplate exists. If not, create it first. | |
520 Handle<Object> boilerplate(literals->get(literals_index), isolate); | |
521 if (*boilerplate == isolate->heap()->undefined_value()) { | |
522 boilerplate = CreateObjectLiteralBoilerplate(isolate, | |
523 literals, | |
524 constant_properties, | |
525 should_have_fast_elements, | |
526 has_function_literal); | |
527 RETURN_IF_EMPTY_HANDLE(isolate, boilerplate); | |
528 // Update the functions literal and return the boilerplate. | |
529 literals->set(literals_index, *boilerplate); | |
530 } | |
531 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); | |
532 } | |
533 | |
534 | |
535 static Handle<AllocationSite> GetLiteralAllocationSite( | 509 static Handle<AllocationSite> GetLiteralAllocationSite( |
536 Isolate* isolate, | 510 Isolate* isolate, |
537 Handle<FixedArray> literals, | 511 Handle<FixedArray> literals, |
538 int literals_index, | 512 int literals_index, |
539 Handle<FixedArray> elements) { | 513 Handle<FixedArray> elements) { |
540 // Check if boilerplate exists. If not, create it first. | 514 // Check if boilerplate exists. If not, create it first. |
541 Handle<Object> literal_site(literals->get(literals_index), isolate); | 515 Handle<Object> literal_site(literals->get(literals_index), isolate); |
542 Handle<AllocationSite> site; | 516 Handle<AllocationSite> site; |
543 if (*literal_site == isolate->heap()->undefined_value()) { | 517 if (*literal_site == isolate->heap()->undefined_value()) { |
544 ASSERT(*elements != isolate->heap()->empty_fixed_array()); | 518 ASSERT(*elements != isolate->heap()->empty_fixed_array()); |
(...skipping 14275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14820 // Handle last resort GC and make sure to allow future allocations | 14794 // Handle last resort GC and make sure to allow future allocations |
14821 // to grow the heap without causing GCs (if possible). | 14795 // to grow the heap without causing GCs (if possible). |
14822 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14796 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14823 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14797 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14824 "Runtime::PerformGC"); | 14798 "Runtime::PerformGC"); |
14825 } | 14799 } |
14826 } | 14800 } |
14827 | 14801 |
14828 | 14802 |
14829 } } // namespace v8::internal | 14803 } } // namespace v8::internal |
OLD | NEW |