Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: src/bootstrapper.cc

Issue 210143002: Revert "No longer OOM on invalid string length." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/bootstrapper.h ('k') | src/contexts.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
93 heap->natives_source_cache()->set(index, *source_code); 91 heap->natives_source_cache()->set(index, *source_code);
94 } 92 }
95 Handle<Object> cached_source(heap->natives_source_cache()->get(index), 93 Handle<Object> cached_source(heap->natives_source_cache()->get(index),
96 isolate_); 94 isolate_);
97 return Handle<String>::cast(cached_source); 95 return Handle<String>::cast(cached_source);
98 } 96 }
99 97
100 98
101 void Bootstrapper::Initialize(bool create_heap_objects) { 99 void Bootstrapper::Initialize(bool create_heap_objects) {
102 extensions_cache_.Initialize(isolate_, create_heap_objects); 100 extensions_cache_.Initialize(isolate_, create_heap_objects);
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 return CompileNative(isolate, name, source_code); 1456 return CompileNative(isolate, name, source_code);
1459 } 1457 }
1460 1458
1461 1459
1462 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { 1460 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) {
1463 Vector<const char> name = ExperimentalNatives::GetScriptName(index); 1461 Vector<const char> name = ExperimentalNatives::GetScriptName(index);
1464 Factory* factory = isolate->factory(); 1462 Factory* factory = isolate->factory();
1465 Handle<String> source_code = 1463 Handle<String> source_code =
1466 factory->NewStringFromAscii( 1464 factory->NewStringFromAscii(
1467 ExperimentalNatives::GetRawScriptSource(index)); 1465 ExperimentalNatives::GetRawScriptSource(index));
1468 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, source_code, false);
1469 return CompileNative(isolate, name, source_code); 1466 return CompileNative(isolate, name, source_code);
1470 } 1467 }
1471 1468
1472 1469
1473 bool Genesis::CompileNative(Isolate* isolate, 1470 bool Genesis::CompileNative(Isolate* isolate,
1474 Vector<const char> name, 1471 Vector<const char> name,
1475 Handle<String> source) { 1472 Handle<String> source) {
1476 HandleScope scope(isolate); 1473 HandleScope scope(isolate);
1477 #ifdef ENABLE_DEBUGGER_SUPPORT 1474 #ifdef ENABLE_DEBUGGER_SUPPORT
1478 isolate->debugger()->set_compiling_natives(true); 1475 isolate->debugger()->set_compiling_natives(true);
(...skipping 29 matching lines...) Expand all
1508 bool use_runtime_context) { 1505 bool use_runtime_context) {
1509 Factory* factory = isolate->factory(); 1506 Factory* factory = isolate->factory();
1510 HandleScope scope(isolate); 1507 HandleScope scope(isolate);
1511 Handle<SharedFunctionInfo> function_info; 1508 Handle<SharedFunctionInfo> function_info;
1512 1509
1513 // If we can't find the function in the cache, we compile a new 1510 // If we can't find the function in the cache, we compile a new
1514 // function and insert it into the cache. 1511 // function and insert it into the cache.
1515 if (cache == NULL || !cache->Lookup(name, &function_info)) { 1512 if (cache == NULL || !cache->Lookup(name, &function_info)) {
1516 ASSERT(source->IsOneByteRepresentation()); 1513 ASSERT(source->IsOneByteRepresentation());
1517 Handle<String> script_name = factory->NewStringFromUtf8(name); 1514 Handle<String> script_name = factory->NewStringFromUtf8(name);
1518 ASSERT(!script_name.is_null());
1519 function_info = Compiler::CompileScript( 1515 function_info = Compiler::CompileScript(
1520 source, 1516 source,
1521 script_name, 1517 script_name,
1522 0, 1518 0,
1523 0, 1519 0,
1524 false, 1520 false,
1525 top_context, 1521 top_context,
1526 extension, 1522 extension,
1527 NULL, 1523 NULL,
1528 NO_CACHED_DATA, 1524 NO_CACHED_DATA,
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 Factory* factory = isolate->factory(); 2073 Factory* factory = isolate->factory();
2078 Handle<GlobalObject> global(native_context->global_object()); 2074 Handle<GlobalObject> global(native_context->global_object());
2079 const char* period_pos = strchr(holder_expr, '.'); 2075 const char* period_pos = strchr(holder_expr, '.');
2080 if (period_pos == NULL) { 2076 if (period_pos == NULL) {
2081 return Handle<JSObject>::cast(GetProperty( 2077 return Handle<JSObject>::cast(GetProperty(
2082 isolate, global, factory->InternalizeUtf8String(holder_expr))); 2078 isolate, global, factory->InternalizeUtf8String(holder_expr)));
2083 } 2079 }
2084 ASSERT_EQ(".prototype", period_pos); 2080 ASSERT_EQ(".prototype", period_pos);
2085 Vector<const char> property(holder_expr, 2081 Vector<const char> property(holder_expr,
2086 static_cast<int>(period_pos - holder_expr)); 2082 static_cast<int>(period_pos - holder_expr));
2087 Handle<String> property_string = factory->InternalizeUtf8String(property);
2088 ASSERT(!property_string.is_null());
2089 Handle<JSFunction> function = Handle<JSFunction>::cast( 2083 Handle<JSFunction> function = Handle<JSFunction>::cast(
2090 GetProperty(isolate, global, property_string)); 2084 GetProperty(isolate, global, factory->InternalizeUtf8String(property)));
2091 return Handle<JSObject>(JSObject::cast(function->prototype())); 2085 return Handle<JSObject>(JSObject::cast(function->prototype()));
2092 } 2086 }
2093 2087
2094 2088
2095 static void InstallBuiltinFunctionId(Handle<JSObject> holder, 2089 static void InstallBuiltinFunctionId(Handle<JSObject> holder,
2096 const char* function_name, 2090 const char* function_name,
2097 BuiltinFunctionId id) { 2091 BuiltinFunctionId id) {
2098 Factory* factory = holder->GetIsolate()->factory(); 2092 Factory* factory = holder->GetIsolate()->factory();
2099 Handle<String> name = factory->InternalizeUtf8String(function_name); 2093 Handle<String> name = factory->InternalizeUtf8String(function_name);
2100 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked(); 2094 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked();
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 // Install the extension's dependencies 2342 // Install the extension's dependencies
2349 for (int i = 0; i < extension->dependency_count(); i++) { 2343 for (int i = 0; i < extension->dependency_count(); i++) {
2350 if (!InstallExtension(isolate, 2344 if (!InstallExtension(isolate,
2351 extension->dependencies()[i], 2345 extension->dependencies()[i],
2352 extension_states)) { 2346 extension_states)) {
2353 return false; 2347 return false;
2354 } 2348 }
2355 } 2349 }
2356 Handle<String> source_code = 2350 Handle<String> source_code =
2357 isolate->factory()->NewExternalStringFromAscii(extension->source()); 2351 isolate->factory()->NewExternalStringFromAscii(extension->source());
2358 // We do not expect this to throw an exception. Change this if it does.
2359 CHECK_NOT_EMPTY_HANDLE(isolate, source_code);
2360 bool result = CompileScriptCached(isolate, 2352 bool result = CompileScriptCached(isolate,
2361 CStrVector(extension->name()), 2353 CStrVector(extension->name()),
2362 source_code, 2354 source_code,
2363 isolate->bootstrapper()->extensions_cache(), 2355 isolate->bootstrapper()->extensions_cache(),
2364 extension, 2356 extension,
2365 Handle<Context>(isolate->context()), 2357 Handle<Context>(isolate->context()),
2366 false); 2358 false);
2367 ASSERT(isolate->has_pending_exception() != result); 2359 ASSERT(isolate->has_pending_exception() != result);
2368 if (!result) { 2360 if (!result) {
2369 // We print out the name of the extension that fail to install. 2361 // We print out the name of the extension that fail to install.
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 return from + sizeof(NestingCounterType); 2747 return from + sizeof(NestingCounterType);
2756 } 2748 }
2757 2749
2758 2750
2759 // Called when the top-level V8 mutex is destroyed. 2751 // Called when the top-level V8 mutex is destroyed.
2760 void Bootstrapper::FreeThreadResources() { 2752 void Bootstrapper::FreeThreadResources() {
2761 ASSERT(!IsActive()); 2753 ASSERT(!IsActive());
2762 } 2754 }
2763 2755
2764 } } // namespace v8::internal 2756 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/contexts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698