Chromium Code Reviews| 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, kStrictMode); |
|
Lasse Reichstein
2011/05/24 09:44:10
It's should not be a strict function.
If it's a st
Lasse Reichstein
2011/05/24 09:44:10
Does this create a function with no .prototype pro
Rico
2011/05/24 10:46:08
Done
Rico
2011/05/24 10:46:08
It creates an empty function with a function witho
Lasse Reichstein
2011/05/24 11:00:19
That *sounds* incorrect. It should have the standa
| |
| 557 Handle<Code> code = Handle<Code>( | 558 Handle<Code> code = |
| 558 isolate()->builtins()->builtin(builtin)); | 559 Handle<Code>(isolate()->builtins()->builtin( |
| 560 Builtins::kStrictModePoisonPill)); | |
|
Lasse Reichstein
2011/05/24 09:44:10
Just use an initializer instead of repeating "Hand
Rico
2011/05/24 10:46:08
Done.
| |
| 559 | 561 |
| 560 throw_type_error->set_map(global_context()->strict_mode_function_map()); | 562 throw_type_error_function->set_map( |
| 561 throw_type_error->set_code(*code); | 563 global_context()->strict_mode_function_map()); |
|
Lasse Reichstein
2011/05/24 09:44:10
Still not a strict function.
Rico
2011/05/24 10:46:08
Done.
| |
| 562 throw_type_error->shared()->set_code(*code); | 564 throw_type_error_function->set_code(*code); |
| 563 throw_type_error->shared()->DontAdaptArguments(); | 565 throw_type_error_function->shared()->set_code(*code); |
| 566 throw_type_error_function->shared()->DontAdaptArguments(); | |
| 564 | 567 |
| 565 PreventExtensions(throw_type_error); | 568 PreventExtensions(throw_type_error_function); |
| 566 | 569 } |
| 567 return throw_type_error; | 570 return throw_type_error_function; |
| 568 } | 571 } |
| 569 | 572 |
| 570 | 573 |
| 571 Handle<Map> Genesis::CreateStrictModeFunctionMap( | 574 Handle<Map> Genesis::CreateStrictModeFunctionMap( |
| 572 PrototypePropertyMode prototype_mode, | 575 PrototypePropertyMode prototype_mode, |
| 573 Handle<JSFunction> empty_function, | 576 Handle<JSFunction> empty_function, |
| 574 Handle<FixedArray> arguments_callbacks, | 577 Handle<FixedArray> arguments_callbacks, |
| 575 Handle<FixedArray> caller_callbacks) { | 578 Handle<FixedArray> caller_callbacks) { |
| 576 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 579 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
| 577 Handle<DescriptorArray> descriptors = | 580 Handle<DescriptorArray> descriptors = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 ADD_READONLY_PROTOTYPE, empty, arguments, caller); | 617 ADD_READONLY_PROTOTYPE, empty, arguments, caller); |
| 615 global_context()->set_strict_mode_function_map( | 618 global_context()->set_strict_mode_function_map( |
| 616 *strict_mode_function_map); | 619 *strict_mode_function_map); |
| 617 | 620 |
| 618 // The final map for the strict mode functions. Writeable prototype. | 621 // The final map for the strict mode functions. Writeable prototype. |
| 619 // This map is installed in MakeFunctionInstancePrototypeWritable. | 622 // This map is installed in MakeFunctionInstancePrototypeWritable. |
| 620 strict_mode_function_instance_map_writable_prototype_ = | 623 strict_mode_function_instance_map_writable_prototype_ = |
| 621 CreateStrictModeFunctionMap( | 624 CreateStrictModeFunctionMap( |
| 622 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); | 625 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); |
| 623 | 626 |
| 624 // Create the ThrowTypeError function instances. | 627 // Create the ThrowTypeError function instance. |
| 625 Handle<JSFunction> arguments_throw = | 628 Handle<JSFunction> throw_function = |
| 626 CreateThrowTypeErrorFunction(Builtins::kStrictFunctionArguments); | 629 GetThrowTypeErrorFunction(); |
| 627 Handle<JSFunction> caller_throw = | |
| 628 CreateThrowTypeErrorFunction(Builtins::kStrictFunctionCaller); | |
| 629 | 630 |
| 630 // Complete the callback fixed arrays. | 631 // Complete the callback fixed arrays. |
| 631 arguments->set(0, *arguments_throw); | 632 arguments->set(0, *throw_function); |
| 632 arguments->set(1, *arguments_throw); | 633 arguments->set(1, *throw_function); |
| 633 caller->set(0, *caller_throw); | 634 caller->set(0, *throw_function); |
| 634 caller->set(1, *caller_throw); | 635 caller->set(1, *throw_function); |
| 635 } | 636 } |
| 636 | 637 |
| 637 | 638 |
| 638 static void AddToWeakGlobalContextList(Context* context) { | 639 static void AddToWeakGlobalContextList(Context* context) { |
| 639 ASSERT(context->IsGlobalContext()); | 640 ASSERT(context->IsGlobalContext()); |
| 640 Heap* heap = context->GetIsolate()->heap(); | 641 Heap* heap = context->GetIsolate()->heap(); |
| 641 #ifdef DEBUG | 642 #ifdef DEBUG |
| 642 { // NOLINT | 643 { // NOLINT |
| 643 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); | 644 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); |
| 644 // Check that context is not in the list yet. | 645 // Check that context is not in the list yet. |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1054 } | 1055 } |
| 1055 | 1056 |
| 1056 { // --- strict mode arguments boilerplate | 1057 { // --- strict mode arguments boilerplate |
| 1057 const PropertyAttributes attributes = | 1058 const PropertyAttributes attributes = |
| 1058 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1059 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 1059 | 1060 |
| 1060 // Create the ThrowTypeError functions. | 1061 // Create the ThrowTypeError functions. |
| 1061 Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED); | 1062 Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED); |
| 1062 Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); | 1063 Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); |
| 1063 | 1064 |
| 1064 Handle<JSFunction> callee_throw = | 1065 Handle<JSFunction> throw_function = |
| 1065 CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCallee); | 1066 GetThrowTypeErrorFunction(); |
| 1066 Handle<JSFunction> caller_throw = | |
| 1067 CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCaller); | |
| 1068 | 1067 |
| 1069 // Install the ThrowTypeError functions. | 1068 // Install the ThrowTypeError functions. |
| 1070 callee->set(0, *callee_throw); | 1069 callee->set(0, *throw_function); |
| 1071 callee->set(1, *callee_throw); | 1070 callee->set(1, *throw_function); |
| 1072 caller->set(0, *caller_throw); | 1071 caller->set(0, *throw_function); |
| 1073 caller->set(1, *caller_throw); | 1072 caller->set(1, *throw_function); |
| 1074 | 1073 |
| 1075 // Create the descriptor array for the arguments object. | 1074 // Create the descriptor array for the arguments object. |
| 1076 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); | 1075 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); |
| 1077 { // length | 1076 { // length |
| 1078 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); | 1077 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); |
| 1079 descriptors->Set(0, &d); | 1078 descriptors->Set(0, &d); |
| 1080 } | 1079 } |
| 1081 { // callee | 1080 { // callee |
| 1082 CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes); | 1081 CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes); |
| 1083 descriptors->Set(1, &d); | 1082 descriptors->Set(1, &d); |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2178 return from + sizeof(NestingCounterType); | 2177 return from + sizeof(NestingCounterType); |
| 2179 } | 2178 } |
| 2180 | 2179 |
| 2181 | 2180 |
| 2182 // Called when the top-level V8 mutex is destroyed. | 2181 // Called when the top-level V8 mutex is destroyed. |
| 2183 void Bootstrapper::FreeThreadResources() { | 2182 void Bootstrapper::FreeThreadResources() { |
| 2184 ASSERT(!IsActive()); | 2183 ASSERT(!IsActive()); |
| 2185 } | 2184 } |
| 2186 | 2185 |
| 2187 } } // namespace v8::internal | 2186 } } // namespace v8::internal |
| OLD | NEW |