OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // processing callbacks which may create new environments. | 164 // processing callbacks which may create new environments. |
165 Genesis* previous_; | 165 Genesis* previous_; |
166 | 166 |
167 Handle<Context> global_context() { return global_context_; } | 167 Handle<Context> global_context() { return global_context_; } |
168 | 168 |
169 // Creates some basic objects. Used for creating a context from scratch. | 169 // Creates some basic objects. Used for creating a context from scratch. |
170 void CreateRoots(); | 170 void CreateRoots(); |
171 // Creates the empty function. Used for creating a context from scratch. | 171 // Creates the empty function. Used for creating a context from scratch. |
172 Handle<JSFunction> CreateEmptyFunction(Isolate* isolate); | 172 Handle<JSFunction> CreateEmptyFunction(Isolate* isolate); |
173 // Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3 | 173 // Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3 |
174 Handle<JSFunction> CreateThrowTypeErrorFunction(Builtins::Name builtin); | 174 Handle<JSFunction> GetThrowTypeErrorFunction(); |
175 | 175 |
176 void CreateStrictModeFunctionMaps(Handle<JSFunction> empty); | 176 void CreateStrictModeFunctionMaps(Handle<JSFunction> empty); |
177 // Creates the global objects using the global and the template passed in | 177 // Creates the global objects using the global and the template passed in |
178 // through the API. We call this regardless of whether we are building a | 178 // through the API. We call this regardless of whether we are building a |
179 // context from scratch or using a deserialized one from the partial snapshot | 179 // context from scratch or using a deserialized one from the partial snapshot |
180 // but in the latter case we don't use the objects it produces directly, as | 180 // but in the latter case we don't use the objects it produces directly, as |
181 // we have to used the deserialized ones that are linked together with the | 181 // we have to used the deserialized ones that are linked together with the |
182 // rest of the context snapshot. | 182 // rest of the context snapshot. |
183 Handle<JSGlobalProxy> CreateNewGlobals( | 183 Handle<JSGlobalProxy> CreateNewGlobals( |
184 v8::Handle<v8::ObjectTemplate> global_template, | 184 v8::Handle<v8::ObjectTemplate> global_template, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 bool use_runtime_context); | 258 bool use_runtime_context); |
259 | 259 |
260 Handle<Context> result_; | 260 Handle<Context> result_; |
261 | 261 |
262 // Function instance maps. Function literal maps are created initially with | 262 // Function instance maps. Function literal maps are created initially with |
263 // a read only prototype for the processing of JS builtins. Later the function | 263 // a read only prototype for the processing of JS builtins. Later the function |
264 // instance maps are replaced in order to make prototype writable. | 264 // instance maps are replaced in order to make prototype writable. |
265 // These are the final, writable prototype, maps. | 265 // These are the final, writable prototype, maps. |
266 Handle<Map> function_instance_map_writable_prototype_; | 266 Handle<Map> function_instance_map_writable_prototype_; |
267 Handle<Map> strict_mode_function_instance_map_writable_prototype_; | 267 Handle<Map> strict_mode_function_instance_map_writable_prototype_; |
| 268 Handle<JSFunction> throw_type_error_function; |
268 | 269 |
269 BootstrapperActive active_; | 270 BootstrapperActive active_; |
270 friend class Bootstrapper; | 271 friend class Bootstrapper; |
271 }; | 272 }; |
272 | 273 |
273 | 274 |
274 void Bootstrapper::Iterate(ObjectVisitor* v) { | 275 void Bootstrapper::Iterate(ObjectVisitor* v) { |
275 extensions_cache_.Iterate(v); | 276 extensions_cache_.Iterate(v); |
276 v->Synchronize("Extensions"); | 277 v->Synchronize("Extensions"); |
277 } | 278 } |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 CallbacksDescriptor d(*factory()->prototype_symbol(), *foreign, attributes); | 543 CallbacksDescriptor d(*factory()->prototype_symbol(), *foreign, attributes); |
543 descriptors->Set(4, &d); | 544 descriptors->Set(4, &d); |
544 } | 545 } |
545 | 546 |
546 descriptors->Sort(); | 547 descriptors->Sort(); |
547 return descriptors; | 548 return descriptors; |
548 } | 549 } |
549 | 550 |
550 | 551 |
551 // ECMAScript 5th Edition, 13.2.3 | 552 // ECMAScript 5th Edition, 13.2.3 |
552 Handle<JSFunction> Genesis::CreateThrowTypeErrorFunction( | 553 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { |
553 Builtins::Name builtin) { | 554 if (throw_type_error_function.is_null()) { |
554 Handle<String> name = factory()->LookupAsciiSymbol("ThrowTypeError"); | 555 Handle<String> name = factory()->LookupAsciiSymbol("ThrowTypeError"); |
555 Handle<JSFunction> throw_type_error = | 556 throw_type_error_function = |
556 factory()->NewFunctionWithoutPrototype(name, kStrictMode); | 557 factory()->NewFunctionWithoutPrototype(name, kNonStrictMode); |
557 Handle<Code> code = Handle<Code>( | 558 Handle<Code> code(isolate()->builtins()->builtin( |
558 isolate()->builtins()->builtin(builtin)); | 559 Builtins::kStrictModePoisonPill)); |
| 560 throw_type_error_function->set_map( |
| 561 global_context()->function_map()); |
| 562 throw_type_error_function->set_code(*code); |
| 563 throw_type_error_function->shared()->set_code(*code); |
| 564 throw_type_error_function->shared()->DontAdaptArguments(); |
559 | 565 |
560 throw_type_error->set_map(global_context()->strict_mode_function_map()); | 566 PreventExtensions(throw_type_error_function); |
561 throw_type_error->set_code(*code); | 567 } |
562 throw_type_error->shared()->set_code(*code); | 568 return throw_type_error_function; |
563 throw_type_error->shared()->DontAdaptArguments(); | |
564 | |
565 PreventExtensions(throw_type_error); | |
566 | |
567 return throw_type_error; | |
568 } | 569 } |
569 | 570 |
570 | 571 |
571 Handle<Map> Genesis::CreateStrictModeFunctionMap( | 572 Handle<Map> Genesis::CreateStrictModeFunctionMap( |
572 PrototypePropertyMode prototype_mode, | 573 PrototypePropertyMode prototype_mode, |
573 Handle<JSFunction> empty_function, | 574 Handle<JSFunction> empty_function, |
574 Handle<FixedArray> arguments_callbacks, | 575 Handle<FixedArray> arguments_callbacks, |
575 Handle<FixedArray> caller_callbacks) { | 576 Handle<FixedArray> caller_callbacks) { |
576 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 577 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
577 Handle<DescriptorArray> descriptors = | 578 Handle<DescriptorArray> descriptors = |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 ADD_READONLY_PROTOTYPE, empty, arguments, caller); | 615 ADD_READONLY_PROTOTYPE, empty, arguments, caller); |
615 global_context()->set_strict_mode_function_map( | 616 global_context()->set_strict_mode_function_map( |
616 *strict_mode_function_map); | 617 *strict_mode_function_map); |
617 | 618 |
618 // The final map for the strict mode functions. Writeable prototype. | 619 // The final map for the strict mode functions. Writeable prototype. |
619 // This map is installed in MakeFunctionInstancePrototypeWritable. | 620 // This map is installed in MakeFunctionInstancePrototypeWritable. |
620 strict_mode_function_instance_map_writable_prototype_ = | 621 strict_mode_function_instance_map_writable_prototype_ = |
621 CreateStrictModeFunctionMap( | 622 CreateStrictModeFunctionMap( |
622 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); | 623 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); |
623 | 624 |
624 // Create the ThrowTypeError function instances. | 625 // Create the ThrowTypeError function instance. |
625 Handle<JSFunction> arguments_throw = | 626 Handle<JSFunction> throw_function = |
626 CreateThrowTypeErrorFunction(Builtins::kStrictFunctionArguments); | 627 GetThrowTypeErrorFunction(); |
627 Handle<JSFunction> caller_throw = | |
628 CreateThrowTypeErrorFunction(Builtins::kStrictFunctionCaller); | |
629 | 628 |
630 // Complete the callback fixed arrays. | 629 // Complete the callback fixed arrays. |
631 arguments->set(0, *arguments_throw); | 630 arguments->set(0, *throw_function); |
632 arguments->set(1, *arguments_throw); | 631 arguments->set(1, *throw_function); |
633 caller->set(0, *caller_throw); | 632 caller->set(0, *throw_function); |
634 caller->set(1, *caller_throw); | 633 caller->set(1, *throw_function); |
635 } | 634 } |
636 | 635 |
637 | 636 |
638 static void AddToWeakGlobalContextList(Context* context) { | 637 static void AddToWeakGlobalContextList(Context* context) { |
639 ASSERT(context->IsGlobalContext()); | 638 ASSERT(context->IsGlobalContext()); |
640 Heap* heap = context->GetIsolate()->heap(); | 639 Heap* heap = context->GetIsolate()->heap(); |
641 #ifdef DEBUG | 640 #ifdef DEBUG |
642 { // NOLINT | 641 { // NOLINT |
643 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); | 642 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); |
644 // Check that context is not in the list yet. | 643 // Check that context is not in the list yet. |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 } | 1053 } |
1055 | 1054 |
1056 { // --- strict mode arguments boilerplate | 1055 { // --- strict mode arguments boilerplate |
1057 const PropertyAttributes attributes = | 1056 const PropertyAttributes attributes = |
1058 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1057 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
1059 | 1058 |
1060 // Create the ThrowTypeError functions. | 1059 // Create the ThrowTypeError functions. |
1061 Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED); | 1060 Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED); |
1062 Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); | 1061 Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); |
1063 | 1062 |
1064 Handle<JSFunction> callee_throw = | 1063 Handle<JSFunction> throw_function = |
1065 CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCallee); | 1064 GetThrowTypeErrorFunction(); |
1066 Handle<JSFunction> caller_throw = | |
1067 CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCaller); | |
1068 | 1065 |
1069 // Install the ThrowTypeError functions. | 1066 // Install the ThrowTypeError functions. |
1070 callee->set(0, *callee_throw); | 1067 callee->set(0, *throw_function); |
1071 callee->set(1, *callee_throw); | 1068 callee->set(1, *throw_function); |
1072 caller->set(0, *caller_throw); | 1069 caller->set(0, *throw_function); |
1073 caller->set(1, *caller_throw); | 1070 caller->set(1, *throw_function); |
1074 | 1071 |
1075 // Create the descriptor array for the arguments object. | 1072 // Create the descriptor array for the arguments object. |
1076 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); | 1073 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); |
1077 { // length | 1074 { // length |
1078 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); | 1075 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); |
1079 descriptors->Set(0, &d); | 1076 descriptors->Set(0, &d); |
1080 } | 1077 } |
1081 { // callee | 1078 { // callee |
1082 CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes); | 1079 CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes); |
1083 descriptors->Set(1, &d); | 1080 descriptors->Set(1, &d); |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 return from + sizeof(NestingCounterType); | 2175 return from + sizeof(NestingCounterType); |
2179 } | 2176 } |
2180 | 2177 |
2181 | 2178 |
2182 // Called when the top-level V8 mutex is destroyed. | 2179 // Called when the top-level V8 mutex is destroyed. |
2183 void Bootstrapper::FreeThreadResources() { | 2180 void Bootstrapper::FreeThreadResources() { |
2184 ASSERT(!IsActive()); | 2181 ASSERT(!IsActive()); |
2185 } | 2182 } |
2186 | 2183 |
2187 } } // namespace v8::internal | 2184 } } // namespace v8::internal |
OLD | NEW |