Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: src/bootstrapper.cc

Issue 268063008: Replace NewFunctionWithPrototype(name, prototype) by NewFunction(name) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // The final map for functions. Writeable prototype. 454 // The final map for functions. Writeable prototype.
455 // This map is installed in MakeFunctionInstancePrototypeWritable. 455 // This map is installed in MakeFunctionInstancePrototypeWritable.
456 sloppy_function_map_writable_prototype_ = 456 sloppy_function_map_writable_prototype_ =
457 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); 457 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
458 458
459 Factory* factory = isolate->factory(); 459 Factory* factory = isolate->factory();
460 460
461 Handle<String> object_name = factory->Object_string(); 461 Handle<String> object_name = factory->Object_string();
462 462
463 { // --- O b j e c t --- 463 { // --- O b j e c t ---
464 Handle<JSFunction> object_fun = factory->NewFunctionWithPrototype( 464 Handle<JSFunction> object_fun = factory->NewFunction(object_name);
465 object_name, factory->null_value());
466 Handle<Map> object_function_map = 465 Handle<Map> object_function_map =
467 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 466 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
468 object_fun->set_initial_map(*object_function_map); 467 object_fun->set_initial_map(*object_function_map);
469 object_function_map->set_constructor(*object_fun); 468 object_function_map->set_constructor(*object_fun);
470 469
471 native_context()->set_object_function(*object_fun); 470 native_context()->set_object_function(*object_fun);
472 471
473 // Allocate a new prototype for the object function. 472 // Allocate a new prototype for the object function.
474 Handle<JSObject> prototype = factory->NewJSObject( 473 Handle<JSObject> prototype = factory->NewJSObject(
475 isolate->object_function(), 474 isolate->object_function(),
476 TENURED); 475 TENURED);
477 476
478 native_context()->set_initial_object_prototype(*prototype); 477 native_context()->set_initial_object_prototype(*prototype);
479 // For bootstrapping set the array prototype to be the same as the object 478 // For bootstrapping set the array prototype to be the same as the object
480 // prototype, otherwise the missing initial_array_prototype will cause 479 // prototype, otherwise the missing initial_array_prototype will cause
481 // assertions during startup. 480 // assertions during startup.
482 native_context()->set_initial_array_prototype(*prototype); 481 native_context()->set_initial_array_prototype(*prototype);
483 Accessors::FunctionSetPrototype(object_fun, prototype); 482 Accessors::FunctionSetPrototype(object_fun, prototype);
484 } 483 }
485 484
486 // Allocate the empty function as the prototype for function ECMAScript 485 // Allocate the empty function as the prototype for function ECMAScript
487 // 262 15.3.4. 486 // 262 15.3.4.
488 Handle<String> empty_string = 487 Handle<String> empty_string =
489 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); 488 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
490 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); 489 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction));
491 Handle<JSFunction> empty_function = factory->NewFunction(empty_string, code); 490 Handle<JSFunction> empty_function = factory->NewFunction(
491 empty_string, MaybeHandle<Object>(), code);
492 492
493 // --- E m p t y --- 493 // --- E m p t y ---
494 Handle<String> source = factory->NewStringFromStaticAscii("() {}"); 494 Handle<String> source = factory->NewStringFromStaticAscii("() {}");
495 Handle<Script> script = factory->NewScript(source); 495 Handle<Script> script = factory->NewScript(source);
496 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 496 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
497 empty_function->shared()->set_script(*script); 497 empty_function->shared()->set_script(*script);
498 empty_function->shared()->set_start_position(0); 498 empty_function->shared()->set_start_position(0);
499 empty_function->shared()->set_end_position(source->length()); 499 empty_function->shared()->set_end_position(source->length());
500 empty_function->shared()->DontAdaptArguments(); 500 empty_function->shared()->DontAdaptArguments();
501 501
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 } 562 }
563 563
564 564
565 // ECMAScript 5th Edition, 13.2.3 565 // ECMAScript 5th Edition, 13.2.3
566 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { 566 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
567 if (throw_type_error_function.is_null()) { 567 if (throw_type_error_function.is_null()) {
568 Handle<String> name = factory()->InternalizeOneByteString( 568 Handle<String> name = factory()->InternalizeOneByteString(
569 STATIC_ASCII_VECTOR("ThrowTypeError")); 569 STATIC_ASCII_VECTOR("ThrowTypeError"));
570 Handle<Code> code(isolate()->builtins()->builtin( 570 Handle<Code> code(isolate()->builtins()->builtin(
571 Builtins::kStrictModePoisonPill)); 571 Builtins::kStrictModePoisonPill));
572 throw_type_error_function = factory()->NewFunction(name, code); 572 throw_type_error_function = factory()->NewFunction(
573 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 Smi::FromInt(0), 1020 Smi::FromInt(0),
1020 SKIP_WRITE_BARRIER); // It's a Smi. 1021 SKIP_WRITE_BARRIER); // It's a Smi.
1021 initial_map->set_prototype(*proto); 1022 initial_map->set_prototype(*proto);
1022 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto), 1023 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto),
1023 JSRegExp::IRREGEXP, factory->empty_string(), 1024 JSRegExp::IRREGEXP, factory->empty_string(),
1024 JSRegExp::Flags(0), 0); 1025 JSRegExp::Flags(0), 0);
1025 } 1026 }
1026 1027
1027 { // -- J S O N 1028 { // -- J S O N
1028 Handle<String> name = factory->InternalizeUtf8String("JSON"); 1029 Handle<String> name = factory->InternalizeUtf8String("JSON");
1029 Handle<JSFunction> cons = factory->NewFunctionWithPrototype( 1030 Handle<JSFunction> cons = factory->NewFunction(name);
1030 name, factory->the_hole_value());
1031 JSFunction::SetInstancePrototype(cons, 1031 JSFunction::SetInstancePrototype(cons,
1032 Handle<Object>(native_context()->initial_object_prototype(), isolate)); 1032 Handle<Object>(native_context()->initial_object_prototype(), isolate));
1033 cons->SetInstanceClassName(*name); 1033 cons->SetInstanceClassName(*name);
1034 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); 1034 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
1035 ASSERT(json_object->IsJSObject()); 1035 ASSERT(json_object->IsJSObject());
1036 JSObject::SetLocalPropertyIgnoreAttributes( 1036 JSObject::SetLocalPropertyIgnoreAttributes(
1037 global, name, json_object, DONT_ENUM).Check(); 1037 global, name, json_object, DONT_ENUM).Check();
1038 native_context()->set_json_object(*json_object); 1038 native_context()->set_json_object(*json_object);
1039 } 1039 }
1040 1040
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 Handle<String> builtins_string = 1663 Handle<String> builtins_string =
1664 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); 1664 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins"));
1665 JSObject::SetLocalPropertyIgnoreAttributes( 1665 JSObject::SetLocalPropertyIgnoreAttributes(
1666 builtins, builtins_string, builtins, attributes).Check(); 1666 builtins, builtins_string, builtins, attributes).Check();
1667 1667
1668 // Set up the reference from the global object to the builtins object. 1668 // Set up the reference from the global object to the builtins object.
1669 JSGlobalObject::cast(native_context()->global_object())-> 1669 JSGlobalObject::cast(native_context()->global_object())->
1670 set_builtins(*builtins); 1670 set_builtins(*builtins);
1671 1671
1672 // Create a bridge function that has context in the native context. 1672 // Create a bridge function that has context in the native context.
1673 Handle<JSFunction> bridge = factory()->NewFunctionWithPrototype( 1673 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string());
1674 factory()->empty_string(), factory()->undefined_value());
1675 ASSERT(bridge->context() == *isolate()->native_context()); 1674 ASSERT(bridge->context() == *isolate()->native_context());
1676 1675
1677 // Allocate the builtins context. 1676 // Allocate the builtins context.
1678 Handle<Context> context = 1677 Handle<Context> context =
1679 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); 1678 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge);
1680 context->set_global_object(*builtins); // override builtins global object 1679 context->set_global_object(*builtins); // override builtins global object
1681 1680
1682 native_context()->set_runtime_context(*context); 1681 native_context()->set_runtime_context(*context);
1683 1682
1684 { // -- S c r i p t 1683 { // -- S c r i p t
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
2673 return from + sizeof(NestingCounterType); 2672 return from + sizeof(NestingCounterType);
2674 } 2673 }
2675 2674
2676 2675
2677 // Called when the top-level V8 mutex is destroyed. 2676 // Called when the top-level V8 mutex is destroyed.
2678 void Bootstrapper::FreeThreadResources() { 2677 void Bootstrapper::FreeThreadResources() {
2679 ASSERT(!IsActive()); 2678 ASSERT(!IsActive());
2680 } 2679 }
2681 2680
2682 } } // namespace v8::internal 2681 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698