| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 const char* name, | 350 const char* name, |
| 351 InstanceType type, | 351 InstanceType type, |
| 352 int instance_size, | 352 int instance_size, |
| 353 MaybeHandle<JSObject> maybe_prototype, | 353 MaybeHandle<JSObject> maybe_prototype, |
| 354 Builtins::Name call, | 354 Builtins::Name call, |
| 355 bool set_instance_class_name) { | 355 bool set_instance_class_name) { |
| 356 Isolate* isolate = target->GetIsolate(); | 356 Isolate* isolate = target->GetIsolate(); |
| 357 Factory* factory = isolate->factory(); | 357 Factory* factory = isolate->factory(); |
| 358 Handle<String> internalized_name = factory->InternalizeUtf8String(name); | 358 Handle<String> internalized_name = factory->InternalizeUtf8String(name); |
| 359 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); | 359 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); |
| 360 Handle<JSFunction> function = factory->NewFunction( | 360 Handle<JSObject> prototype; |
| 361 maybe_prototype, internalized_name, type, instance_size, call_code); | 361 Handle<JSFunction> function = maybe_prototype.ToHandle(&prototype) |
| 362 ? factory->NewFunction(prototype, internalized_name, type, |
| 363 instance_size, call_code) |
| 364 : factory->NewFunction(internalized_name, call_code); |
| 362 PropertyAttributes attributes; | 365 PropertyAttributes attributes; |
| 363 if (target->IsJSBuiltinsObject()) { | 366 if (target->IsJSBuiltinsObject()) { |
| 364 attributes = | 367 attributes = |
| 365 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 368 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 366 } else { | 369 } else { |
| 367 attributes = DONT_ENUM; | 370 attributes = DONT_ENUM; |
| 368 } | 371 } |
| 369 JSObject::SetLocalPropertyIgnoreAttributes( | 372 JSObject::SetLocalPropertyIgnoreAttributes( |
| 370 target, internalized_name, function, attributes).Check(); | 373 target, internalized_name, function, attributes).Check(); |
| 371 if (set_instance_class_name) { | 374 if (set_instance_class_name) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 // assertions during startup. | 482 // assertions during startup. |
| 480 native_context()->set_initial_array_prototype(*prototype); | 483 native_context()->set_initial_array_prototype(*prototype); |
| 481 Accessors::FunctionSetPrototype(object_fun, prototype); | 484 Accessors::FunctionSetPrototype(object_fun, prototype); |
| 482 } | 485 } |
| 483 | 486 |
| 484 // Allocate the empty function as the prototype for function ECMAScript | 487 // Allocate the empty function as the prototype for function ECMAScript |
| 485 // 262 15.3.4. | 488 // 262 15.3.4. |
| 486 Handle<String> empty_string = | 489 Handle<String> empty_string = |
| 487 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); | 490 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); |
| 488 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); | 491 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); |
| 489 Handle<JSFunction> empty_function = factory->NewFunction( | 492 Handle<JSFunction> empty_function = factory->NewFunction(empty_string, code); |
| 490 empty_string, MaybeHandle<Object>(), code); | |
| 491 | 493 |
| 492 // --- E m p t y --- | 494 // --- E m p t y --- |
| 493 Handle<String> source = factory->NewStringFromStaticAscii("() {}"); | 495 Handle<String> source = factory->NewStringFromStaticAscii("() {}"); |
| 494 Handle<Script> script = factory->NewScript(source); | 496 Handle<Script> script = factory->NewScript(source); |
| 495 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 497 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 496 empty_function->shared()->set_script(*script); | 498 empty_function->shared()->set_script(*script); |
| 497 empty_function->shared()->set_start_position(0); | 499 empty_function->shared()->set_start_position(0); |
| 498 empty_function->shared()->set_end_position(source->length()); | 500 empty_function->shared()->set_end_position(source->length()); |
| 499 empty_function->shared()->DontAdaptArguments(); | 501 empty_function->shared()->DontAdaptArguments(); |
| 500 | 502 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 } | 563 } |
| 562 | 564 |
| 563 | 565 |
| 564 // ECMAScript 5th Edition, 13.2.3 | 566 // ECMAScript 5th Edition, 13.2.3 |
| 565 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { | 567 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { |
| 566 if (throw_type_error_function.is_null()) { | 568 if (throw_type_error_function.is_null()) { |
| 567 Handle<String> name = factory()->InternalizeOneByteString( | 569 Handle<String> name = factory()->InternalizeOneByteString( |
| 568 STATIC_ASCII_VECTOR("ThrowTypeError")); | 570 STATIC_ASCII_VECTOR("ThrowTypeError")); |
| 569 Handle<Code> code(isolate()->builtins()->builtin( | 571 Handle<Code> code(isolate()->builtins()->builtin( |
| 570 Builtins::kStrictModePoisonPill)); | 572 Builtins::kStrictModePoisonPill)); |
| 571 throw_type_error_function = factory()->NewFunction( | 573 throw_type_error_function = factory()->NewFunction(name, code); |
| 572 name, MaybeHandle<Object>(), code); | |
| 573 throw_type_error_function->set_map(native_context()->sloppy_function_map()); | 574 throw_type_error_function->set_map(native_context()->sloppy_function_map()); |
| 574 throw_type_error_function->shared()->DontAdaptArguments(); | 575 throw_type_error_function->shared()->DontAdaptArguments(); |
| 575 | 576 |
| 576 JSObject::PreventExtensions(throw_type_error_function).Assert(); | 577 JSObject::PreventExtensions(throw_type_error_function).Assert(); |
| 577 } | 578 } |
| 578 return throw_type_error_function; | 579 return throw_type_error_function; |
| 579 } | 580 } |
| 580 | 581 |
| 581 | 582 |
| 582 Handle<Map> Genesis::CreateStrictFunctionMap( | 583 Handle<Map> Genesis::CreateStrictFunctionMap( |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 Builtins::kIllegal, true); | 1080 Builtins::kIllegal, true); |
| 1080 | 1081 |
| 1081 { // --- arguments_boilerplate_ | 1082 { // --- arguments_boilerplate_ |
| 1082 // Make sure we can recognize argument objects at runtime. | 1083 // Make sure we can recognize argument objects at runtime. |
| 1083 // This is done by introducing an anonymous function with | 1084 // This is done by introducing an anonymous function with |
| 1084 // class_name equals 'Arguments'. | 1085 // class_name equals 'Arguments'. |
| 1085 Handle<String> arguments_string = factory->InternalizeOneByteString( | 1086 Handle<String> arguments_string = factory->InternalizeOneByteString( |
| 1086 STATIC_ASCII_VECTOR("Arguments")); | 1087 STATIC_ASCII_VECTOR("Arguments")); |
| 1087 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); | 1088 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); |
| 1088 | 1089 |
| 1089 Handle<JSFunction> function = factory->NewFunction( | 1090 Handle<JSFunction> function = factory->NewFunction(arguments_string, code); |
| 1090 MaybeHandle<Object>(), arguments_string, JS_OBJECT_TYPE, | |
| 1091 JSObject::kHeaderSize, code); | |
| 1092 ASSERT(!function->has_initial_map()); | 1091 ASSERT(!function->has_initial_map()); |
| 1093 function->shared()->set_instance_class_name(*arguments_string); | 1092 function->shared()->set_instance_class_name(*arguments_string); |
| 1094 function->shared()->set_expected_nof_properties(2); | 1093 function->shared()->set_expected_nof_properties(2); |
| 1095 function->set_prototype_or_initial_map( | 1094 function->set_prototype_or_initial_map( |
| 1096 native_context()->object_function()->prototype()); | 1095 native_context()->object_function()->prototype()); |
| 1097 Handle<JSObject> result = factory->NewJSObject(function); | 1096 Handle<JSObject> result = factory->NewJSObject(function); |
| 1098 | 1097 |
| 1099 native_context()->set_sloppy_arguments_boilerplate(*result); | 1098 native_context()->set_sloppy_arguments_boilerplate(*result); |
| 1100 // Note: length must be added as the first property and | 1099 // Note: length must be added as the first property and |
| 1101 // callee must be added as the second property. | 1100 // callee must be added as the second property. |
| (...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2660 return from + sizeof(NestingCounterType); | 2659 return from + sizeof(NestingCounterType); |
| 2661 } | 2660 } |
| 2662 | 2661 |
| 2663 | 2662 |
| 2664 // Called when the top-level V8 mutex is destroyed. | 2663 // Called when the top-level V8 mutex is destroyed. |
| 2665 void Bootstrapper::FreeThreadResources() { | 2664 void Bootstrapper::FreeThreadResources() { |
| 2666 ASSERT(!IsActive()); | 2665 ASSERT(!IsActive()); |
| 2667 } | 2666 } |
| 2668 | 2667 |
| 2669 } } // namespace v8::internal | 2668 } } // namespace v8::internal |
| OLD | NEW |