| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 Handle<Map> Factory::CopyMapDropTransitions(Handle<Map> src) { | 275 Handle<Map> Factory::CopyMapDropTransitions(Handle<Map> src) { |
| 276 CALL_HEAP_FUNCTION(src->CopyDropTransitions(), Map); | 276 CALL_HEAP_FUNCTION(src->CopyDropTransitions(), Map); |
| 277 } | 277 } |
| 278 | 278 |
| 279 | 279 |
| 280 Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) { | 280 Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) { |
| 281 CALL_HEAP_FUNCTION(array->Copy(), FixedArray); | 281 CALL_HEAP_FUNCTION(array->Copy(), FixedArray); |
| 282 } | 282 } |
| 283 | 283 |
| 284 | 284 |
| 285 Handle<JSFunction> Factory::BaseNewFunctionFromBoilerplate( | 285 Handle<JSFunction> Factory::BaseNewFunctionFromSharedFunctionInfo( |
| 286 Handle<JSFunction> boilerplate, | 286 Handle<SharedFunctionInfo> function_info, |
| 287 Handle<Map> function_map, | 287 Handle<Map> function_map, |
| 288 PretenureFlag pretenure) { | 288 PretenureFlag pretenure) { |
| 289 ASSERT(boilerplate->IsBoilerplate()); | |
| 290 ASSERT(!boilerplate->has_initial_map()); | |
| 291 ASSERT(!boilerplate->has_prototype()); | |
| 292 ASSERT(boilerplate->properties() == Heap::empty_fixed_array()); | |
| 293 ASSERT(boilerplate->elements() == Heap::empty_fixed_array()); | |
| 294 CALL_HEAP_FUNCTION(Heap::AllocateFunction(*function_map, | 289 CALL_HEAP_FUNCTION(Heap::AllocateFunction(*function_map, |
| 295 boilerplate->shared(), | 290 *function_info, |
| 296 Heap::the_hole_value(), | 291 Heap::the_hole_value(), |
| 297 pretenure), | 292 pretenure), |
| 298 JSFunction); | 293 JSFunction); |
| 299 } | 294 } |
| 300 | 295 |
| 301 | 296 |
| 302 Handle<JSFunction> Factory::NewFunctionFromBoilerplate( | 297 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
| 303 Handle<JSFunction> boilerplate, | 298 Handle<SharedFunctionInfo> function_info, |
| 304 Handle<Context> context, | 299 Handle<Context> context, |
| 305 PretenureFlag pretenure) { | 300 PretenureFlag pretenure) { |
| 306 Handle<JSFunction> result = BaseNewFunctionFromBoilerplate( | 301 Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo( |
| 307 boilerplate, Top::function_map(), pretenure); | 302 function_info, Top::function_map(), pretenure); |
| 308 result->set_context(*context); | 303 result->set_context(*context); |
| 309 int number_of_literals = boilerplate->NumberOfLiterals(); | 304 int number_of_literals = function_info->num_literals(); |
| 310 Handle<FixedArray> literals = | 305 Handle<FixedArray> literals = |
| 311 Factory::NewFixedArray(number_of_literals, pretenure); | 306 Factory::NewFixedArray(number_of_literals, pretenure); |
| 312 if (number_of_literals > 0) { | 307 if (number_of_literals > 0) { |
| 313 // Store the object, regexp and array functions in the literals | 308 // Store the object, regexp and array functions in the literals |
| 314 // array prefix. These functions will be used when creating | 309 // array prefix. These functions will be used when creating |
| 315 // object, regexp and array literals in this function. | 310 // object, regexp and array literals in this function. |
| 316 literals->set(JSFunction::kLiteralGlobalContextIndex, | 311 literals->set(JSFunction::kLiteralGlobalContextIndex, |
| 317 context->global_context()); | 312 context->global_context()); |
| 318 } | 313 } |
| 319 result->set_literals(*literals); | 314 result->set_literals(*literals); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 initial_map->set_constructor(*function); | 478 initial_map->set_constructor(*function); |
| 484 } else { | 479 } else { |
| 485 ASSERT(!function->has_initial_map()); | 480 ASSERT(!function->has_initial_map()); |
| 486 ASSERT(!function->has_prototype()); | 481 ASSERT(!function->has_prototype()); |
| 487 } | 482 } |
| 488 | 483 |
| 489 return function; | 484 return function; |
| 490 } | 485 } |
| 491 | 486 |
| 492 | 487 |
| 493 Handle<JSFunction> Factory::NewFunctionBoilerplate(Handle<String> name, | |
| 494 int number_of_literals, | |
| 495 Handle<Code> code) { | |
| 496 Handle<JSFunction> function = NewFunctionBoilerplate(name); | |
| 497 function->set_code(*code); | |
| 498 int literals_array_size = number_of_literals; | |
| 499 // If the function contains object, regexp or array literals, | |
| 500 // allocate extra space for a literals array prefix containing the | |
| 501 // object, regexp and array constructor functions. | |
| 502 if (number_of_literals > 0) { | |
| 503 literals_array_size += JSFunction::kLiteralsPrefixSize; | |
| 504 } | |
| 505 Handle<FixedArray> literals = | |
| 506 Factory::NewFixedArray(literals_array_size, TENURED); | |
| 507 function->set_literals(*literals); | |
| 508 ASSERT(!function->has_initial_map()); | |
| 509 ASSERT(!function->has_prototype()); | |
| 510 return function; | |
| 511 } | |
| 512 | |
| 513 | |
| 514 Handle<JSFunction> Factory::NewFunctionBoilerplate(Handle<String> name) { | |
| 515 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); | |
| 516 CALL_HEAP_FUNCTION(Heap::AllocateFunction(Heap::boilerplate_function_map(), | |
| 517 *shared, | |
| 518 Heap::the_hole_value()), | |
| 519 JSFunction); | |
| 520 } | |
| 521 | |
| 522 | |
| 523 Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name, | 488 Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name, |
| 524 InstanceType type, | 489 InstanceType type, |
| 525 int instance_size, | 490 int instance_size, |
| 526 Handle<JSObject> prototype, | 491 Handle<JSObject> prototype, |
| 527 Handle<Code> code, | 492 Handle<Code> code, |
| 528 bool force_initial_map) { | 493 bool force_initial_map) { |
| 529 // Allocate the function | 494 // Allocate the function |
| 530 Handle<JSFunction> function = NewFunction(name, prototype); | 495 Handle<JSFunction> function = NewFunction(name, prototype); |
| 531 | 496 |
| 532 function->set_code(*code); | 497 function->set_code(*code); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 | 644 |
| 680 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements, | 645 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements, |
| 681 PretenureFlag pretenure) { | 646 PretenureFlag pretenure) { |
| 682 Handle<JSArray> result = | 647 Handle<JSArray> result = |
| 683 Handle<JSArray>::cast(NewJSObject(Top::array_function(), pretenure)); | 648 Handle<JSArray>::cast(NewJSObject(Top::array_function(), pretenure)); |
| 684 result->SetContent(*elements); | 649 result->SetContent(*elements); |
| 685 return result; | 650 return result; |
| 686 } | 651 } |
| 687 | 652 |
| 688 | 653 |
| 654 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
| 655 Handle<String> name, int number_of_literals, Handle<Code> code) { |
| 656 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); |
| 657 shared->set_code(*code); |
| 658 int literals_array_size = number_of_literals; |
| 659 // If the function contains object, regexp or array literals, |
| 660 // allocate extra space for a literals array prefix containing the |
| 661 // context. |
| 662 if (number_of_literals > 0) { |
| 663 literals_array_size += JSFunction::kLiteralsPrefixSize; |
| 664 } |
| 665 shared->set_num_literals(literals_array_size); |
| 666 return shared; |
| 667 } |
| 668 |
| 669 |
| 689 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(Handle<String> name) { | 670 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(Handle<String> name) { |
| 690 CALL_HEAP_FUNCTION(Heap::AllocateSharedFunctionInfo(*name), | 671 CALL_HEAP_FUNCTION(Heap::AllocateSharedFunctionInfo(*name), |
| 691 SharedFunctionInfo); | 672 SharedFunctionInfo); |
| 692 } | 673 } |
| 693 | 674 |
| 694 | 675 |
| 695 Handle<String> Factory::NumberToString(Handle<Object> number) { | 676 Handle<String> Factory::NumberToString(Handle<Object> number) { |
| 696 CALL_HEAP_FUNCTION(Heap::NumberToString(*number), String); | 677 CALL_HEAP_FUNCTION(Heap::NumberToString(*number), String); |
| 697 } | 678 } |
| 698 | 679 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 Execution::ConfigureInstance(instance, | 943 Execution::ConfigureInstance(instance, |
| 963 instance_template, | 944 instance_template, |
| 964 pending_exception); | 945 pending_exception); |
| 965 } else { | 946 } else { |
| 966 *pending_exception = false; | 947 *pending_exception = false; |
| 967 } | 948 } |
| 968 } | 949 } |
| 969 | 950 |
| 970 | 951 |
| 971 } } // namespace v8::internal | 952 } } // namespace v8::internal |
| OLD | NEW |