| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bootstrapper.h" | 5 #include "bootstrapper.h" |
| 6 | 6 |
| 7 #include "accessors.h" | 7 #include "accessors.h" |
| 8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
| 9 #include "natives.h" | 9 #include "natives.h" |
| 10 #include "snapshot.h" | 10 #include "snapshot.h" |
| (...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 ExperimentalNatives::GetRawScriptSource(index)), | 1428 ExperimentalNatives::GetRawScriptSource(index)), |
| 1429 false); | 1429 false); |
| 1430 return CompileNative(isolate, name, source_code); | 1430 return CompileNative(isolate, name, source_code); |
| 1431 } | 1431 } |
| 1432 | 1432 |
| 1433 | 1433 |
| 1434 bool Genesis::CompileNative(Isolate* isolate, | 1434 bool Genesis::CompileNative(Isolate* isolate, |
| 1435 Vector<const char> name, | 1435 Vector<const char> name, |
| 1436 Handle<String> source) { | 1436 Handle<String> source) { |
| 1437 HandleScope scope(isolate); | 1437 HandleScope scope(isolate); |
| 1438 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 1439 isolate->debugger()->set_compiling_natives(true); | 1438 isolate->debugger()->set_compiling_natives(true); |
| 1440 #endif | |
| 1441 // During genesis, the boilerplate for stack overflow won't work until the | 1439 // During genesis, the boilerplate for stack overflow won't work until the |
| 1442 // environment has been at least partially initialized. Add a stack check | 1440 // environment has been at least partially initialized. Add a stack check |
| 1443 // before entering JS code to catch overflow early. | 1441 // before entering JS code to catch overflow early. |
| 1444 StackLimitCheck check(isolate); | 1442 StackLimitCheck check(isolate); |
| 1445 if (check.HasOverflowed()) return false; | 1443 if (check.HasOverflowed()) return false; |
| 1446 | 1444 |
| 1447 bool result = CompileScriptCached(isolate, | 1445 bool result = CompileScriptCached(isolate, |
| 1448 name, | 1446 name, |
| 1449 source, | 1447 source, |
| 1450 NULL, | 1448 NULL, |
| 1451 NULL, | 1449 NULL, |
| 1452 Handle<Context>(isolate->context()), | 1450 Handle<Context>(isolate->context()), |
| 1453 true); | 1451 true); |
| 1454 ASSERT(isolate->has_pending_exception() != result); | 1452 ASSERT(isolate->has_pending_exception() != result); |
| 1455 if (!result) isolate->clear_pending_exception(); | 1453 if (!result) isolate->clear_pending_exception(); |
| 1456 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 1457 isolate->debugger()->set_compiling_natives(false); | 1454 isolate->debugger()->set_compiling_natives(false); |
| 1458 #endif | |
| 1459 return result; | 1455 return result; |
| 1460 } | 1456 } |
| 1461 | 1457 |
| 1462 | 1458 |
| 1463 bool Genesis::CompileScriptCached(Isolate* isolate, | 1459 bool Genesis::CompileScriptCached(Isolate* isolate, |
| 1464 Vector<const char> name, | 1460 Vector<const char> name, |
| 1465 Handle<String> source, | 1461 Handle<String> source, |
| 1466 SourceCodeCache* cache, | 1462 SourceCodeCache* cache, |
| 1467 v8::Extension* extension, | 1463 v8::Extension* extension, |
| 1468 Handle<Context> top_context, | 1464 Handle<Context> top_context, |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 STATIC_ASCII_VECTOR("stackTraceLimit")); | 2136 STATIC_ASCII_VECTOR("stackTraceLimit")); |
| 2141 Handle<Smi> stack_trace_limit( | 2137 Handle<Smi> stack_trace_limit( |
| 2142 Smi::FromInt(FLAG_stack_trace_limit), isolate); | 2138 Smi::FromInt(FLAG_stack_trace_limit), isolate); |
| 2143 RETURN_ON_EXCEPTION_VALUE( | 2139 RETURN_ON_EXCEPTION_VALUE( |
| 2144 isolate, | 2140 isolate, |
| 2145 JSObject::SetLocalPropertyIgnoreAttributes( | 2141 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2146 Handle<JSObject>::cast(Error), name, stack_trace_limit, NONE), | 2142 Handle<JSObject>::cast(Error), name, stack_trace_limit, NONE), |
| 2147 false); | 2143 false); |
| 2148 } | 2144 } |
| 2149 | 2145 |
| 2150 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 2151 // Expose the debug global object in global if a name for it is specified. | 2146 // Expose the debug global object in global if a name for it is specified. |
| 2152 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { | 2147 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { |
| 2153 Debug* debug = isolate->debug(); | 2148 Debug* debug = isolate->debug(); |
| 2154 // If loading fails we just bail out without installing the | 2149 // If loading fails we just bail out without installing the |
| 2155 // debugger but without tanking the whole context. | 2150 // debugger but without tanking the whole context. |
| 2156 if (!debug->Load()) return true; | 2151 if (!debug->Load()) return true; |
| 2157 // Set the security token for the debugger context to the same as | 2152 // Set the security token for the debugger context to the same as |
| 2158 // the shell native context to allow calling between these (otherwise | 2153 // the shell native context to allow calling between these (otherwise |
| 2159 // exposing debug global object doesn't make much sense). | 2154 // exposing debug global object doesn't make much sense). |
| 2160 debug->debug_context()->set_security_token( | 2155 debug->debug_context()->set_security_token( |
| 2161 native_context->security_token()); | 2156 native_context->security_token()); |
| 2162 | 2157 |
| 2163 Handle<String> debug_string = | 2158 Handle<String> debug_string = |
| 2164 factory->InternalizeUtf8String(FLAG_expose_debug_as); | 2159 factory->InternalizeUtf8String(FLAG_expose_debug_as); |
| 2165 Handle<Object> global_proxy( | 2160 Handle<Object> global_proxy( |
| 2166 debug->debug_context()->global_proxy(), isolate); | 2161 debug->debug_context()->global_proxy(), isolate); |
| 2167 RETURN_ON_EXCEPTION_VALUE( | 2162 RETURN_ON_EXCEPTION_VALUE( |
| 2168 isolate, | 2163 isolate, |
| 2169 JSObject::SetLocalPropertyIgnoreAttributes( | 2164 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2170 global, debug_string, global_proxy, DONT_ENUM), | 2165 global, debug_string, global_proxy, DONT_ENUM), |
| 2171 false); | 2166 false); |
| 2172 } | 2167 } |
| 2173 #endif | |
| 2174 return true; | 2168 return true; |
| 2175 } | 2169 } |
| 2176 | 2170 |
| 2177 | 2171 |
| 2178 static uint32_t Hash(RegisteredExtension* extension) { | 2172 static uint32_t Hash(RegisteredExtension* extension) { |
| 2179 return v8::internal::ComputePointerHash(extension); | 2173 return v8::internal::ComputePointerHash(extension); |
| 2180 } | 2174 } |
| 2181 | 2175 |
| 2182 | 2176 |
| 2183 Genesis::ExtensionStates::ExtensionStates() : map_(HashMap::PointersMatch, 8) {} | 2177 Genesis::ExtensionStates::ExtensionStates() : map_(HashMap::PointersMatch, 8) {} |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2683 return from + sizeof(NestingCounterType); | 2677 return from + sizeof(NestingCounterType); |
| 2684 } | 2678 } |
| 2685 | 2679 |
| 2686 | 2680 |
| 2687 // Called when the top-level V8 mutex is destroyed. | 2681 // Called when the top-level V8 mutex is destroyed. |
| 2688 void Bootstrapper::FreeThreadResources() { | 2682 void Bootstrapper::FreeThreadResources() { |
| 2689 ASSERT(!IsActive()); | 2683 ASSERT(!IsActive()); |
| 2690 } | 2684 } |
| 2691 | 2685 |
| 2692 } } // namespace v8::internal | 2686 } } // namespace v8::internal |
| OLD | NEW |