OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bootstrapper.h" | 5 #include "bootstrapper.h" |
6 | 6 |
7 #include "accessors.h" | 7 #include "accessors.h" |
8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
9 #include "natives.h" | 9 #include "natives.h" |
10 #include "snapshot.h" | 10 #include "snapshot.h" |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 // prototype, otherwise the missing initial_array_prototype will cause | 477 // prototype, otherwise the missing initial_array_prototype will cause |
478 // assertions during startup. | 478 // assertions during startup. |
479 native_context()->set_initial_array_prototype(*prototype); | 479 native_context()->set_initial_array_prototype(*prototype); |
480 Accessors::FunctionSetPrototype(object_fun, prototype); | 480 Accessors::FunctionSetPrototype(object_fun, prototype); |
481 } | 481 } |
482 | 482 |
483 // Allocate the empty function as the prototype for function ECMAScript | 483 // Allocate the empty function as the prototype for function ECMAScript |
484 // 262 15.3.4. | 484 // 262 15.3.4. |
485 Handle<String> empty_string = | 485 Handle<String> empty_string = |
486 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); | 486 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); |
487 Handle<Code> code = | |
Igor Sheludko
2014/04/17 11:16:24
I think you can write here:
Handle<Code> code(i
| |
488 Handle<Code>(isolate->builtins()->builtin(Builtins::kEmptyFunction)); | |
487 Handle<JSFunction> empty_function = | 489 Handle<JSFunction> empty_function = |
488 factory->NewFunctionWithoutPrototype(empty_string, SLOPPY); | 490 factory->NewFunctionWithoutPrototype(empty_string, code); |
489 | 491 |
490 // --- E m p t y --- | 492 // --- E m p t y --- |
491 Handle<Code> code = | |
492 Handle<Code>(isolate->builtins()->builtin( | |
493 Builtins::kEmptyFunction)); | |
494 empty_function->set_code(*code); | |
495 empty_function->shared()->set_code(*code); | |
496 Handle<String> source = | 493 Handle<String> source = |
497 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); | 494 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); |
498 Handle<Script> script = factory->NewScript(source); | 495 Handle<Script> script = factory->NewScript(source); |
499 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 496 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
500 empty_function->shared()->set_script(*script); | 497 empty_function->shared()->set_script(*script); |
501 empty_function->shared()->set_start_position(0); | 498 empty_function->shared()->set_start_position(0); |
502 empty_function->shared()->set_end_position(source->length()); | 499 empty_function->shared()->set_end_position(source->length()); |
503 empty_function->shared()->DontAdaptArguments(); | 500 empty_function->shared()->DontAdaptArguments(); |
504 | 501 |
505 // Set prototypes for the function maps. | 502 // Set prototypes for the function maps. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 map->AppendDescriptor(&d); | 557 map->AppendDescriptor(&d); |
561 } | 558 } |
562 } | 559 } |
563 | 560 |
564 | 561 |
565 // ECMAScript 5th Edition, 13.2.3 | 562 // ECMAScript 5th Edition, 13.2.3 |
566 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { | 563 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { |
567 if (throw_type_error_function.is_null()) { | 564 if (throw_type_error_function.is_null()) { |
568 Handle<String> name = factory()->InternalizeOneByteString( | 565 Handle<String> name = factory()->InternalizeOneByteString( |
569 STATIC_ASCII_VECTOR("ThrowTypeError")); | 566 STATIC_ASCII_VECTOR("ThrowTypeError")); |
570 throw_type_error_function = | |
571 factory()->NewFunctionWithoutPrototype(name, SLOPPY); | |
572 Handle<Code> code(isolate()->builtins()->builtin( | 567 Handle<Code> code(isolate()->builtins()->builtin( |
573 Builtins::kStrictModePoisonPill)); | 568 Builtins::kStrictModePoisonPill)); |
569 throw_type_error_function = | |
570 factory()->NewFunctionWithoutPrototype(name, code); | |
574 throw_type_error_function->set_map(native_context()->sloppy_function_map()); | 571 throw_type_error_function->set_map(native_context()->sloppy_function_map()); |
575 throw_type_error_function->set_code(*code); | |
576 throw_type_error_function->shared()->set_code(*code); | |
577 throw_type_error_function->shared()->DontAdaptArguments(); | 572 throw_type_error_function->shared()->DontAdaptArguments(); |
578 | 573 |
579 JSObject::PreventExtensions(throw_type_error_function).Assert(); | 574 JSObject::PreventExtensions(throw_type_error_function).Assert(); |
580 } | 575 } |
581 return throw_type_error_function; | 576 return throw_type_error_function; |
582 } | 577 } |
583 | 578 |
584 | 579 |
585 Handle<Map> Genesis::CreateStrictFunctionMap( | 580 Handle<Map> Genesis::CreateStrictFunctionMap( |
586 PrototypePropertyMode prototype_mode, | 581 PrototypePropertyMode prototype_mode, |
(...skipping 2078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2665 return from + sizeof(NestingCounterType); | 2660 return from + sizeof(NestingCounterType); |
2666 } | 2661 } |
2667 | 2662 |
2668 | 2663 |
2669 // Called when the top-level V8 mutex is destroyed. | 2664 // Called when the top-level V8 mutex is destroyed. |
2670 void Bootstrapper::FreeThreadResources() { | 2665 void Bootstrapper::FreeThreadResources() { |
2671 ASSERT(!IsActive()); | 2666 ASSERT(!IsActive()); |
2672 } | 2667 } |
2673 | 2668 |
2674 } } // namespace v8::internal | 2669 } } // namespace v8::internal |
OLD | NEW |