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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 set_instance_descriptors(Heap::empty_descriptor_array()); | 479 set_instance_descriptors(Heap::empty_descriptor_array()); |
480 } | 480 } |
481 | 481 |
482 // Allocate the empty function as the prototype for function ECMAScript | 482 // Allocate the empty function as the prototype for function ECMAScript |
483 // 262 15.3.4. | 483 // 262 15.3.4. |
484 Handle<String> symbol = Factory::LookupAsciiSymbol("Empty"); | 484 Handle<String> symbol = Factory::LookupAsciiSymbol("Empty"); |
485 Handle<JSFunction> empty_function = | 485 Handle<JSFunction> empty_function = |
486 Factory::NewFunction(symbol, Factory::null_value()); | 486 Factory::NewFunction(symbol, Factory::null_value()); |
487 | 487 |
488 { // --- E m p t y --- | 488 { // --- E m p t y --- |
489 Handle<Code> call_code = | 489 Handle<Code> code = |
490 Handle<Code>(Builtins::builtin(Builtins::EmptyFunction)); | 490 Handle<Code>(Builtins::builtin(Builtins::EmptyFunction)); |
491 Handle<String> source = Factory::NewStringFromAscii(CStrVector("() {}")); | 491 Handle<String> source = Factory::NewStringFromAscii(CStrVector("() {}")); |
492 | 492 |
493 empty_function->set_code(*call_code); | 493 empty_function->set_code(*code); |
494 empty_function->shared()->set_script(*Factory::NewScript(source)); | 494 empty_function->shared()->set_script(*Factory::NewScript(source)); |
495 empty_function->shared()->set_start_position(0); | 495 empty_function->shared()->set_start_position(0); |
496 empty_function->shared()->set_end_position(source->length()); | 496 empty_function->shared()->set_end_position(source->length()); |
| 497 empty_function->shared()->DontAdaptArguments(); |
497 global_context()->function_map()->set_prototype(*empty_function); | 498 global_context()->function_map()->set_prototype(*empty_function); |
498 global_context()->function_instance_map()->set_prototype(*empty_function); | 499 global_context()->function_instance_map()->set_prototype(*empty_function); |
499 | 500 |
500 // Allocate the function map first and then patch the prototype later | 501 // Allocate the function map first and then patch the prototype later |
501 Handle<Map> empty_fm = Factory::CopyMap(fm); | 502 Handle<Map> empty_fm = Factory::CopyMap(fm); |
502 empty_fm->set_instance_descriptors(*function_map_descriptors); | 503 empty_fm->set_instance_descriptors(*function_map_descriptors); |
503 empty_fm->set_prototype(global_context()->object_function()->prototype()); | 504 empty_fm->set_prototype(global_context()->object_function()->prototype()); |
504 empty_function->set_map(*empty_fm); | 505 empty_function->set_map(*empty_fm); |
505 } | 506 } |
506 | 507 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 574 |
574 // Install global Function object | 575 // Install global Function object |
575 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 576 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
576 empty_function, Builtins::Illegal, true); // ECMA native. | 577 empty_function, Builtins::Illegal, true); // ECMA native. |
577 | 578 |
578 { // --- A r r a y --- | 579 { // --- A r r a y --- |
579 Handle<JSFunction> array_function = | 580 Handle<JSFunction> array_function = |
580 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 581 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
581 Top::initial_object_prototype(), Builtins::ArrayCode, | 582 Top::initial_object_prototype(), Builtins::ArrayCode, |
582 true); | 583 true); |
| 584 array_function->shared()->DontAdaptArguments(); |
583 | 585 |
584 // This seems a bit hackish, but we need to make sure Array.length | 586 // This seems a bit hackish, but we need to make sure Array.length |
585 // is 1. | 587 // is 1. |
586 array_function->shared()->set_length(1); | 588 array_function->shared()->set_length(1); |
587 Handle<DescriptorArray> array_descriptors = | 589 Handle<DescriptorArray> array_descriptors = |
588 Factory::CopyAppendProxyDescriptor( | 590 Factory::CopyAppendProxyDescriptor( |
589 Factory::empty_descriptor_array(), | 591 Factory::empty_descriptor_array(), |
590 Factory::length_symbol(), | 592 Factory::length_symbol(), |
591 Factory::NewProxy(&Accessors::ArrayLength), | 593 Factory::NewProxy(&Accessors::ArrayLength), |
592 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE)); | 594 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE)); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 global_context()->set_context_extension_function(*context_extension_fun); | 704 global_context()->set_context_extension_function(*context_extension_fun); |
703 } | 705 } |
704 | 706 |
705 // Setup the call-as-function delegate. | 707 // Setup the call-as-function delegate. |
706 Handle<Code> code = | 708 Handle<Code> code = |
707 Handle<Code>(Builtins::builtin(Builtins::HandleApiCallAsFunction)); | 709 Handle<Code>(Builtins::builtin(Builtins::HandleApiCallAsFunction)); |
708 Handle<JSFunction> delegate = | 710 Handle<JSFunction> delegate = |
709 Factory::NewFunction(Factory::empty_symbol(), JS_OBJECT_TYPE, | 711 Factory::NewFunction(Factory::empty_symbol(), JS_OBJECT_TYPE, |
710 JSObject::kHeaderSize, code, true); | 712 JSObject::kHeaderSize, code, true); |
711 global_context()->set_call_as_function_delegate(*delegate); | 713 global_context()->set_call_as_function_delegate(*delegate); |
| 714 delegate->shared()->DontAdaptArguments(); |
712 | 715 |
713 global_context()->set_special_function_table(Heap::empty_fixed_array()); | 716 global_context()->set_special_function_table(Heap::empty_fixed_array()); |
714 | 717 |
715 // Initialize the out of memory slot. | 718 // Initialize the out of memory slot. |
716 global_context()->set_out_of_memory(Heap::false_value()); | 719 global_context()->set_out_of_memory(Heap::false_value()); |
717 } | 720 } |
718 | 721 |
719 | 722 |
720 bool Genesis::CompileBuiltin(int index) { | 723 bool Genesis::CompileBuiltin(int index) { |
721 Vector<const char> name = Natives::GetScriptName(index); | 724 Vector<const char> name = Natives::GetScriptName(index); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 if (!ConfigureGlobalObject(global_template)) return; | 1334 if (!ConfigureGlobalObject(global_template)) return; |
1332 | 1335 |
1333 if (!InstallExtensions(extensions)) return; | 1336 if (!InstallExtensions(extensions)) return; |
1334 | 1337 |
1335 if (!InstallSpecialObjects()) return; | 1338 if (!InstallSpecialObjects()) return; |
1336 | 1339 |
1337 result_ = global_context_; | 1340 result_ = global_context_; |
1338 } | 1341 } |
1339 | 1342 |
1340 } } // namespace v8::internal | 1343 } } // namespace v8::internal |
OLD | NEW |