Chromium Code Reviews| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // and store it in a LanguageMode variable with the given name. | 133 // and store it in a LanguageMode variable with the given name. |
| 134 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \ | 134 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \ |
| 135 ASSERT(args[index]->IsSmi()); \ | 135 ASSERT(args[index]->IsSmi()); \ |
| 136 ASSERT(args.smi_at(index) == CLASSIC_MODE || \ | 136 ASSERT(args.smi_at(index) == CLASSIC_MODE || \ |
| 137 args.smi_at(index) == STRICT_MODE || \ | 137 args.smi_at(index) == STRICT_MODE || \ |
| 138 args.smi_at(index) == EXTENDED_MODE); \ | 138 args.smi_at(index) == EXTENDED_MODE); \ |
| 139 LanguageMode name = \ | 139 LanguageMode name = \ |
| 140 static_cast<LanguageMode>(args.smi_at(index)); | 140 static_cast<LanguageMode>(args.smi_at(index)); |
| 141 | 141 |
| 142 | 142 |
| 143 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate, | 143 |
| 144 JSObject* boilerplate) { | 144 MUST_USE_RESULT MaybeObject* Runtime::DeepCopyBoilerplate( |
| 145 Isolate* isolate, | |
| 146 JSObject* boilerplate, | |
| 147 AllocationSiteMode allocation_site_mode) { | |
| 145 StackLimitCheck check(isolate); | 148 StackLimitCheck check(isolate); |
| 146 if (check.HasOverflowed()) return isolate->StackOverflow(); | 149 if (check.HasOverflowed()) return isolate->StackOverflow(); |
| 147 | 150 |
| 148 Heap* heap = isolate->heap(); | 151 Heap* heap = isolate->heap(); |
| 149 Object* result; | 152 Object* result; |
| 150 { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate); | 153 AllocationSiteMode current_object_mode = DONT_TRACK_ALLOCATION_SITE; |
| 154 if (allocation_site_mode == TRACK_ALLOCATION_SITE && | |
| 155 boilerplate->ShouldTrackAllocationInfo()) { | |
| 156 current_object_mode = TRACK_ALLOCATION_SITE; | |
| 157 } | |
| 158 | |
| 159 { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate, | |
| 160 current_object_mode); | |
| 151 if (!maybe_result->ToObject(&result)) return maybe_result; | 161 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 152 } | 162 } |
| 153 JSObject* copy = JSObject::cast(result); | 163 JSObject* copy = JSObject::cast(result); |
| 154 | 164 |
| 155 // Deep copy local properties. | 165 // Deep copy local properties. |
| 156 if (copy->HasFastProperties()) { | 166 if (copy->HasFastProperties()) { |
| 157 FixedArray* properties = copy->properties(); | 167 FixedArray* properties = copy->properties(); |
| 158 for (int i = 0; i < properties->length(); i++) { | 168 for (int i = 0; i < properties->length(); i++) { |
| 159 Object* value = properties->get(i); | 169 Object* value = properties->get(i); |
| 160 if (value->IsJSObject()) { | 170 if (value->IsJSObject()) { |
| 161 JSObject* js_object = JSObject::cast(value); | 171 JSObject* js_object = JSObject::cast(value); |
| 162 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object); | 172 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object, |
| 173 allocation_site_mode); | |
| 163 if (!maybe_result->ToObject(&result)) return maybe_result; | 174 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 164 } | 175 } |
| 165 properties->set(i, result); | 176 properties->set(i, result); |
| 166 } | 177 } |
| 167 } | 178 } |
| 168 int nof = copy->map()->inobject_properties(); | 179 int nof = copy->map()->inobject_properties(); |
| 169 for (int i = 0; i < nof; i++) { | 180 for (int i = 0; i < nof; i++) { |
| 170 Object* value = copy->InObjectPropertyAt(i); | 181 Object* value = copy->InObjectPropertyAt(i); |
| 171 if (value->IsJSObject()) { | 182 if (value->IsJSObject()) { |
| 172 JSObject* js_object = JSObject::cast(value); | 183 JSObject* js_object = JSObject::cast(value); |
| 173 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object); | 184 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object, |
| 185 allocation_site_mode); | |
| 174 if (!maybe_result->ToObject(&result)) return maybe_result; | 186 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 175 } | 187 } |
| 176 copy->InObjectPropertyAtPut(i, result); | 188 copy->InObjectPropertyAtPut(i, result); |
| 177 } | 189 } |
| 178 } | 190 } |
| 179 } else { | 191 } else { |
| 180 { MaybeObject* maybe_result = | 192 { MaybeObject* maybe_result = |
| 181 heap->AllocateFixedArray(copy->NumberOfLocalProperties()); | 193 heap->AllocateFixedArray(copy->NumberOfLocalProperties()); |
| 182 if (!maybe_result->ToObject(&result)) return maybe_result; | 194 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 183 } | 195 } |
| 184 FixedArray* names = FixedArray::cast(result); | 196 FixedArray* names = FixedArray::cast(result); |
| 185 copy->GetLocalPropertyNames(names, 0); | 197 copy->GetLocalPropertyNames(names, 0); |
| 186 for (int i = 0; i < names->length(); i++) { | 198 for (int i = 0; i < names->length(); i++) { |
| 187 ASSERT(names->get(i)->IsString()); | 199 ASSERT(names->get(i)->IsString()); |
| 188 String* key_string = String::cast(names->get(i)); | 200 String* key_string = String::cast(names->get(i)); |
| 189 PropertyAttributes attributes = | 201 PropertyAttributes attributes = |
| 190 copy->GetLocalPropertyAttribute(key_string); | 202 copy->GetLocalPropertyAttribute(key_string); |
| 191 // Only deep copy fields from the object literal expression. | 203 // Only deep copy fields from the object literal expression. |
| 192 // In particular, don't try to copy the length attribute of | 204 // In particular, don't try to copy the length attribute of |
| 193 // an array. | 205 // an array. |
| 194 if (attributes != NONE) continue; | 206 if (attributes != NONE) continue; |
| 195 Object* value = | 207 Object* value = |
| 196 copy->GetProperty(key_string, &attributes)->ToObjectUnchecked(); | 208 copy->GetProperty(key_string, &attributes)->ToObjectUnchecked(); |
| 197 if (value->IsJSObject()) { | 209 if (value->IsJSObject()) { |
| 198 JSObject* js_object = JSObject::cast(value); | 210 JSObject* js_object = JSObject::cast(value); |
| 199 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object); | 211 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object, |
| 212 allocation_site_mode); | |
| 200 if (!maybe_result->ToObject(&result)) return maybe_result; | 213 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 201 } | 214 } |
| 202 { MaybeObject* maybe_result = | 215 { MaybeObject* maybe_result = |
| 203 // Creating object copy for literals. No strict mode needed. | 216 // Creating object copy for literals. No strict mode needed. |
| 204 copy->SetProperty(key_string, result, NONE, kNonStrictMode); | 217 copy->SetProperty(key_string, result, NONE, kNonStrictMode); |
| 205 if (!maybe_result->ToObject(&result)) return maybe_result; | 218 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 206 } | 219 } |
| 207 } | 220 } |
| 208 } | 221 } |
| 209 } | 222 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 226 #endif | 239 #endif |
| 227 } else { | 240 } else { |
| 228 for (int i = 0; i < elements->length(); i++) { | 241 for (int i = 0; i < elements->length(); i++) { |
| 229 Object* value = elements->get(i); | 242 Object* value = elements->get(i); |
| 230 ASSERT(value->IsSmi() || | 243 ASSERT(value->IsSmi() || |
| 231 value->IsTheHole() || | 244 value->IsTheHole() || |
| 232 (IsFastObjectElementsKind(copy->GetElementsKind()))); | 245 (IsFastObjectElementsKind(copy->GetElementsKind()))); |
| 233 if (value->IsJSObject()) { | 246 if (value->IsJSObject()) { |
| 234 JSObject* js_object = JSObject::cast(value); | 247 JSObject* js_object = JSObject::cast(value); |
| 235 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, | 248 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, |
| 236 js_object); | 249 js_object, |
| 250 allocation_site_mode); | |
| 237 if (!maybe_result->ToObject(&result)) return maybe_result; | 251 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 238 } | 252 } |
| 239 elements->set(i, result); | 253 elements->set(i, result); |
| 240 } | 254 } |
| 241 } | 255 } |
| 242 } | 256 } |
| 243 break; | 257 break; |
| 244 } | 258 } |
| 245 case DICTIONARY_ELEMENTS: { | 259 case DICTIONARY_ELEMENTS: { |
| 246 SeededNumberDictionary* element_dictionary = copy->element_dictionary(); | 260 SeededNumberDictionary* element_dictionary = copy->element_dictionary(); |
| 247 int capacity = element_dictionary->Capacity(); | 261 int capacity = element_dictionary->Capacity(); |
| 248 for (int i = 0; i < capacity; i++) { | 262 for (int i = 0; i < capacity; i++) { |
| 249 Object* k = element_dictionary->KeyAt(i); | 263 Object* k = element_dictionary->KeyAt(i); |
| 250 if (element_dictionary->IsKey(k)) { | 264 if (element_dictionary->IsKey(k)) { |
| 251 Object* value = element_dictionary->ValueAt(i); | 265 Object* value = element_dictionary->ValueAt(i); |
| 252 if (value->IsJSObject()) { | 266 if (value->IsJSObject()) { |
| 253 JSObject* js_object = JSObject::cast(value); | 267 JSObject* js_object = JSObject::cast(value); |
| 254 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, | 268 { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, |
| 255 js_object); | 269 js_object, |
| 270 allocation_site_mode); | |
| 256 if (!maybe_result->ToObject(&result)) return maybe_result; | 271 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 257 } | 272 } |
| 258 element_dictionary->ValueAtPut(i, result); | 273 element_dictionary->ValueAtPut(i, result); |
| 259 } | 274 } |
| 260 } | 275 } |
| 261 } | 276 } |
| 262 break; | 277 break; |
| 263 } | 278 } |
| 264 case NON_STRICT_ARGUMENTS_ELEMENTS: | 279 case NON_STRICT_ARGUMENTS_ELEMENTS: |
| 265 UNIMPLEMENTED(); | 280 UNIMPLEMENTED(); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 579 | 594 |
| 580 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) { | 595 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) { |
| 581 HandleScope scope(isolate); | 596 HandleScope scope(isolate); |
| 582 ASSERT(args.length() == 4); | 597 ASSERT(args.length() == 4); |
| 583 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 598 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 584 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 599 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 585 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | 600 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); |
| 586 CONVERT_SMI_ARG_CHECKED(flags, 3); | 601 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 587 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 602 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
| 588 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 603 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
| 604 bool allocation_sites_allowed = | |
| 605 (flags & ObjectLiteral::kAllocationSiteInfoAllowed) != 0; | |
|
danno
2013/02/11 15:05:21
The flag tells object literal instantiation to cre
mvstanton
2013/02/15 07:36:43
"they are not allowed, they are desired." Beautifu
| |
| 606 | |
|
danno
2013/02/11 15:05:21
Also, perhaps you should fashion the calculation o
mvstanton
2013/02/15 07:36:43
right on, done.
| |
| 607 AllocationSiteMode allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | |
| 608 if (FLAG_track_allocation_sites && allocation_sites_allowed) { | |
| 609 allocation_site_mode = TRACK_ALLOCATION_SITE; | |
| 610 } | |
| 589 | 611 |
| 590 // Check if boilerplate exists. If not, create it first. | 612 // Check if boilerplate exists. If not, create it first. |
| 591 Handle<Object> boilerplate(literals->get(literals_index), isolate); | 613 Handle<Object> boilerplate(literals->get(literals_index), isolate); |
| 592 if (*boilerplate == isolate->heap()->undefined_value()) { | 614 if (*boilerplate == isolate->heap()->undefined_value()) { |
| 593 boilerplate = CreateObjectLiteralBoilerplate(isolate, | 615 boilerplate = CreateObjectLiteralBoilerplate(isolate, |
| 594 literals, | 616 literals, |
| 595 constant_properties, | 617 constant_properties, |
| 596 should_have_fast_elements, | 618 should_have_fast_elements, |
| 597 has_function_literal); | 619 has_function_literal); |
| 598 if (boilerplate.is_null()) return Failure::Exception(); | 620 if (boilerplate.is_null()) return Failure::Exception(); |
| 599 // Update the functions literal and return the boilerplate. | 621 // Update the functions literal and return the boilerplate. |
| 600 literals->set(literals_index, *boilerplate); | 622 literals->set(literals_index, *boilerplate); |
| 601 } | 623 } |
| 602 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate)); | 624 |
| 625 return Runtime::DeepCopyBoilerplate(isolate, | |
| 626 JSObject::cast(*boilerplate), | |
| 627 allocation_site_mode); | |
| 603 } | 628 } |
| 604 | 629 |
| 605 | 630 |
| 606 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) { | 631 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) { |
| 607 HandleScope scope(isolate); | 632 HandleScope scope(isolate); |
| 608 ASSERT(args.length() == 4); | 633 ASSERT(args.length() == 4); |
| 609 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 634 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 610 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 635 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 611 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | 636 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); |
| 612 CONVERT_SMI_ARG_CHECKED(flags, 3); | 637 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 613 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 638 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
| 614 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 639 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
| 640 bool allocation_site_info_allowed = | |
| 641 (flags & ObjectLiteral::kAllocationSiteInfoAllowed) != 0 | |
| 642 && FLAG_track_allocation_sites; | |
| 615 | 643 |
| 616 // Check if boilerplate exists. If not, create it first. | 644 // Check if boilerplate exists. If not, create it first. |
| 617 Handle<Object> boilerplate(literals->get(literals_index), isolate); | 645 Handle<Object> boilerplate(literals->get(literals_index), isolate); |
| 618 if (*boilerplate == isolate->heap()->undefined_value()) { | 646 if (*boilerplate == isolate->heap()->undefined_value()) { |
| 619 boilerplate = CreateObjectLiteralBoilerplate(isolate, | 647 boilerplate = CreateObjectLiteralBoilerplate(isolate, |
| 620 literals, | 648 literals, |
| 621 constant_properties, | 649 constant_properties, |
| 622 should_have_fast_elements, | 650 should_have_fast_elements, |
| 623 has_function_literal); | 651 has_function_literal); |
| 624 if (boilerplate.is_null()) return Failure::Exception(); | 652 if (boilerplate.is_null()) return Failure::Exception(); |
| 625 // Update the functions literal and return the boilerplate. | 653 // Update the functions literal and return the boilerplate. |
| 626 literals->set(literals_index, *boilerplate); | 654 literals->set(literals_index, *boilerplate); |
| 627 } | 655 } |
| 628 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); | 656 |
| 657 AllocationSiteMode mode = allocation_site_info_allowed | |
| 658 ? TRACK_ALLOCATION_SITE | |
| 659 : DONT_TRACK_ALLOCATION_SITE; | |
| 660 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate), | |
| 661 mode); | |
|
danno
2013/02/11 15:05:21
nit: mode fits on previous line.
mvstanton
2013/02/15 07:36:43
Changes based on other recommendations affected th
| |
| 629 } | 662 } |
| 630 | 663 |
| 631 | 664 |
| 632 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { | 665 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { |
| 633 HandleScope scope(isolate); | 666 HandleScope scope(isolate); |
| 634 ASSERT(args.length() == 3); | 667 ASSERT(args.length() == 4); |
| 635 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 668 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 636 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 669 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 637 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 670 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 671 CONVERT_SMI_ARG_CHECKED(flags, 3); | |
| 672 bool allocation_sites_allowed = | |
| 673 (flags & ArrayLiteral::kAllocationSiteInfoAllowed) != 0; | |
| 674 | |
| 675 AllocationSiteMode allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | |
| 676 if (FLAG_track_allocation_sites && allocation_sites_allowed) { | |
| 677 allocation_site_mode = TRACK_ALLOCATION_SITE; | |
| 678 } | |
| 638 | 679 |
| 639 // Check if boilerplate exists. If not, create it first. | 680 // Check if boilerplate exists. If not, create it first. |
| 640 Handle<Object> boilerplate(literals->get(literals_index), isolate); | 681 Handle<Object> boilerplate(literals->get(literals_index), isolate); |
| 641 if (*boilerplate == isolate->heap()->undefined_value()) { | 682 if (*boilerplate == isolate->heap()->undefined_value()) { |
| 642 ASSERT(*elements != isolate->heap()->empty_fixed_array()); | 683 ASSERT(*elements != isolate->heap()->empty_fixed_array()); |
| 643 boilerplate = | 684 boilerplate = |
| 644 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); | 685 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); |
| 645 if (boilerplate.is_null()) return Failure::Exception(); | 686 if (boilerplate.is_null()) return Failure::Exception(); |
| 646 // Update the functions literal and return the boilerplate. | 687 // Update the functions literal and return the boilerplate. |
| 647 literals->set(literals_index, *boilerplate); | 688 literals->set(literals_index, *boilerplate); |
| 648 } | 689 } |
| 649 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate)); | 690 |
| 691 return Runtime::DeepCopyBoilerplate(isolate, | |
| 692 JSObject::cast(*boilerplate), | |
| 693 allocation_site_mode); | |
| 650 } | 694 } |
| 651 | 695 |
| 652 | 696 |
| 653 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { | 697 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { |
| 654 HandleScope scope(isolate); | 698 HandleScope scope(isolate); |
| 655 ASSERT(args.length() == 3); | 699 ASSERT(args.length() == 4); |
| 656 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 700 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 657 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 701 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 658 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 702 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 703 CONVERT_SMI_ARG_CHECKED(flags, 3); | |
| 704 bool allocation_site_info_allowed = FLAG_track_allocation_sites && | |
| 705 ((flags & ArrayLiteral::kAllocationSiteInfoAllowed) != 0); | |
| 659 | 706 |
| 660 // Check if boilerplate exists. If not, create it first. | 707 // Check if boilerplate exists. If not, create it first. |
| 661 Handle<Object> boilerplate(literals->get(literals_index), isolate); | 708 Handle<Object> boilerplate(literals->get(literals_index), isolate); |
| 662 if (*boilerplate == isolate->heap()->undefined_value()) { | 709 if (*boilerplate == isolate->heap()->undefined_value()) { |
| 663 ASSERT(*elements != isolate->heap()->empty_fixed_array()); | 710 ASSERT(*elements != isolate->heap()->empty_fixed_array()); |
| 664 boilerplate = | 711 boilerplate = |
| 665 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); | 712 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); |
| 666 if (boilerplate.is_null()) return Failure::Exception(); | 713 if (boilerplate.is_null()) return Failure::Exception(); |
| 667 // Update the functions literal and return the boilerplate. | 714 // Update the functions literal and return the boilerplate. |
| 668 literals->set(literals_index, *boilerplate); | 715 literals->set(literals_index, *boilerplate); |
| 669 } | 716 } |
| 670 if (JSObject::cast(*boilerplate)->elements()->map() == | 717 if (JSObject::cast(*boilerplate)->elements()->map() == |
| 671 isolate->heap()->fixed_cow_array_map()) { | 718 isolate->heap()->fixed_cow_array_map()) { |
| 672 isolate->counters()->cow_arrays_created_runtime()->Increment(); | 719 isolate->counters()->cow_arrays_created_runtime()->Increment(); |
| 673 } | 720 } |
| 674 | 721 |
| 675 JSObject* boilerplate_object = JSObject::cast(*boilerplate); | 722 JSObject* boilerplate_object = JSObject::cast(*boilerplate); |
| 676 AllocationSiteMode mode = AllocationSiteInfo::GetMode( | 723 AllocationSiteMode mode = allocation_site_info_allowed && |
| 677 boilerplate_object->GetElementsKind()); | 724 boilerplate_object->ShouldTrackAllocationInfo() |
|
danno
2013/02/11 15:05:21
nite: Just for clarity and easy, separate the bool
mvstanton
2013/02/15 07:36:43
Done.
| |
| 725 ? TRACK_ALLOCATION_SITE | |
| 726 : DONT_TRACK_ALLOCATION_SITE; | |
| 678 return isolate->heap()->CopyJSObject(boilerplate_object, mode); | 727 return isolate->heap()->CopyJSObject(boilerplate_object, mode); |
| 679 } | 728 } |
| 680 | 729 |
| 681 | 730 |
| 682 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { | 731 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { |
| 683 ASSERT(args.length() == 2); | 732 ASSERT(args.length() == 2); |
| 684 CONVERT_ARG_CHECKED(JSReceiver, handler, 0); | 733 CONVERT_ARG_CHECKED(JSReceiver, handler, 0); |
| 685 Object* prototype = args[1]; | 734 Object* prototype = args[1]; |
| 686 Object* used_prototype = | 735 Object* used_prototype = |
| 687 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); | 736 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); |
| (...skipping 12840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13528 // Handle last resort GC and make sure to allow future allocations | 13577 // Handle last resort GC and make sure to allow future allocations |
| 13529 // to grow the heap without causing GCs (if possible). | 13578 // to grow the heap without causing GCs (if possible). |
| 13530 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13579 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13531 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13580 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13532 "Runtime::PerformGC"); | 13581 "Runtime::PerformGC"); |
| 13533 } | 13582 } |
| 13534 } | 13583 } |
| 13535 | 13584 |
| 13536 | 13585 |
| 13537 } } // namespace v8::internal | 13586 } } // namespace v8::internal |
| OLD | NEW |