| 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 "src/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 480 |
| 481 native_context()->set_object_function(*object_fun); | 481 native_context()->set_object_function(*object_fun); |
| 482 | 482 |
| 483 // Allocate a new prototype for the object function. | 483 // Allocate a new prototype for the object function. |
| 484 object_function_prototype = | 484 object_function_prototype = |
| 485 factory->NewJSObject(isolate->object_function(), TENURED); | 485 factory->NewJSObject(isolate->object_function(), TENURED); |
| 486 Handle<Map> map = Map::Copy(handle(object_function_prototype->map()), | 486 Handle<Map> map = Map::Copy(handle(object_function_prototype->map()), |
| 487 "EmptyObjectPrototype"); | 487 "EmptyObjectPrototype"); |
| 488 map->set_is_prototype_map(true); | 488 map->set_is_prototype_map(true); |
| 489 object_function_prototype->set_map(*map); | 489 object_function_prototype->set_map(*map); |
| 490 Map::SetPrototypeObject(map, object_function_prototype, isolate); |
| 490 | 491 |
| 491 native_context()->set_initial_object_prototype(*object_function_prototype); | 492 native_context()->set_initial_object_prototype(*object_function_prototype); |
| 492 // For bootstrapping set the array prototype to be the same as the object | 493 // For bootstrapping set the array prototype to be the same as the object |
| 493 // prototype, otherwise the missing initial_array_prototype will cause | 494 // prototype, otherwise the missing initial_array_prototype will cause |
| 494 // assertions during startup. | 495 // assertions during startup. |
| 495 native_context()->set_initial_array_prototype(*object_function_prototype); | 496 native_context()->set_initial_array_prototype(*object_function_prototype); |
| 496 Accessors::FunctionSetPrototype(object_fun, object_function_prototype) | 497 Accessors::FunctionSetPrototype(object_fun, object_function_prototype) |
| 497 .Assert(); | 498 .Assert(); |
| 498 } | 499 } |
| 499 | 500 |
| 500 // Allocate the empty function as the prototype for function ECMAScript | 501 // Allocate the empty function as the prototype for function ECMAScript |
| 501 // 262 15.3.4. | 502 // 262 15.3.4. |
| 502 Handle<String> empty_string = | 503 Handle<String> empty_string = |
| 503 factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); | 504 factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); |
| 504 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); | 505 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); |
| 505 Handle<JSFunction> empty_function = factory->NewFunctionWithoutPrototype( | 506 Handle<JSFunction> empty_function = factory->NewFunctionWithoutPrototype( |
| 506 empty_string, code); | 507 empty_string, code); |
| 507 | 508 |
| 508 // Allocate the function map first and then patch the prototype later | 509 // Allocate the function map first and then patch the prototype later |
| 509 Handle<Map> empty_function_map = | 510 Handle<Map> empty_function_map = |
| 510 CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); | 511 CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); |
| 511 DCHECK(!empty_function_map->is_dictionary_map()); | 512 DCHECK(!empty_function_map->is_dictionary_map()); |
| 512 Map::SetPrototype(empty_function_map, object_function_prototype); | 513 Map::SetPrototype(empty_function_map, object_function_prototype); |
| 513 empty_function_map->set_is_prototype_map(true); | 514 empty_function_map->set_is_prototype_map(true); |
| 514 empty_function->set_map(*empty_function_map); | 515 empty_function->set_map(*empty_function_map); |
| 516 Map::SetPrototypeObject(empty_function_map, empty_function, isolate); |
| 515 | 517 |
| 516 // --- E m p t y --- | 518 // --- E m p t y --- |
| 517 Handle<String> source = factory->NewStringFromStaticChars("() {}"); | 519 Handle<String> source = factory->NewStringFromStaticChars("() {}"); |
| 518 Handle<Script> script = factory->NewScript(source); | 520 Handle<Script> script = factory->NewScript(source); |
| 519 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 521 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 520 empty_function->shared()->set_script(*script); | 522 empty_function->shared()->set_script(*script); |
| 521 empty_function->shared()->set_start_position(0); | 523 empty_function->shared()->set_start_position(0); |
| 522 empty_function->shared()->set_end_position(source->length()); | 524 empty_function->shared()->set_end_position(source->length()); |
| 523 empty_function->shared()->DontAdaptArguments(); | 525 empty_function->shared()->DontAdaptArguments(); |
| 524 | 526 |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, | 1122 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, |
| 1121 heap->false_value()); | 1123 heap->false_value()); |
| 1122 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, | 1124 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, |
| 1123 heap->false_value()); | 1125 heap->false_value()); |
| 1124 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, | 1126 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, |
| 1125 heap->false_value()); | 1127 heap->false_value()); |
| 1126 proto->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, | 1128 proto->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, |
| 1127 Smi::FromInt(0), | 1129 Smi::FromInt(0), |
| 1128 SKIP_WRITE_BARRIER); // It's a Smi. | 1130 SKIP_WRITE_BARRIER); // It's a Smi. |
| 1129 proto_map->set_is_prototype_map(true); | 1131 proto_map->set_is_prototype_map(true); |
| 1132 Map::SetPrototypeObject(proto_map, proto, isolate); |
| 1130 Map::SetPrototype(initial_map, proto); | 1133 Map::SetPrototype(initial_map, proto); |
| 1131 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto), | 1134 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto), |
| 1132 JSRegExp::IRREGEXP, factory->empty_string(), | 1135 JSRegExp::IRREGEXP, factory->empty_string(), |
| 1133 JSRegExp::Flags(0), 0); | 1136 JSRegExp::Flags(0), 0); |
| 1134 } | 1137 } |
| 1135 | 1138 |
| 1136 { // -- J S O N | 1139 { // -- J S O N |
| 1137 Handle<String> name = factory->InternalizeUtf8String("JSON"); | 1140 Handle<String> name = factory->InternalizeUtf8String("JSON"); |
| 1138 Handle<JSFunction> cons = factory->NewFunction(name); | 1141 Handle<JSFunction> cons = factory->NewFunction(name); |
| 1139 JSFunction::SetInstancePrototype(cons, | 1142 JSFunction::SetInstancePrototype(cons, |
| (...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2962 return from + sizeof(NestingCounterType); | 2965 return from + sizeof(NestingCounterType); |
| 2963 } | 2966 } |
| 2964 | 2967 |
| 2965 | 2968 |
| 2966 // Called when the top-level V8 mutex is destroyed. | 2969 // Called when the top-level V8 mutex is destroyed. |
| 2967 void Bootstrapper::FreeThreadResources() { | 2970 void Bootstrapper::FreeThreadResources() { |
| 2968 DCHECK(!IsActive()); | 2971 DCHECK(!IsActive()); |
| 2969 } | 2972 } |
| 2970 | 2973 |
| 2971 } } // namespace v8::internal | 2974 } } // namespace v8::internal |
| OLD | NEW |