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

Side by Side Diff: src/bootstrapper.cc

Issue 559913002: Rename ascii to one-byte where applicable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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
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 "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/extensions/externalize-string-extension.h" 9 #include "src/extensions/externalize-string-extension.h"
10 #include "src/extensions/free-buffer-extension.h" 10 #include "src/extensions/free-buffer-extension.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 DCHECK(0 <= index && index < Natives::GetBuiltinsCount()); 47 DCHECK(0 <= index && index < Natives::GetBuiltinsCount());
48 Heap* heap = isolate_->heap(); 48 Heap* heap = isolate_->heap();
49 if (heap->natives_source_cache()->get(index)->IsUndefined()) { 49 if (heap->natives_source_cache()->get(index)->IsUndefined()) {
50 // We can use external strings for the natives. 50 // We can use external strings for the natives.
51 Vector<const char> source = Natives::GetRawScriptSource(index); 51 Vector<const char> source = Natives::GetRawScriptSource(index);
52 NativesExternalStringResource* resource = 52 NativesExternalStringResource* resource =
53 new NativesExternalStringResource(this, 53 new NativesExternalStringResource(this,
54 source.start(), 54 source.start(),
55 source.length()); 55 source.length());
56 // We do not expect this to throw an exception. Change this if it does. 56 // We do not expect this to throw an exception. Change this if it does.
57 Handle<String> source_code = 57 Handle<String> source_code = isolate_->factory()
58 isolate_->factory()->NewExternalStringFromAscii( 58 ->NewExternalStringFromOneByte(resource)
59 resource).ToHandleChecked(); 59 .ToHandleChecked();
60 heap->natives_source_cache()->set(index, *source_code); 60 heap->natives_source_cache()->set(index, *source_code);
61 } 61 }
62 Handle<Object> cached_source(heap->natives_source_cache()->get(index), 62 Handle<Object> cached_source(heap->natives_source_cache()->get(index),
63 isolate_); 63 isolate_);
64 return Handle<String>::cast(cached_source); 64 return Handle<String>::cast(cached_source);
65 } 65 }
66 66
67 67
68 void Bootstrapper::Initialize(bool create_heap_objects) { 68 void Bootstrapper::Initialize(bool create_heap_objects) {
69 extensions_cache_.Initialize(isolate_, create_heap_objects); 69 extensions_cache_.Initialize(isolate_, create_heap_objects);
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // For bootstrapping set the array prototype to be the same as the object 504 // For bootstrapping set the array prototype to be the same as the object
505 // prototype, otherwise the missing initial_array_prototype will cause 505 // prototype, otherwise the missing initial_array_prototype will cause
506 // assertions during startup. 506 // assertions during startup.
507 native_context()->set_initial_array_prototype(*prototype); 507 native_context()->set_initial_array_prototype(*prototype);
508 Accessors::FunctionSetPrototype(object_fun, prototype); 508 Accessors::FunctionSetPrototype(object_fun, prototype);
509 } 509 }
510 510
511 // Allocate the empty function as the prototype for function ECMAScript 511 // Allocate the empty function as the prototype for function ECMAScript
512 // 262 15.3.4. 512 // 262 15.3.4.
513 Handle<String> empty_string = 513 Handle<String> empty_string =
514 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); 514 factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
515 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); 515 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction));
516 Handle<JSFunction> empty_function = factory->NewFunctionWithoutPrototype( 516 Handle<JSFunction> empty_function = factory->NewFunctionWithoutPrototype(
517 empty_string, code); 517 empty_string, code);
518 518
519 // Allocate the function map first and then patch the prototype later 519 // Allocate the function map first and then patch the prototype later
520 Handle<Map> empty_function_map = 520 Handle<Map> empty_function_map =
521 CreateFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); 521 CreateFunctionMap(FUNCTION_WITHOUT_PROTOTYPE);
522 DCHECK(!empty_function_map->is_dictionary_map()); 522 DCHECK(!empty_function_map->is_dictionary_map());
523 empty_function_map->set_prototype( 523 empty_function_map->set_prototype(
524 native_context()->object_function()->prototype()); 524 native_context()->object_function()->prototype());
525 empty_function_map->set_is_prototype_map(true); 525 empty_function_map->set_is_prototype_map(true);
526 empty_function->set_map(*empty_function_map); 526 empty_function->set_map(*empty_function_map);
527 527
528 // --- E m p t y --- 528 // --- E m p t y ---
529 Handle<String> source = factory->NewStringFromStaticAscii("() {}"); 529 Handle<String> source = factory->NewStringFromStaticChars("() {}");
530 Handle<Script> script = factory->NewScript(source); 530 Handle<Script> script = factory->NewScript(source);
531 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 531 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
532 empty_function->shared()->set_script(*script); 532 empty_function->shared()->set_script(*script);
533 empty_function->shared()->set_start_position(0); 533 empty_function->shared()->set_start_position(0);
534 empty_function->shared()->set_end_position(source->length()); 534 empty_function->shared()->set_end_position(source->length());
535 empty_function->shared()->DontAdaptArguments(); 535 empty_function->shared()->DontAdaptArguments();
536 536
537 // Set prototypes for the function maps. 537 // Set prototypes for the function maps.
538 native_context()->sloppy_function_map()->set_prototype(*empty_function); 538 native_context()->sloppy_function_map()->set_prototype(*empty_function);
539 native_context()->sloppy_function_without_prototype_map()-> 539 native_context()->sloppy_function_without_prototype_map()->
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 prototype, attribs); 597 prototype, attribs);
598 map->AppendDescriptor(&d); 598 map->AppendDescriptor(&d);
599 } 599 }
600 } 600 }
601 601
602 602
603 // ECMAScript 5th Edition, 13.2.3 603 // ECMAScript 5th Edition, 13.2.3
604 Handle<JSFunction> Genesis::GetStrictPoisonFunction() { 604 Handle<JSFunction> Genesis::GetStrictPoisonFunction() {
605 if (strict_poison_function.is_null()) { 605 if (strict_poison_function.is_null()) {
606 Handle<String> name = factory()->InternalizeOneByteString( 606 Handle<String> name = factory()->InternalizeOneByteString(
607 STATIC_ASCII_VECTOR("ThrowTypeError")); 607 STATIC_CHAR_VECTOR("ThrowTypeError"));
608 Handle<Code> code(isolate()->builtins()->builtin( 608 Handle<Code> code(isolate()->builtins()->builtin(
609 Builtins::kStrictModePoisonPill)); 609 Builtins::kStrictModePoisonPill));
610 strict_poison_function = factory()->NewFunctionWithoutPrototype(name, code); 610 strict_poison_function = factory()->NewFunctionWithoutPrototype(name, code);
611 strict_poison_function->set_map(native_context()->sloppy_function_map()); 611 strict_poison_function->set_map(native_context()->sloppy_function_map());
612 strict_poison_function->shared()->DontAdaptArguments(); 612 strict_poison_function->shared()->DontAdaptArguments();
613 613
614 JSObject::PreventExtensions(strict_poison_function).Assert(); 614 JSObject::PreventExtensions(strict_poison_function).Assert();
615 } 615 }
616 return strict_poison_function; 616 return strict_poison_function;
617 } 617 }
618 618
619 619
620 Handle<JSFunction> Genesis::GetGeneratorPoisonFunction() { 620 Handle<JSFunction> Genesis::GetGeneratorPoisonFunction() {
621 if (generator_poison_function.is_null()) { 621 if (generator_poison_function.is_null()) {
622 Handle<String> name = factory()->InternalizeOneByteString( 622 Handle<String> name = factory()->InternalizeOneByteString(
623 STATIC_ASCII_VECTOR("ThrowTypeError")); 623 STATIC_CHAR_VECTOR("ThrowTypeError"));
624 Handle<Code> code(isolate()->builtins()->builtin( 624 Handle<Code> code(isolate()->builtins()->builtin(
625 Builtins::kGeneratorPoisonPill)); 625 Builtins::kGeneratorPoisonPill));
626 generator_poison_function = factory()->NewFunctionWithoutPrototype( 626 generator_poison_function = factory()->NewFunctionWithoutPrototype(
627 name, code); 627 name, code);
628 generator_poison_function->set_map(native_context()->sloppy_function_map()); 628 generator_poison_function->set_map(native_context()->sloppy_function_map());
629 generator_poison_function->shared()->DontAdaptArguments(); 629 generator_poison_function->shared()->DontAdaptArguments();
630 630
631 JSObject::PreventExtensions(generator_poison_function).Assert(); 631 JSObject::PreventExtensions(generator_poison_function).Assert();
632 } 632 }
633 return generator_poison_function; 633 return generator_poison_function;
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 1288
1289 { // --- context extension 1289 { // --- context extension
1290 // Create a function for the context extension objects. 1290 // Create a function for the context extension objects.
1291 Handle<Code> code = Handle<Code>( 1291 Handle<Code> code = Handle<Code>(
1292 isolate->builtins()->builtin(Builtins::kIllegal)); 1292 isolate->builtins()->builtin(Builtins::kIllegal));
1293 Handle<JSFunction> context_extension_fun = factory->NewFunction( 1293 Handle<JSFunction> context_extension_fun = factory->NewFunction(
1294 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE, 1294 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE,
1295 JSObject::kHeaderSize); 1295 JSObject::kHeaderSize);
1296 1296
1297 Handle<String> name = factory->InternalizeOneByteString( 1297 Handle<String> name = factory->InternalizeOneByteString(
1298 STATIC_ASCII_VECTOR("context_extension")); 1298 STATIC_CHAR_VECTOR("context_extension"));
1299 context_extension_fun->shared()->set_instance_class_name(*name); 1299 context_extension_fun->shared()->set_instance_class_name(*name);
1300 native_context()->set_context_extension_function(*context_extension_fun); 1300 native_context()->set_context_extension_function(*context_extension_fun);
1301 } 1301 }
1302 1302
1303 1303
1304 { 1304 {
1305 // Set up the call-as-function delegate. 1305 // Set up the call-as-function delegate.
1306 Handle<Code> code = 1306 Handle<Code> code =
1307 Handle<Code>(isolate->builtins()->builtin( 1307 Handle<Code>(isolate->builtins()->builtin(
1308 Builtins::kHandleApiCallAsFunction)); 1308 Builtins::kHandleApiCallAsFunction));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 isolate->bootstrapper()->NativesSourceLookup(index); 1426 isolate->bootstrapper()->NativesSourceLookup(index);
1427 return CompileNative(isolate, name, source_code); 1427 return CompileNative(isolate, name, source_code);
1428 } 1428 }
1429 1429
1430 1430
1431 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { 1431 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) {
1432 Vector<const char> name = ExperimentalNatives::GetScriptName(index); 1432 Vector<const char> name = ExperimentalNatives::GetScriptName(index);
1433 Factory* factory = isolate->factory(); 1433 Factory* factory = isolate->factory();
1434 Handle<String> source_code; 1434 Handle<String> source_code;
1435 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 1435 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
1436 isolate, source_code, 1436 isolate, source_code, factory->NewStringFromAscii(
1437 factory->NewStringFromAscii( 1437 ExperimentalNatives::GetRawScriptSource(index)),
1438 ExperimentalNatives::GetRawScriptSource(index)),
1439 false); 1438 false);
1440 return CompileNative(isolate, name, source_code); 1439 return CompileNative(isolate, name, source_code);
1441 } 1440 }
1442 1441
1443 1442
1444 bool Genesis::CompileNative(Isolate* isolate, 1443 bool Genesis::CompileNative(Isolate* isolate,
1445 Vector<const char> name, 1444 Vector<const char> name,
1446 Handle<String> source) { 1445 Handle<String> source) {
1447 HandleScope scope(isolate); 1446 HandleScope scope(isolate);
1448 SuppressDebug compiling_natives(isolate->debug()); 1447 SuppressDebug compiling_natives(isolate->debug());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 return Handle<JSObject>(JSObject::cast(function->prototype())); 1537 return Handle<JSObject>(JSObject::cast(function->prototype()));
1539 } 1538 }
1540 Handle<String> inner_string = factory->InternalizeUtf8String(inner); 1539 Handle<String> inner_string = factory->InternalizeUtf8String(inner);
1541 DCHECK(!inner_string.is_null()); 1540 DCHECK(!inner_string.is_null());
1542 Handle<Object> value = 1541 Handle<Object> value =
1543 Object::GetProperty(object, inner_string).ToHandleChecked(); 1542 Object::GetProperty(object, inner_string).ToHandleChecked();
1544 return Handle<JSObject>::cast(value); 1543 return Handle<JSObject>::cast(value);
1545 } 1544 }
1546 1545
1547 1546
1548 #define INSTALL_NATIVE(Type, name, var) \ 1547 #define INSTALL_NATIVE(Type, name, var) \
1549 Handle<String> var##_name = \ 1548 Handle<String> var##_name = \
1550 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \ 1549 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR(name)); \
1551 Handle<Object> var##_native = Object::GetProperty( \ 1550 Handle<Object> var##_native = \
1552 handle(native_context()->builtins()), var##_name).ToHandleChecked(); \ 1551 Object::GetProperty(handle(native_context()->builtins()), var##_name) \
1552 .ToHandleChecked(); \
1553 native_context()->set_##var(Type::cast(*var##_native)); 1553 native_context()->set_##var(Type::cast(*var##_native));
1554 1554
1555 #define INSTALL_NATIVE_MATH(name) \ 1555 #define INSTALL_NATIVE_MATH(name) \
1556 { \ 1556 { \
1557 Handle<Object> fun = \ 1557 Handle<Object> fun = \
1558 ResolveBuiltinIdHolder(native_context(), "Math." #name); \ 1558 ResolveBuiltinIdHolder(native_context(), "Math." #name); \
1559 native_context()->set_math_##name##_fun(JSFunction::cast(*fun)); \ 1559 native_context()->set_math_##name##_fun(JSFunction::cast(*fun)); \
1560 } 1560 }
1561 1561
1562 void Genesis::InstallNativeFunctions() { 1562 void Genesis::InstallNativeFunctions() {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 // Create a function for the builtins object. Allocate space for the 1689 // Create a function for the builtins object. Allocate space for the
1690 // JavaScript builtins, a reference to the builtins object 1690 // JavaScript builtins, a reference to the builtins object
1691 // (itself) and a reference to the native_context directly in the object. 1691 // (itself) and a reference to the native_context directly in the object.
1692 Handle<Code> code = Handle<Code>( 1692 Handle<Code> code = Handle<Code>(
1693 isolate()->builtins()->builtin(Builtins::kIllegal)); 1693 isolate()->builtins()->builtin(Builtins::kIllegal));
1694 Handle<JSFunction> builtins_fun = factory()->NewFunction( 1694 Handle<JSFunction> builtins_fun = factory()->NewFunction(
1695 factory()->empty_string(), code, JS_BUILTINS_OBJECT_TYPE, 1695 factory()->empty_string(), code, JS_BUILTINS_OBJECT_TYPE,
1696 JSBuiltinsObject::kSize); 1696 JSBuiltinsObject::kSize);
1697 1697
1698 Handle<String> name = 1698 Handle<String> name =
1699 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); 1699 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("builtins"));
1700 builtins_fun->shared()->set_instance_class_name(*name); 1700 builtins_fun->shared()->set_instance_class_name(*name);
1701 builtins_fun->initial_map()->set_dictionary_map(true); 1701 builtins_fun->initial_map()->set_dictionary_map(true);
1702 builtins_fun->initial_map()->set_prototype(heap()->null_value()); 1702 builtins_fun->initial_map()->set_prototype(heap()->null_value());
1703 1703
1704 // Allocate the builtins object. 1704 // Allocate the builtins object.
1705 Handle<JSBuiltinsObject> builtins = 1705 Handle<JSBuiltinsObject> builtins =
1706 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); 1706 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun));
1707 builtins->set_builtins(*builtins); 1707 builtins->set_builtins(*builtins);
1708 builtins->set_native_context(*native_context()); 1708 builtins->set_native_context(*native_context());
1709 builtins->set_global_context(*native_context()); 1709 builtins->set_global_context(*native_context());
1710 builtins->set_global_proxy(native_context()->global_proxy()); 1710 builtins->set_global_proxy(native_context()->global_proxy());
1711 1711
1712 1712
1713 // Set up the 'global' properties of the builtins object. The 1713 // Set up the 'global' properties of the builtins object. The
1714 // 'global' property that refers to the global object is the only 1714 // 'global' property that refers to the global object is the only
1715 // way to get from code running in the builtins context to the 1715 // way to get from code running in the builtins context to the
1716 // global object. 1716 // global object.
1717 static const PropertyAttributes attributes = 1717 static const PropertyAttributes attributes =
1718 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 1718 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
1719 Handle<String> global_string = 1719 Handle<String> global_string =
1720 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global")); 1720 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("global"));
1721 Handle<Object> global_obj(native_context()->global_object(), isolate()); 1721 Handle<Object> global_obj(native_context()->global_object(), isolate());
1722 JSObject::AddProperty(builtins, global_string, global_obj, attributes); 1722 JSObject::AddProperty(builtins, global_string, global_obj, attributes);
1723 Handle<String> builtins_string = 1723 Handle<String> builtins_string =
1724 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); 1724 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("builtins"));
1725 JSObject::AddProperty(builtins, builtins_string, builtins, attributes); 1725 JSObject::AddProperty(builtins, builtins_string, builtins, attributes);
1726 1726
1727 // Set up the reference from the global object to the builtins object. 1727 // Set up the reference from the global object to the builtins object.
1728 JSGlobalObject::cast(native_context()->global_object())-> 1728 JSGlobalObject::cast(native_context()->global_object())->
1729 set_builtins(*builtins); 1729 set_builtins(*builtins);
1730 1730
1731 // Create a bridge function that has context in the native context. 1731 // Create a bridge function that has context in the native context.
1732 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string()); 1732 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string());
1733 DCHECK(bridge->context() == *isolate()->native_context()); 1733 DCHECK(bridge->context() == *isolate()->native_context());
1734 1734
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 if (isolate->serializer_enabled()) return true; 2198 if (isolate->serializer_enabled()) return true;
2199 2199
2200 Factory* factory = isolate->factory(); 2200 Factory* factory = isolate->factory();
2201 HandleScope scope(isolate); 2201 HandleScope scope(isolate);
2202 Handle<JSGlobalObject> global(JSGlobalObject::cast( 2202 Handle<JSGlobalObject> global(JSGlobalObject::cast(
2203 native_context->global_object())); 2203 native_context->global_object()));
2204 2204
2205 Handle<JSObject> Error = Handle<JSObject>::cast( 2205 Handle<JSObject> Error = Handle<JSObject>::cast(
2206 Object::GetProperty(isolate, global, "Error").ToHandleChecked()); 2206 Object::GetProperty(isolate, global, "Error").ToHandleChecked());
2207 Handle<String> name = 2207 Handle<String> name =
2208 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("stackTraceLimit")); 2208 factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("stackTraceLimit"));
2209 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate); 2209 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate);
2210 JSObject::AddProperty(Error, name, stack_trace_limit, NONE); 2210 JSObject::AddProperty(Error, name, stack_trace_limit, NONE);
2211 2211
2212 // Expose the natives in global if a name for it is specified. 2212 // Expose the natives in global if a name for it is specified.
2213 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { 2213 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
2214 Handle<String> natives = 2214 Handle<String> natives =
2215 factory->InternalizeUtf8String(FLAG_expose_natives_as); 2215 factory->InternalizeUtf8String(FLAG_expose_natives_as);
2216 uint32_t dummy_index; 2216 uint32_t dummy_index;
2217 if (natives->AsArrayIndex(&dummy_index)) return true; 2217 if (natives->AsArrayIndex(&dummy_index)) return true;
2218 JSObject::AddProperty(global, natives, handle(global->builtins()), 2218 JSObject::AddProperty(global, natives, handle(global->builtins()),
2219 DONT_ENUM); 2219 DONT_ENUM);
2220 } 2220 }
2221 2221
2222 // Expose the stack trace symbol to native JS. 2222 // Expose the stack trace symbol to native JS.
2223 RETURN_ON_EXCEPTION_VALUE( 2223 RETURN_ON_EXCEPTION_VALUE(isolate,
2224 isolate, 2224 JSObject::SetOwnPropertyIgnoreAttributes(
2225 JSObject::SetOwnPropertyIgnoreAttributes( 2225 handle(native_context->builtins(), isolate),
2226 handle(native_context->builtins(), isolate), 2226 factory->InternalizeOneByteString(
2227 factory->InternalizeOneByteString( 2227 STATIC_CHAR_VECTOR("stack_trace_symbol")),
2228 STATIC_ASCII_VECTOR("stack_trace_symbol")), 2228 factory->stack_trace_symbol(), NONE),
2229 factory->stack_trace_symbol(), 2229 false);
2230 NONE),
2231 false);
2232 2230
2233 // Expose the debug global object in global if a name for it is specified. 2231 // Expose the debug global object in global if a name for it is specified.
2234 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { 2232 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) {
2235 // If loading fails we just bail out without installing the 2233 // If loading fails we just bail out without installing the
2236 // debugger but without tanking the whole context. 2234 // debugger but without tanking the whole context.
2237 Debug* debug = isolate->debug(); 2235 Debug* debug = isolate->debug();
2238 if (!debug->Load()) return true; 2236 if (!debug->Load()) return true;
2239 Handle<Context> debug_context = debug->debug_context(); 2237 Handle<Context> debug_context = debug->debug_context();
2240 // Set the security token for the debugger context to the same as 2238 // Set the security token for the debugger context to the same as
2241 // the shell native context to allow calling between these (otherwise 2239 // the shell native context to allow calling between these (otherwise
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 // Install the extension's dependencies 2354 // Install the extension's dependencies
2357 for (int i = 0; i < extension->dependency_count(); i++) { 2355 for (int i = 0; i < extension->dependency_count(); i++) {
2358 if (!InstallExtension(isolate, 2356 if (!InstallExtension(isolate,
2359 extension->dependencies()[i], 2357 extension->dependencies()[i],
2360 extension_states)) { 2358 extension_states)) {
2361 return false; 2359 return false;
2362 } 2360 }
2363 } 2361 }
2364 // We do not expect this to throw an exception. Change this if it does. 2362 // We do not expect this to throw an exception. Change this if it does.
2365 Handle<String> source_code = 2363 Handle<String> source_code =
2366 isolate->factory()->NewExternalStringFromAscii( 2364 isolate->factory()
2367 extension->source()).ToHandleChecked(); 2365 ->NewExternalStringFromOneByte(extension->source())
2366 .ToHandleChecked();
2368 bool result = CompileScriptCached(isolate, 2367 bool result = CompileScriptCached(isolate,
2369 CStrVector(extension->name()), 2368 CStrVector(extension->name()),
2370 source_code, 2369 source_code,
2371 isolate->bootstrapper()->extensions_cache(), 2370 isolate->bootstrapper()->extensions_cache(),
2372 extension, 2371 extension,
2373 Handle<Context>(isolate->context()), 2372 Handle<Context>(isolate->context()),
2374 false); 2373 false);
2375 DCHECK(isolate->has_pending_exception() != result); 2374 DCHECK(isolate->has_pending_exception() != result);
2376 if (!result) { 2375 if (!result) {
2377 // We print out the name of the extension that fail to install. 2376 // We print out the name of the extension that fail to install.
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 2673
2675 do { 2674 do {
2676 isolate->random_number_generator()->NextBytes(state, num_bytes); 2675 isolate->random_number_generator()->NextBytes(state, num_bytes);
2677 } while (state[0] == 0 || state[1] == 0); 2676 } while (state[0] == 0 || state[1] == 0);
2678 2677
2679 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New( 2678 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(
2680 reinterpret_cast<v8::Isolate*>(isolate), state, num_bytes); 2679 reinterpret_cast<v8::Isolate*>(isolate), state, num_bytes);
2681 Utils::OpenHandle(*buffer)->set_should_be_freed(true); 2680 Utils::OpenHandle(*buffer)->set_should_be_freed(true);
2682 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); 2681 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems);
2683 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); 2682 Handle<JSBuiltinsObject> builtins(native_context()->builtins());
2684 Runtime::DefineObjectProperty(builtins, 2683 Runtime::DefineObjectProperty(builtins, factory()->InternalizeOneByteString(
2685 factory()->InternalizeOneByteString( 2684 STATIC_CHAR_VECTOR("rngstate")),
2686 STATIC_ASCII_VECTOR("rngstate")), 2685 Utils::OpenHandle(*ta), NONE).Assert();
2687 Utils::OpenHandle(*ta),
2688 NONE).Assert();
2689 2686
2690 // Initialize trigonometric lookup tables and constants. 2687 // Initialize trigonometric lookup tables and constants.
2691 const int constants_size = arraysize(fdlibm::MathConstants::constants); 2688 const int constants_size = arraysize(fdlibm::MathConstants::constants);
2692 const int table_num_bytes = constants_size * kDoubleSize; 2689 const int table_num_bytes = constants_size * kDoubleSize;
2693 v8::Local<v8::ArrayBuffer> trig_buffer = v8::ArrayBuffer::New( 2690 v8::Local<v8::ArrayBuffer> trig_buffer = v8::ArrayBuffer::New(
2694 reinterpret_cast<v8::Isolate*>(isolate), 2691 reinterpret_cast<v8::Isolate*>(isolate),
2695 const_cast<double*>(fdlibm::MathConstants::constants), table_num_bytes); 2692 const_cast<double*>(fdlibm::MathConstants::constants), table_num_bytes);
2696 v8::Local<v8::Float64Array> trig_table = 2693 v8::Local<v8::Float64Array> trig_table =
2697 v8::Float64Array::New(trig_buffer, 0, constants_size); 2694 v8::Float64Array::New(trig_buffer, 0, constants_size);
2698 2695
2699 Runtime::DefineObjectProperty( 2696 Runtime::DefineObjectProperty(
2700 builtins, 2697 builtins,
2701 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("kMath")), 2698 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("kMath")),
2702 Utils::OpenHandle(*trig_table), NONE).Assert(); 2699 Utils::OpenHandle(*trig_table), NONE).Assert();
2703 } 2700 }
2704 2701
2705 result_ = native_context(); 2702 result_ = native_context();
2706 } 2703 }
2707 2704
2708 2705
2709 // Support for thread preemption. 2706 // Support for thread preemption.
2710 2707
2711 // Reserve space for statics needing saving and restoring. 2708 // Reserve space for statics needing saving and restoring.
(...skipping 16 matching lines...) Expand all
2728 return from + sizeof(NestingCounterType); 2725 return from + sizeof(NestingCounterType);
2729 } 2726 }
2730 2727
2731 2728
2732 // Called when the top-level V8 mutex is destroyed. 2729 // Called when the top-level V8 mutex is destroyed.
2733 void Bootstrapper::FreeThreadResources() { 2730 void Bootstrapper::FreeThreadResources() {
2734 DCHECK(!IsActive()); 2731 DCHECK(!IsActive());
2735 } 2732 }
2736 2733
2737 } } // namespace v8::internal 2734 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/contexts.cc » ('j') | src/jsregexp.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698