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

Side by Side Diff: src/bootstrapper.cc

Issue 239053007: Always pass in code to NewFunctionWithoutPrototype (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comment Created 6 years, 8 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(isolate->builtins()->builtin(Builtins::kEmptyFunction));
487 Handle<JSFunction> empty_function = 488 Handle<JSFunction> empty_function =
488 factory->NewFunctionWithoutPrototype(empty_string, SLOPPY); 489 factory->NewFunctionWithoutPrototype(empty_string, code);
489 490
490 // --- E m p t y --- 491 // --- 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 = 492 Handle<String> source =
497 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); 493 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}"));
498 Handle<Script> script = factory->NewScript(source); 494 Handle<Script> script = factory->NewScript(source);
499 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 495 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
500 empty_function->shared()->set_script(*script); 496 empty_function->shared()->set_script(*script);
501 empty_function->shared()->set_start_position(0); 497 empty_function->shared()->set_start_position(0);
502 empty_function->shared()->set_end_position(source->length()); 498 empty_function->shared()->set_end_position(source->length());
503 empty_function->shared()->DontAdaptArguments(); 499 empty_function->shared()->DontAdaptArguments();
504 500
505 // Set prototypes for the function maps. 501 // Set prototypes for the function maps.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 map->AppendDescriptor(&d); 556 map->AppendDescriptor(&d);
561 } 557 }
562 } 558 }
563 559
564 560
565 // ECMAScript 5th Edition, 13.2.3 561 // ECMAScript 5th Edition, 13.2.3
566 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { 562 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
567 if (throw_type_error_function.is_null()) { 563 if (throw_type_error_function.is_null()) {
568 Handle<String> name = factory()->InternalizeOneByteString( 564 Handle<String> name = factory()->InternalizeOneByteString(
569 STATIC_ASCII_VECTOR("ThrowTypeError")); 565 STATIC_ASCII_VECTOR("ThrowTypeError"));
570 throw_type_error_function =
571 factory()->NewFunctionWithoutPrototype(name, SLOPPY);
572 Handle<Code> code(isolate()->builtins()->builtin( 566 Handle<Code> code(isolate()->builtins()->builtin(
573 Builtins::kStrictModePoisonPill)); 567 Builtins::kStrictModePoisonPill));
568 throw_type_error_function =
569 factory()->NewFunctionWithoutPrototype(name, code);
574 throw_type_error_function->set_map(native_context()->sloppy_function_map()); 570 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(); 571 throw_type_error_function->shared()->DontAdaptArguments();
578 572
579 JSObject::PreventExtensions(throw_type_error_function).Assert(); 573 JSObject::PreventExtensions(throw_type_error_function).Assert();
580 } 574 }
581 return throw_type_error_function; 575 return throw_type_error_function;
582 } 576 }
583 577
584 578
585 Handle<Map> Genesis::CreateStrictFunctionMap( 579 Handle<Map> Genesis::CreateStrictFunctionMap(
586 PrototypePropertyMode prototype_mode, 580 PrototypePropertyMode prototype_mode,
(...skipping 2078 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 return from + sizeof(NestingCounterType); 2659 return from + sizeof(NestingCounterType);
2666 } 2660 }
2667 2661
2668 2662
2669 // Called when the top-level V8 mutex is destroyed. 2663 // Called when the top-level V8 mutex is destroyed.
2670 void Bootstrapper::FreeThreadResources() { 2664 void Bootstrapper::FreeThreadResources() {
2671 ASSERT(!IsActive()); 2665 ASSERT(!IsActive());
2672 } 2666 }
2673 2667
2674 } } // namespace v8::internal 2668 } } // 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