| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if (is_ecma_native) { | 346 if (is_ecma_native) { |
| 347 function->shared()->set_instance_class_name(*symbol); | 347 function->shared()->set_instance_class_name(*symbol); |
| 348 } | 348 } |
| 349 return function; | 349 return function; |
| 350 } | 350 } |
| 351 | 351 |
| 352 | 352 |
| 353 Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( | 353 Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( |
| 354 PrototypePropertyMode prototypeMode) { | 354 PrototypePropertyMode prototypeMode) { |
| 355 Handle<DescriptorArray> descriptors = | 355 Handle<DescriptorArray> descriptors = |
| 356 factory()->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5)
; | 356 factory()->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE |
| 357 ? 4 |
| 358 : 5); |
| 357 PropertyAttributes attributes = | 359 PropertyAttributes attributes = |
| 358 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 360 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 359 | 361 |
| 360 { // Add length. | 362 { // Add length. |
| 361 Handle<Proxy> proxy = factory()->NewProxy(&Accessors::FunctionLength); | 363 Handle<Proxy> proxy = factory()->NewProxy(&Accessors::FunctionLength); |
| 362 CallbacksDescriptor d(*factory()->length_symbol(), *proxy, attributes); | 364 CallbacksDescriptor d(*factory()->length_symbol(), *proxy, attributes); |
| 363 descriptors->Set(0, &d); | 365 descriptors->Set(0, &d); |
| 364 } | 366 } |
| 365 { // Add name. | 367 { // Add name. |
| 366 Handle<Proxy> proxy = factory()->NewProxy(&Accessors::FunctionName); | 368 Handle<Proxy> proxy = factory()->NewProxy(&Accessors::FunctionName); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 empty_function->set_map(*empty_fm); | 493 empty_function->set_map(*empty_fm); |
| 492 return empty_function; | 494 return empty_function; |
| 493 } | 495 } |
| 494 | 496 |
| 495 | 497 |
| 496 Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( | 498 Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( |
| 497 PrototypePropertyMode prototypeMode, | 499 PrototypePropertyMode prototypeMode, |
| 498 Handle<FixedArray> arguments, | 500 Handle<FixedArray> arguments, |
| 499 Handle<FixedArray> caller) { | 501 Handle<FixedArray> caller) { |
| 500 Handle<DescriptorArray> descriptors = | 502 Handle<DescriptorArray> descriptors = |
| 501 factory()->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5)
; | 503 factory()->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE |
| 504 ? 4 |
| 505 : 5); |
| 502 PropertyAttributes attributes = static_cast<PropertyAttributes>( | 506 PropertyAttributes attributes = static_cast<PropertyAttributes>( |
| 503 DONT_ENUM | DONT_DELETE | READ_ONLY); | 507 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 504 | 508 |
| 505 { // length | 509 { // length |
| 506 Handle<Proxy> proxy = factory()->NewProxy(&Accessors::FunctionLength); | 510 Handle<Proxy> proxy = factory()->NewProxy(&Accessors::FunctionLength); |
| 507 CallbacksDescriptor d(*factory()->length_symbol(), *proxy, attributes); | 511 CallbacksDescriptor d(*factory()->length_symbol(), *proxy, attributes); |
| 508 descriptors->Set(0, &d); | 512 descriptors->Set(0, &d); |
| 509 } | 513 } |
| 510 { // name | 514 { // name |
| 511 Handle<Proxy> proxy = factory()->NewProxy(&Accessors::FunctionName); | 515 Handle<Proxy> proxy = factory()->NewProxy(&Accessors::FunctionName); |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 ? top_context->builtins() | 1242 ? top_context->builtins() |
| 1239 : top_context->global()); | 1243 : top_context->global()); |
| 1240 bool has_pending_exception; | 1244 bool has_pending_exception; |
| 1241 Handle<Object> result = | 1245 Handle<Object> result = |
| 1242 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); | 1246 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); |
| 1243 if (has_pending_exception) return false; | 1247 if (has_pending_exception) return false; |
| 1244 return true; | 1248 return true; |
| 1245 } | 1249 } |
| 1246 | 1250 |
| 1247 | 1251 |
| 1248 #define INSTALL_NATIVE(Type, name, var) \ | 1252 #define INSTALL_NATIVE(Type, name, var) \ |
| 1249 Handle<String> var##_name = factory()->LookupAsciiSymbol(name);
\ | 1253 Handle<String> var##_name = factory()->LookupAsciiSymbol(name); \ |
| 1250 Object* var##_native = \ | 1254 Object* var##_native = \ |
| 1251 global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name); \ | 1255 global_context()->builtins()->GetPropertyNoExceptionThrown( \ |
| 1256 *var##_name); \ |
| 1252 global_context()->set_##var(Type::cast(var##_native)); | 1257 global_context()->set_##var(Type::cast(var##_native)); |
| 1253 | 1258 |
| 1254 | 1259 |
| 1255 void Genesis::InstallNativeFunctions() { | 1260 void Genesis::InstallNativeFunctions() { |
| 1256 HandleScope scope; | 1261 HandleScope scope; |
| 1257 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); | 1262 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); |
| 1258 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); | 1263 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); |
| 1259 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); | 1264 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); |
| 1260 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); | 1265 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); |
| 1261 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); | 1266 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 1309 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
| 1305 Handle<String> global_symbol = factory()->LookupAsciiSymbol("global"); | 1310 Handle<String> global_symbol = factory()->LookupAsciiSymbol("global"); |
| 1306 Handle<Object> global_obj(global_context()->global()); | 1311 Handle<Object> global_obj(global_context()->global()); |
| 1307 SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes); | 1312 SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes); |
| 1308 | 1313 |
| 1309 // Setup the reference from the global object to the builtins object. | 1314 // Setup the reference from the global object to the builtins object. |
| 1310 JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); | 1315 JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); |
| 1311 | 1316 |
| 1312 // Create a bridge function that has context in the global context. | 1317 // Create a bridge function that has context in the global context. |
| 1313 Handle<JSFunction> bridge = | 1318 Handle<JSFunction> bridge = |
| 1314 factory()->NewFunction(factory()->empty_symbol(), | 1319 factory()->NewFunction(factory()->empty_symbol(), |
| 1315 factory()->undefined_value()); | 1320 factory()->undefined_value()); |
| 1316 ASSERT(bridge->context() == *isolate()->global_context()); | 1321 ASSERT(bridge->context() == *isolate()->global_context()); |
| 1317 | 1322 |
| 1318 // Allocate the builtins context. | 1323 // Allocate the builtins context. |
| 1319 Handle<Context> context = | 1324 Handle<Context> context = |
| 1320 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); | 1325 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); |
| 1321 context->set_global(*builtins); // override builtins global object | 1326 context->set_global(*builtins); // override builtins global object |
| 1322 | 1327 |
| 1323 global_context()->set_runtime_context(*context); | 1328 global_context()->set_runtime_context(*context); |
| 1324 | 1329 |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 return from + sizeof(NestingCounterType); | 2134 return from + sizeof(NestingCounterType); |
| 2130 } | 2135 } |
| 2131 | 2136 |
| 2132 | 2137 |
| 2133 // Called when the top-level V8 mutex is destroyed. | 2138 // Called when the top-level V8 mutex is destroyed. |
| 2134 void Bootstrapper::FreeThreadResources() { | 2139 void Bootstrapper::FreeThreadResources() { |
| 2135 ASSERT(!IsActive()); | 2140 ASSERT(!IsActive()); |
| 2136 } | 2141 } |
| 2137 | 2142 |
| 2138 } } // namespace v8::internal | 2143 } } // namespace v8::internal |
| OLD | NEW |