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

Side by Side Diff: src/bootstrapper.cc

Issue 239243018: Heap::AllocateStringFromOneByte() and major part of its callers handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comment + some cleanup Created 6 years, 8 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 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); 486 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
487 Handle<JSFunction> empty_function = 487 Handle<JSFunction> empty_function =
488 factory->NewFunctionWithoutPrototype(empty_string, SLOPPY); 488 factory->NewFunctionWithoutPrototype(empty_string, SLOPPY);
489 489
490 // --- E m p t y --- 490 // --- E m p t y ---
491 Handle<Code> code = 491 Handle<Code> code =
492 Handle<Code>(isolate->builtins()->builtin( 492 Handle<Code>(isolate->builtins()->builtin(
493 Builtins::kEmptyFunction)); 493 Builtins::kEmptyFunction));
494 empty_function->set_code(*code); 494 empty_function->set_code(*code);
495 empty_function->shared()->set_code(*code); 495 empty_function->shared()->set_code(*code);
496 Handle<String> source = 496 Handle<String> source = factory->NewStringFromStaticAscii("() {}");
497 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}"));
498 Handle<Script> script = factory->NewScript(source); 497 Handle<Script> script = factory->NewScript(source);
499 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 498 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
500 empty_function->shared()->set_script(*script); 499 empty_function->shared()->set_script(*script);
501 empty_function->shared()->set_start_position(0); 500 empty_function->shared()->set_start_position(0);
502 empty_function->shared()->set_end_position(source->length()); 501 empty_function->shared()->set_end_position(source->length());
503 empty_function->shared()->DontAdaptArguments(); 502 empty_function->shared()->DontAdaptArguments();
504 503
505 // Set prototypes for the function maps. 504 // Set prototypes for the function maps.
506 native_context()->sloppy_function_map()->set_prototype(*empty_function); 505 native_context()->sloppy_function_map()->set_prototype(*empty_function);
507 native_context()->sloppy_function_without_prototype_map()-> 506 native_context()->sloppy_function_without_prototype_map()->
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 Vector<const char> name = Natives::GetScriptName(index); 1396 Vector<const char> name = Natives::GetScriptName(index);
1398 Handle<String> source_code = 1397 Handle<String> source_code =
1399 isolate->bootstrapper()->NativesSourceLookup(index); 1398 isolate->bootstrapper()->NativesSourceLookup(index);
1400 return CompileNative(isolate, name, source_code); 1399 return CompileNative(isolate, name, source_code);
1401 } 1400 }
1402 1401
1403 1402
1404 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { 1403 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) {
1405 Vector<const char> name = ExperimentalNatives::GetScriptName(index); 1404 Vector<const char> name = ExperimentalNatives::GetScriptName(index);
1406 Factory* factory = isolate->factory(); 1405 Factory* factory = isolate->factory();
1407 Handle<String> source_code = 1406 Handle<String> source_code;
1407 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
1408 isolate, source_code,
1408 factory->NewStringFromAscii( 1409 factory->NewStringFromAscii(
1409 ExperimentalNatives::GetRawScriptSource(index)); 1410 ExperimentalNatives::GetRawScriptSource(index)),
1410 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, source_code, false); 1411 false);
1411 return CompileNative(isolate, name, source_code); 1412 return CompileNative(isolate, name, source_code);
1412 } 1413 }
1413 1414
1414 1415
1415 bool Genesis::CompileNative(Isolate* isolate, 1416 bool Genesis::CompileNative(Isolate* isolate,
1416 Vector<const char> name, 1417 Vector<const char> name,
1417 Handle<String> source) { 1418 Handle<String> source) {
1418 HandleScope scope(isolate); 1419 HandleScope scope(isolate);
1419 #ifdef ENABLE_DEBUGGER_SUPPORT 1420 #ifdef ENABLE_DEBUGGER_SUPPORT
1420 isolate->debugger()->set_compiling_natives(true); 1421 isolate->debugger()->set_compiling_natives(true);
(...skipping 28 matching lines...) Expand all
1449 Handle<Context> top_context, 1450 Handle<Context> top_context,
1450 bool use_runtime_context) { 1451 bool use_runtime_context) {
1451 Factory* factory = isolate->factory(); 1452 Factory* factory = isolate->factory();
1452 HandleScope scope(isolate); 1453 HandleScope scope(isolate);
1453 Handle<SharedFunctionInfo> function_info; 1454 Handle<SharedFunctionInfo> function_info;
1454 1455
1455 // If we can't find the function in the cache, we compile a new 1456 // If we can't find the function in the cache, we compile a new
1456 // function and insert it into the cache. 1457 // function and insert it into the cache.
1457 if (cache == NULL || !cache->Lookup(name, &function_info)) { 1458 if (cache == NULL || !cache->Lookup(name, &function_info)) {
1458 ASSERT(source->IsOneByteRepresentation()); 1459 ASSERT(source->IsOneByteRepresentation());
1459 Handle<String> script_name = factory->NewStringFromUtf8(name); 1460 Handle<String> script_name =
1460 ASSERT(!script_name.is_null()); 1461 factory->NewStringFromUtf8(name).ToHandleChecked();
1461 function_info = Compiler::CompileScript( 1462 function_info = Compiler::CompileScript(
1462 source, 1463 source,
1463 script_name, 1464 script_name,
1464 0, 1465 0,
1465 0, 1466 0,
1466 false, 1467 false,
1467 top_context, 1468 top_context,
1468 extension, 1469 extension,
1469 NULL, 1470 NULL,
1470 NO_CACHED_DATA, 1471 NO_CACHED_DATA,
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 return from + sizeof(NestingCounterType); 2666 return from + sizeof(NestingCounterType);
2666 } 2667 }
2667 2668
2668 2669
2669 // Called when the top-level V8 mutex is destroyed. 2670 // Called when the top-level V8 mutex is destroyed.
2670 void Bootstrapper::FreeThreadResources() { 2671 void Bootstrapper::FreeThreadResources() {
2671 ASSERT(!IsActive()); 2672 ASSERT(!IsActive());
2672 } 2673 }
2673 2674
2674 } } // namespace v8::internal 2675 } } // 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