OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 Heap* heap = isolate_->heap(); | 81 Heap* heap = isolate_->heap(); |
82 if (heap->natives_source_cache()->get(index)->IsUndefined()) { | 82 if (heap->natives_source_cache()->get(index)->IsUndefined()) { |
83 // We can use external strings for the natives. | 83 // We can use external strings for the natives. |
84 Vector<const char> source = Natives::GetRawScriptSource(index); | 84 Vector<const char> source = Natives::GetRawScriptSource(index); |
85 NativesExternalStringResource* resource = | 85 NativesExternalStringResource* resource = |
86 new NativesExternalStringResource(this, | 86 new NativesExternalStringResource(this, |
87 source.start(), | 87 source.start(), |
88 source.length()); | 88 source.length()); |
89 Handle<String> source_code = | 89 Handle<String> source_code = |
90 isolate_->factory()->NewExternalStringFromAscii(resource); | 90 isolate_->factory()->NewExternalStringFromAscii(resource); |
| 91 // We do not expect this to throw an exception. Change this if it does. |
| 92 CHECK_NOT_EMPTY_HANDLE(isolate_, source_code); |
91 heap->natives_source_cache()->set(index, *source_code); | 93 heap->natives_source_cache()->set(index, *source_code); |
92 } | 94 } |
93 Handle<Object> cached_source(heap->natives_source_cache()->get(index), | 95 Handle<Object> cached_source(heap->natives_source_cache()->get(index), |
94 isolate_); | 96 isolate_); |
95 return Handle<String>::cast(cached_source); | 97 return Handle<String>::cast(cached_source); |
96 } | 98 } |
97 | 99 |
98 | 100 |
99 void Bootstrapper::Initialize(bool create_heap_objects) { | 101 void Bootstrapper::Initialize(bool create_heap_objects) { |
100 extensions_cache_.Initialize(isolate_, create_heap_objects); | 102 extensions_cache_.Initialize(isolate_, create_heap_objects); |
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 return CompileNative(isolate, name, source_code); | 1457 return CompileNative(isolate, name, source_code); |
1456 } | 1458 } |
1457 | 1459 |
1458 | 1460 |
1459 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { | 1461 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { |
1460 Vector<const char> name = ExperimentalNatives::GetScriptName(index); | 1462 Vector<const char> name = ExperimentalNatives::GetScriptName(index); |
1461 Factory* factory = isolate->factory(); | 1463 Factory* factory = isolate->factory(); |
1462 Handle<String> source_code = | 1464 Handle<String> source_code = |
1463 factory->NewStringFromAscii( | 1465 factory->NewStringFromAscii( |
1464 ExperimentalNatives::GetRawScriptSource(index)); | 1466 ExperimentalNatives::GetRawScriptSource(index)); |
| 1467 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, source_code, false); |
1465 return CompileNative(isolate, name, source_code); | 1468 return CompileNative(isolate, name, source_code); |
1466 } | 1469 } |
1467 | 1470 |
1468 | 1471 |
1469 bool Genesis::CompileNative(Isolate* isolate, | 1472 bool Genesis::CompileNative(Isolate* isolate, |
1470 Vector<const char> name, | 1473 Vector<const char> name, |
1471 Handle<String> source) { | 1474 Handle<String> source) { |
1472 HandleScope scope(isolate); | 1475 HandleScope scope(isolate); |
1473 #ifdef ENABLE_DEBUGGER_SUPPORT | 1476 #ifdef ENABLE_DEBUGGER_SUPPORT |
1474 isolate->debugger()->set_compiling_natives(true); | 1477 isolate->debugger()->set_compiling_natives(true); |
(...skipping 29 matching lines...) Expand all Loading... |
1504 bool use_runtime_context) { | 1507 bool use_runtime_context) { |
1505 Factory* factory = isolate->factory(); | 1508 Factory* factory = isolate->factory(); |
1506 HandleScope scope(isolate); | 1509 HandleScope scope(isolate); |
1507 Handle<SharedFunctionInfo> function_info; | 1510 Handle<SharedFunctionInfo> function_info; |
1508 | 1511 |
1509 // If we can't find the function in the cache, we compile a new | 1512 // If we can't find the function in the cache, we compile a new |
1510 // function and insert it into the cache. | 1513 // function and insert it into the cache. |
1511 if (cache == NULL || !cache->Lookup(name, &function_info)) { | 1514 if (cache == NULL || !cache->Lookup(name, &function_info)) { |
1512 ASSERT(source->IsOneByteRepresentation()); | 1515 ASSERT(source->IsOneByteRepresentation()); |
1513 Handle<String> script_name = factory->NewStringFromUtf8(name); | 1516 Handle<String> script_name = factory->NewStringFromUtf8(name); |
| 1517 ASSERT(!script_name.is_null()); |
1514 function_info = Compiler::CompileScript( | 1518 function_info = Compiler::CompileScript( |
1515 source, | 1519 source, |
1516 script_name, | 1520 script_name, |
1517 0, | 1521 0, |
1518 0, | 1522 0, |
1519 false, | 1523 false, |
1520 top_context, | 1524 top_context, |
1521 extension, | 1525 extension, |
1522 NULL, | 1526 NULL, |
1523 NO_CACHED_DATA, | 1527 NO_CACHED_DATA, |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 Factory* factory = isolate->factory(); | 2075 Factory* factory = isolate->factory(); |
2072 Handle<GlobalObject> global(native_context->global_object()); | 2076 Handle<GlobalObject> global(native_context->global_object()); |
2073 const char* period_pos = strchr(holder_expr, '.'); | 2077 const char* period_pos = strchr(holder_expr, '.'); |
2074 if (period_pos == NULL) { | 2078 if (period_pos == NULL) { |
2075 return Handle<JSObject>::cast(GetProperty( | 2079 return Handle<JSObject>::cast(GetProperty( |
2076 isolate, global, factory->InternalizeUtf8String(holder_expr))); | 2080 isolate, global, factory->InternalizeUtf8String(holder_expr))); |
2077 } | 2081 } |
2078 ASSERT_EQ(".prototype", period_pos); | 2082 ASSERT_EQ(".prototype", period_pos); |
2079 Vector<const char> property(holder_expr, | 2083 Vector<const char> property(holder_expr, |
2080 static_cast<int>(period_pos - holder_expr)); | 2084 static_cast<int>(period_pos - holder_expr)); |
| 2085 Handle<String> property_string = factory->InternalizeUtf8String(property); |
| 2086 ASSERT(!property_string.is_null()); |
2081 Handle<JSFunction> function = Handle<JSFunction>::cast( | 2087 Handle<JSFunction> function = Handle<JSFunction>::cast( |
2082 GetProperty(isolate, global, factory->InternalizeUtf8String(property))); | 2088 GetProperty(isolate, global, property_string)); |
2083 return Handle<JSObject>(JSObject::cast(function->prototype())); | 2089 return Handle<JSObject>(JSObject::cast(function->prototype())); |
2084 } | 2090 } |
2085 | 2091 |
2086 | 2092 |
2087 static void InstallBuiltinFunctionId(Handle<JSObject> holder, | 2093 static void InstallBuiltinFunctionId(Handle<JSObject> holder, |
2088 const char* function_name, | 2094 const char* function_name, |
2089 BuiltinFunctionId id) { | 2095 BuiltinFunctionId id) { |
2090 Factory* factory = holder->GetIsolate()->factory(); | 2096 Factory* factory = holder->GetIsolate()->factory(); |
2091 Handle<String> name = factory->InternalizeUtf8String(function_name); | 2097 Handle<String> name = factory->InternalizeUtf8String(function_name); |
2092 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked(); | 2098 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked(); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2340 // Install the extension's dependencies | 2346 // Install the extension's dependencies |
2341 for (int i = 0; i < extension->dependency_count(); i++) { | 2347 for (int i = 0; i < extension->dependency_count(); i++) { |
2342 if (!InstallExtension(isolate, | 2348 if (!InstallExtension(isolate, |
2343 extension->dependencies()[i], | 2349 extension->dependencies()[i], |
2344 extension_states)) { | 2350 extension_states)) { |
2345 return false; | 2351 return false; |
2346 } | 2352 } |
2347 } | 2353 } |
2348 Handle<String> source_code = | 2354 Handle<String> source_code = |
2349 isolate->factory()->NewExternalStringFromAscii(extension->source()); | 2355 isolate->factory()->NewExternalStringFromAscii(extension->source()); |
| 2356 // We do not expect this to throw an exception. Change this if it does. |
| 2357 CHECK_NOT_EMPTY_HANDLE(isolate, source_code); |
2350 bool result = CompileScriptCached(isolate, | 2358 bool result = CompileScriptCached(isolate, |
2351 CStrVector(extension->name()), | 2359 CStrVector(extension->name()), |
2352 source_code, | 2360 source_code, |
2353 isolate->bootstrapper()->extensions_cache(), | 2361 isolate->bootstrapper()->extensions_cache(), |
2354 extension, | 2362 extension, |
2355 Handle<Context>(isolate->context()), | 2363 Handle<Context>(isolate->context()), |
2356 false); | 2364 false); |
2357 ASSERT(isolate->has_pending_exception() != result); | 2365 ASSERT(isolate->has_pending_exception() != result); |
2358 if (!result) { | 2366 if (!result) { |
2359 // We print out the name of the extension that fail to install. | 2367 // We print out the name of the extension that fail to install. |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 return from + sizeof(NestingCounterType); | 2753 return from + sizeof(NestingCounterType); |
2746 } | 2754 } |
2747 | 2755 |
2748 | 2756 |
2749 // Called when the top-level V8 mutex is destroyed. | 2757 // Called when the top-level V8 mutex is destroyed. |
2750 void Bootstrapper::FreeThreadResources() { | 2758 void Bootstrapper::FreeThreadResources() { |
2751 ASSERT(!IsActive()); | 2759 ASSERT(!IsActive()); |
2752 } | 2760 } |
2753 | 2761 |
2754 } } // namespace v8::internal | 2762 } } // namespace v8::internal |
OLD | NEW |