| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 initial_map->set_constructor(*function); | 445 initial_map->set_constructor(*function); |
| 446 } | 446 } |
| 447 | 447 |
| 448 // Set function.prototype and give the prototype a constructor | 448 // Set function.prototype and give the prototype a constructor |
| 449 // property that refers to the function. | 449 // property that refers to the function. |
| 450 SetPrototypeProperty(function, prototype); | 450 SetPrototypeProperty(function, prototype); |
| 451 SetProperty(prototype, Factory::constructor_symbol(), function, DONT_ENUM); | 451 SetProperty(prototype, Factory::constructor_symbol(), function, DONT_ENUM); |
| 452 return function; | 452 return function; |
| 453 } | 453 } |
| 454 | 454 |
| 455 |
| 455 Handle<Code> Factory::NewCode(const CodeDesc& desc, ScopeInfo<>* sinfo, | 456 Handle<Code> Factory::NewCode(const CodeDesc& desc, ScopeInfo<>* sinfo, |
| 456 Code::Flags flags) { | 457 Code::Flags flags) { |
| 457 CALL_HEAP_FUNCTION(Heap::CreateCode(desc, sinfo, flags), Code); | 458 CALL_HEAP_FUNCTION(Heap::CreateCode(desc, sinfo, flags), Code); |
| 458 } | 459 } |
| 459 | 460 |
| 460 | 461 |
| 461 Handle<Code> Factory::CopyCode(Handle<Code> code) { | 462 Handle<Code> Factory::CopyCode(Handle<Code> code) { |
| 462 CALL_HEAP_FUNCTION(Heap::CopyCode(*code), Code); | 463 CALL_HEAP_FUNCTION(Heap::CopyCode(*code), Code); |
| 463 } | 464 } |
| 464 | 465 |
| 465 | 466 |
| 466 #define CALL_GC(RETRY) \ | 467 static inline Object* DoCopyInsert(DescriptorArray* array, |
| 467 do { \ | 468 String* key, |
| 468 if (!Heap::CollectGarbage(Failure::cast(RETRY)->requested(), \ | 469 Object* value, |
| 469 Failure::cast(RETRY)->allocation_space())) { \ | 470 PropertyAttributes attributes) { |
| 470 /* TODO(1181417): Fix this. */ \ | 471 CallbacksDescriptor desc(key, value, attributes); |
| 471 V8::FatalProcessOutOfMemory("Factory CALL_GC"); \ | 472 Object* obj = array->CopyInsert(&desc, REMOVE_TRANSITIONS); |
| 472 } \ | 473 return obj; |
| 473 } while (false) | 474 } |
| 474 | 475 |
| 475 | 476 |
| 476 // Allocate the new array. We cannot use the CALL_HEAP_FUNCTION macro here, | 477 // Allocate the new array. |
| 477 // because the stack-allocated CallbacksDescriptor instance is not GC safe. | |
| 478 Handle<DescriptorArray> Factory::CopyAppendProxyDescriptor( | 478 Handle<DescriptorArray> Factory::CopyAppendProxyDescriptor( |
| 479 Handle<DescriptorArray> array, | 479 Handle<DescriptorArray> array, |
| 480 Handle<String> key, | 480 Handle<String> key, |
| 481 Handle<Object> value, | 481 Handle<Object> value, |
| 482 PropertyAttributes attributes) { | 482 PropertyAttributes attributes) { |
| 483 GC_GREEDY_CHECK(); | 483 CALL_HEAP_FUNCTION(DoCopyInsert(*array, *key, *value, attributes), |
| 484 CallbacksDescriptor desc(*key, *value, attributes); | 484 DescriptorArray); |
| 485 Object* obj = array->CopyInsert(&desc, REMOVE_TRANSITIONS); | |
| 486 if (obj->IsFailure()) { | |
| 487 if (obj->IsRetryAfterGC()) { | |
| 488 CALL_GC(obj); | |
| 489 CallbacksDescriptor desc(*key, *value, attributes); | |
| 490 obj = array->CopyInsert(&desc, REMOVE_TRANSITIONS); | |
| 491 } | |
| 492 if (obj->IsFailure()) { | |
| 493 // TODO(1181417): Fix this. | |
| 494 V8::FatalProcessOutOfMemory("CopyAppendProxyDescriptor"); | |
| 495 } | |
| 496 } | |
| 497 return Handle<DescriptorArray>(DescriptorArray::cast(obj)); | |
| 498 } | 485 } |
| 499 | 486 |
| 500 #undef CALL_GC | |
| 501 | |
| 502 | 487 |
| 503 Handle<String> Factory::SymbolFromString(Handle<String> value) { | 488 Handle<String> Factory::SymbolFromString(Handle<String> value) { |
| 504 CALL_HEAP_FUNCTION(Heap::LookupSymbol(*value), String); | 489 CALL_HEAP_FUNCTION(Heap::LookupSymbol(*value), String); |
| 505 } | 490 } |
| 506 | 491 |
| 507 | 492 |
| 508 Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors( | 493 Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors( |
| 509 Handle<DescriptorArray> array, | 494 Handle<DescriptorArray> array, |
| 510 Handle<Object> descriptors) { | 495 Handle<Object> descriptors) { |
| 511 v8::NeanderArray callbacks(descriptors); | 496 v8::NeanderArray callbacks(descriptors); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 Execution::ConfigureInstance(instance, | 829 Execution::ConfigureInstance(instance, |
| 845 instance_template, | 830 instance_template, |
| 846 pending_exception); | 831 pending_exception); |
| 847 } else { | 832 } else { |
| 848 *pending_exception = false; | 833 *pending_exception = false; |
| 849 } | 834 } |
| 850 } | 835 } |
| 851 | 836 |
| 852 | 837 |
| 853 } } // namespace v8::internal | 838 } } // namespace v8::internal |
| OLD | NEW |