| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 return map; | 393 return map; |
| 394 } | 394 } |
| 395 | 395 |
| 396 | 396 |
| 397 Handle<JSFunction> Genesis::CreateEmptyFunction() { | 397 Handle<JSFunction> Genesis::CreateEmptyFunction() { |
| 398 // Allocate the map for function instances. Maps are allocated first and their | 398 // Allocate the map for function instances. Maps are allocated first and their |
| 399 // prototypes patched later, once empty function is created. | 399 // prototypes patched later, once empty function is created. |
| 400 | 400 |
| 401 // Please note that the prototype property for function instances must be | 401 // Please note that the prototype property for function instances must be |
| 402 // writable. | 402 // writable. |
| 403 global_context()->set_function_instance_map( | 403 Handle<Map> function_instance_map = |
| 404 *CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE)); | 404 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); |
| 405 global_context()->set_function_instance_map(*function_instance_map); |
| 405 | 406 |
| 406 // Functions with this map will not have a 'prototype' property, and | 407 // Functions with this map will not have a 'prototype' property, and |
| 407 // can not be used as constructors. | 408 // can not be used as constructors. |
| 409 Handle<Map> function_without_prototype_map = |
| 410 CreateFunctionMap(DONT_ADD_PROTOTYPE); |
| 408 global_context()->set_function_without_prototype_map( | 411 global_context()->set_function_without_prototype_map( |
| 409 *CreateFunctionMap(DONT_ADD_PROTOTYPE)); | 412 *function_without_prototype_map); |
| 410 | 413 |
| 411 // Allocate the function map. This map is temporary, used only for processing | 414 // Allocate the function map. This map is temporary, used only for processing |
| 412 // of builtins. | 415 // of builtins. |
| 413 // Later the map is replaced with writable prototype map, allocated below. | 416 // Later the map is replaced with writable prototype map, allocated below. |
| 414 global_context()->set_function_map( | 417 Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE); |
| 415 *CreateFunctionMap(ADD_READONLY_PROTOTYPE)); | 418 global_context()->set_function_map(*function_map); |
| 416 | 419 |
| 417 // The final map for functions. Writeable prototype. | 420 // The final map for functions. Writeable prototype. |
| 418 // This map is installed in MakeFunctionInstancePrototypeWritable. | 421 // This map is installed in MakeFunctionInstancePrototypeWritable. |
| 419 function_instance_map_writable_prototype_ = | 422 function_instance_map_writable_prototype_ = |
| 420 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); | 423 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); |
| 421 | 424 |
| 422 Isolate* isolate = Isolate::Current(); | 425 Isolate* isolate = Isolate::Current(); |
| 423 Factory* factory = isolate->factory(); | 426 Factory* factory = isolate->factory(); |
| 424 Heap* heap = isolate->heap(); | 427 Heap* heap = isolate->heap(); |
| 425 | 428 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 empty_function->shared()->DontAdaptArguments(); | 470 empty_function->shared()->DontAdaptArguments(); |
| 468 | 471 |
| 469 // Set prototypes for the function maps. | 472 // Set prototypes for the function maps. |
| 470 global_context()->function_map()->set_prototype(*empty_function); | 473 global_context()->function_map()->set_prototype(*empty_function); |
| 471 global_context()->function_instance_map()->set_prototype(*empty_function); | 474 global_context()->function_instance_map()->set_prototype(*empty_function); |
| 472 global_context()->function_without_prototype_map()-> | 475 global_context()->function_without_prototype_map()-> |
| 473 set_prototype(*empty_function); | 476 set_prototype(*empty_function); |
| 474 function_instance_map_writable_prototype_->set_prototype(*empty_function); | 477 function_instance_map_writable_prototype_->set_prototype(*empty_function); |
| 475 | 478 |
| 476 // Allocate the function map first and then patch the prototype later | 479 // Allocate the function map first and then patch the prototype later |
| 477 Handle<Map> function_without_prototype_map( | |
| 478 global_context()->function_without_prototype_map()); | |
| 479 Handle<Map> empty_fm = factory->CopyMapDropDescriptors( | 480 Handle<Map> empty_fm = factory->CopyMapDropDescriptors( |
| 480 function_without_prototype_map); | 481 function_without_prototype_map); |
| 481 empty_fm->set_instance_descriptors( | 482 empty_fm->set_instance_descriptors( |
| 482 function_without_prototype_map->instance_descriptors()); | 483 function_without_prototype_map->instance_descriptors()); |
| 483 empty_fm->set_prototype(global_context()->object_function()->prototype()); | 484 empty_fm->set_prototype(global_context()->object_function()->prototype()); |
| 484 empty_function->set_map(*empty_fm); | 485 empty_function->set_map(*empty_fm); |
| 485 return empty_function; | 486 return empty_function; |
| 486 } | 487 } |
| 487 | 488 |
| 488 | 489 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 | 572 |
| 572 | 573 |
| 573 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { | 574 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { |
| 574 // Create the callbacks arrays for ThrowTypeError functions. | 575 // Create the callbacks arrays for ThrowTypeError functions. |
| 575 // The get/set callacks are filled in after the maps are created below. | 576 // The get/set callacks are filled in after the maps are created below. |
| 576 Factory* factory = Isolate::Current()->factory(); | 577 Factory* factory = Isolate::Current()->factory(); |
| 577 Handle<FixedArray> arguments = factory->NewFixedArray(2, TENURED); | 578 Handle<FixedArray> arguments = factory->NewFixedArray(2, TENURED); |
| 578 Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); | 579 Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); |
| 579 | 580 |
| 580 // Allocate map for the strict mode function instances. | 581 // Allocate map for the strict mode function instances. |
| 582 Handle<Map> strict_mode_function_instance_map = |
| 583 CreateStrictModeFunctionMap( |
| 584 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); |
| 581 global_context()->set_strict_mode_function_instance_map( | 585 global_context()->set_strict_mode_function_instance_map( |
| 582 *CreateStrictModeFunctionMap( | 586 *strict_mode_function_instance_map); |
| 583 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller)); | |
| 584 | 587 |
| 585 // Allocate map for the prototype-less strict mode instances. | 588 // Allocate map for the prototype-less strict mode instances. |
| 589 Handle<Map> strict_mode_function_without_prototype_map = |
| 590 CreateStrictModeFunctionMap( |
| 591 DONT_ADD_PROTOTYPE, empty, arguments, caller); |
| 586 global_context()->set_strict_mode_function_without_prototype_map( | 592 global_context()->set_strict_mode_function_without_prototype_map( |
| 587 *CreateStrictModeFunctionMap( | 593 *strict_mode_function_without_prototype_map); |
| 588 DONT_ADD_PROTOTYPE, empty, arguments, caller)); | |
| 589 | 594 |
| 590 // Allocate map for the strict mode functions. This map is temporary, used | 595 // Allocate map for the strict mode functions. This map is temporary, used |
| 591 // only for processing of builtins. | 596 // only for processing of builtins. |
| 592 // Later the map is replaced with writable prototype map, allocated below. | 597 // Later the map is replaced with writable prototype map, allocated below. |
| 598 Handle<Map> strict_mode_function_map = |
| 599 CreateStrictModeFunctionMap( |
| 600 ADD_READONLY_PROTOTYPE, empty, arguments, caller); |
| 593 global_context()->set_strict_mode_function_map( | 601 global_context()->set_strict_mode_function_map( |
| 594 *CreateStrictModeFunctionMap( | 602 *strict_mode_function_map); |
| 595 ADD_READONLY_PROTOTYPE, empty, arguments, caller)); | |
| 596 | 603 |
| 597 // The final map for the strict mode functions. Writeable prototype. | 604 // The final map for the strict mode functions. Writeable prototype. |
| 598 // This map is installed in MakeFunctionInstancePrototypeWritable. | 605 // This map is installed in MakeFunctionInstancePrototypeWritable. |
| 599 strict_mode_function_instance_map_writable_prototype_ = | 606 strict_mode_function_instance_map_writable_prototype_ = |
| 600 CreateStrictModeFunctionMap( | 607 CreateStrictModeFunctionMap( |
| 601 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); | 608 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); |
| 602 | 609 |
| 603 // Create the ThrowTypeError function instances. | 610 // Create the ThrowTypeError function instances. |
| 604 Handle<JSFunction> arguments_throw = | 611 Handle<JSFunction> arguments_throw = |
| 605 CreateThrowTypeErrorFunction(Builtins::kStrictFunctionArguments); | 612 CreateThrowTypeErrorFunction(Builtins::kStrictFunctionArguments); |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 ? top_context->builtins() | 1239 ? top_context->builtins() |
| 1233 : top_context->global()); | 1240 : top_context->global()); |
| 1234 bool has_pending_exception; | 1241 bool has_pending_exception; |
| 1235 Handle<Object> result = | 1242 Handle<Object> result = |
| 1236 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); | 1243 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); |
| 1237 if (has_pending_exception) return false; | 1244 if (has_pending_exception) return false; |
| 1238 return true; | 1245 return true; |
| 1239 } | 1246 } |
| 1240 | 1247 |
| 1241 | 1248 |
| 1242 #define INSTALL_NATIVE(Type, name, var) \ | 1249 #define INSTALL_NATIVE(Type, name, var) \ |
| 1243 Handle<String> var##_name = factory->LookupAsciiSymbol(name); \ | 1250 Handle<String> var##_name = factory->LookupAsciiSymbol(name); \ |
| 1244 global_context()->set_##var(Type::cast( \ | 1251 Object* var##_native = \ |
| 1245 global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name))); | 1252 global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name); \ |
| 1253 global_context()->set_##var(Type::cast(var##_native)); |
| 1246 | 1254 |
| 1247 | 1255 |
| 1248 void Genesis::InstallNativeFunctions() { | 1256 void Genesis::InstallNativeFunctions() { |
| 1249 Factory* factory = Isolate::Current()->factory(); | 1257 Factory* factory = Isolate::Current()->factory(); |
| 1250 HandleScope scope; | 1258 HandleScope scope; |
| 1251 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); | 1259 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); |
| 1252 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); | 1260 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); |
| 1253 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); | 1261 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); |
| 1254 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); | 1262 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); |
| 1255 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); | 1263 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2121 return from + sizeof(NestingCounterType); | 2129 return from + sizeof(NestingCounterType); |
| 2122 } | 2130 } |
| 2123 | 2131 |
| 2124 | 2132 |
| 2125 // Called when the top-level V8 mutex is destroyed. | 2133 // Called when the top-level V8 mutex is destroyed. |
| 2126 void Bootstrapper::FreeThreadResources() { | 2134 void Bootstrapper::FreeThreadResources() { |
| 2127 ASSERT(!IsActive()); | 2135 ASSERT(!IsActive()); |
| 2128 } | 2136 } |
| 2129 | 2137 |
| 2130 } } // namespace v8::internal | 2138 } } // namespace v8::internal |
| OLD | NEW |