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

Side by Side Diff: src/bootstrapper.cc

Issue 1148007: Merge bleeding_edge from version 2.1.3 up to revision 4205... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 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/ast.cc ('k') | src/builtins.h » ('j') | src/heap.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // generate an index for each native JS file. 48 // generate an index for each native JS file.
49 class SourceCodeCache BASE_EMBEDDED { 49 class SourceCodeCache BASE_EMBEDDED {
50 public: 50 public:
51 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } 51 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { }
52 52
53 void Initialize(bool create_heap_objects) { 53 void Initialize(bool create_heap_objects) {
54 cache_ = create_heap_objects ? Heap::empty_fixed_array() : NULL; 54 cache_ = create_heap_objects ? Heap::empty_fixed_array() : NULL;
55 } 55 }
56 56
57 void Iterate(ObjectVisitor* v) { 57 void Iterate(ObjectVisitor* v) {
58 v->VisitPointer(bit_cast<Object**, FixedArray**>(&cache_)); 58 v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_));
59 } 59 }
60 60
61 61
62 bool Lookup(Vector<const char> name, Handle<JSFunction>* handle) { 62 bool Lookup(Vector<const char> name, Handle<JSFunction>* handle) {
63 for (int i = 0; i < cache_->length(); i+=2) { 63 for (int i = 0; i < cache_->length(); i+=2) {
64 SeqAsciiString* str = SeqAsciiString::cast(cache_->get(i)); 64 SeqAsciiString* str = SeqAsciiString::cast(cache_->get(i));
65 if (str->IsEqualTo(name)) { 65 if (str->IsEqualTo(name)) {
66 *handle = Handle<JSFunction>(JSFunction::cast(cache_->get(i + 1))); 66 *handle = Handle<JSFunction>(JSFunction::cast(cache_->get(i + 1)));
67 return true; 67 return true;
68 } 68 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // 'from'. 245 // 'from'.
246 void TransferObject(Handle<JSObject> from, Handle<JSObject> to); 246 void TransferObject(Handle<JSObject> from, Handle<JSObject> to);
247 void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to); 247 void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to);
248 void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to); 248 void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to);
249 249
250 Handle<DescriptorArray> ComputeFunctionInstanceDescriptor( 250 Handle<DescriptorArray> ComputeFunctionInstanceDescriptor(
251 bool make_prototype_read_only, 251 bool make_prototype_read_only,
252 bool make_prototype_enumerable = false); 252 bool make_prototype_enumerable = false);
253 void MakeFunctionInstancePrototypeWritable(); 253 void MakeFunctionInstancePrototypeWritable();
254 254
255 void AddSpecialFunction(Handle<JSObject> prototype,
256 const char* name,
257 Handle<Code> code);
258
259 void BuildSpecialFunctionTable();
260
261 static bool CompileBuiltin(int index); 255 static bool CompileBuiltin(int index);
262 static bool CompileNative(Vector<const char> name, Handle<String> source); 256 static bool CompileNative(Vector<const char> name, Handle<String> source);
263 static bool CompileScriptCached(Vector<const char> name, 257 static bool CompileScriptCached(Vector<const char> name,
264 Handle<String> source, 258 Handle<String> source,
265 SourceCodeCache* cache, 259 SourceCodeCache* cache,
266 v8::Extension* extension, 260 v8::Extension* extension,
267 Handle<Context> top_context, 261 Handle<Context> top_context,
268 bool use_runtime_context); 262 bool use_runtime_context);
269 263
270 Handle<Context> result_; 264 Handle<Context> result_;
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 // Setup the call-as-constructor delegate. 811 // Setup the call-as-constructor delegate.
818 Handle<Code> code = 812 Handle<Code> code =
819 Handle<Code>(Builtins::builtin(Builtins::HandleApiCallAsConstructor)); 813 Handle<Code>(Builtins::builtin(Builtins::HandleApiCallAsConstructor));
820 Handle<JSFunction> delegate = 814 Handle<JSFunction> delegate =
821 Factory::NewFunction(Factory::empty_symbol(), JS_OBJECT_TYPE, 815 Factory::NewFunction(Factory::empty_symbol(), JS_OBJECT_TYPE,
822 JSObject::kHeaderSize, code, true); 816 JSObject::kHeaderSize, code, true);
823 global_context()->set_call_as_constructor_delegate(*delegate); 817 global_context()->set_call_as_constructor_delegate(*delegate);
824 delegate->shared()->DontAdaptArguments(); 818 delegate->shared()->DontAdaptArguments();
825 } 819 }
826 820
827 global_context()->set_special_function_table(Heap::empty_fixed_array());
828
829 // Initialize the out of memory slot. 821 // Initialize the out of memory slot.
830 global_context()->set_out_of_memory(Heap::false_value()); 822 global_context()->set_out_of_memory(Heap::false_value());
831 823
832 // Initialize the data slot. 824 // Initialize the data slot.
833 global_context()->set_data(Heap::undefined_value()); 825 global_context()->set_data(Heap::undefined_value());
834 } 826 }
835 827
836 828
837 bool Genesis::CompileBuiltin(int index) { 829 bool Genesis::CompileBuiltin(int index) {
838 Vector<const char> name = Natives::GetScriptName(index); 830 Vector<const char> name = Natives::GetScriptName(index);
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 HandleScope scope; 1483 HandleScope scope;
1492 1484
1493 Handle<DescriptorArray> function_map_descriptors = 1485 Handle<DescriptorArray> function_map_descriptors =
1494 ComputeFunctionInstanceDescriptor(false); 1486 ComputeFunctionInstanceDescriptor(false);
1495 Handle<Map> fm = Factory::CopyMapDropDescriptors(Top::function_map()); 1487 Handle<Map> fm = Factory::CopyMapDropDescriptors(Top::function_map());
1496 fm->set_instance_descriptors(*function_map_descriptors); 1488 fm->set_instance_descriptors(*function_map_descriptors);
1497 Top::context()->global_context()->set_function_map(*fm); 1489 Top::context()->global_context()->set_function_map(*fm);
1498 } 1490 }
1499 1491
1500 1492
1501 void Genesis::AddSpecialFunction(Handle<JSObject> prototype,
1502 const char* name,
1503 Handle<Code> code) {
1504 Handle<String> key = Factory::LookupAsciiSymbol(name);
1505 Handle<Object> value = Handle<Object>(prototype->GetProperty(*key));
1506 if (value->IsJSFunction()) {
1507 Handle<JSFunction> optimized = Factory::NewFunction(key,
1508 JS_OBJECT_TYPE,
1509 JSObject::kHeaderSize,
1510 code,
1511 false);
1512 optimized->shared()->DontAdaptArguments();
1513 int len = global_context()->special_function_table()->length();
1514 Handle<FixedArray> new_array = Factory::NewFixedArray(len + 3);
1515 for (int index = 0; index < len; index++) {
1516 new_array->set(index,
1517 global_context()->special_function_table()->get(index));
1518 }
1519 new_array->set(len+0, *prototype);
1520 new_array->set(len+1, *value);
1521 new_array->set(len+2, *optimized);
1522 global_context()->set_special_function_table(*new_array);
1523 }
1524 }
1525
1526
1527 void Genesis::BuildSpecialFunctionTable() {
1528 HandleScope scope;
1529 Handle<JSObject> global = Handle<JSObject>(global_context()->global());
1530 // Add special versions for some Array.prototype functions.
1531 Handle<JSFunction> function =
1532 Handle<JSFunction>(
1533 JSFunction::cast(global->GetProperty(Heap::Array_symbol())));
1534 Handle<JSObject> visible_prototype =
1535 Handle<JSObject>(JSObject::cast(function->prototype()));
1536 // Remember to put those specializations on the hidden prototype if present.
1537 Handle<JSObject> special_prototype;
1538 Handle<Object> superproto(visible_prototype->GetPrototype());
1539 if (superproto->IsJSObject() &&
1540 JSObject::cast(*superproto)->map()->is_hidden_prototype()) {
1541 special_prototype = Handle<JSObject>::cast(superproto);
1542 } else {
1543 special_prototype = visible_prototype;
1544 }
1545 AddSpecialFunction(special_prototype, "pop",
1546 Handle<Code>(Builtins::builtin(Builtins::ArrayPop)));
1547 AddSpecialFunction(special_prototype, "push",
1548 Handle<Code>(Builtins::builtin(Builtins::ArrayPush)));
1549 AddSpecialFunction(special_prototype, "shift",
1550 Handle<Code>(Builtins::builtin(Builtins::ArrayShift)));
1551 AddSpecialFunction(special_prototype, "unshift",
1552 Handle<Code>(Builtins::builtin(Builtins::ArrayUnshift)));
1553 AddSpecialFunction(special_prototype, "slice",
1554 Handle<Code>(Builtins::builtin(Builtins::ArraySlice)));
1555 AddSpecialFunction(special_prototype, "splice",
1556 Handle<Code>(Builtins::builtin(Builtins::ArraySplice)));
1557 }
1558
1559
1560 Genesis::Genesis(Handle<Object> global_object, 1493 Genesis::Genesis(Handle<Object> global_object,
1561 v8::Handle<v8::ObjectTemplate> global_template, 1494 v8::Handle<v8::ObjectTemplate> global_template,
1562 v8::ExtensionConfiguration* extensions) { 1495 v8::ExtensionConfiguration* extensions) {
1563 result_ = Handle<Context>::null(); 1496 result_ = Handle<Context>::null();
1564 // If V8 isn't running and cannot be initialized, just return. 1497 // If V8 isn't running and cannot be initialized, just return.
1565 if (!V8::IsRunning() && !V8::Initialize(NULL)) return; 1498 if (!V8::IsRunning() && !V8::Initialize(NULL)) return;
1566 1499
1567 // Before creating the roots we must save the context and restore it 1500 // Before creating the roots we must save the context and restore it
1568 // on all function exits. 1501 // on all function exits.
1569 HandleScope scope; 1502 HandleScope scope;
(...skipping 24 matching lines...) Expand all
1594 CreateRoots(); 1527 CreateRoots();
1595 Handle<JSFunction> empty_function = CreateEmptyFunction(); 1528 Handle<JSFunction> empty_function = CreateEmptyFunction();
1596 Handle<GlobalObject> inner_global; 1529 Handle<GlobalObject> inner_global;
1597 Handle<JSGlobalProxy> global_proxy = 1530 Handle<JSGlobalProxy> global_proxy =
1598 CreateNewGlobals(global_template, global_object, &inner_global); 1531 CreateNewGlobals(global_template, global_object, &inner_global);
1599 HookUpGlobalProxy(inner_global, global_proxy); 1532 HookUpGlobalProxy(inner_global, global_proxy);
1600 InitializeGlobal(inner_global, empty_function); 1533 InitializeGlobal(inner_global, empty_function);
1601 if (!InstallNatives()) return; 1534 if (!InstallNatives()) return;
1602 1535
1603 MakeFunctionInstancePrototypeWritable(); 1536 MakeFunctionInstancePrototypeWritable();
1604 BuildSpecialFunctionTable();
1605 1537
1606 if (!ConfigureGlobalObjects(global_template)) return; 1538 if (!ConfigureGlobalObjects(global_template)) return;
1607 i::Counters::contexts_created_from_scratch.Increment(); 1539 i::Counters::contexts_created_from_scratch.Increment();
1608 } 1540 }
1609 1541
1610 result_ = global_context_; 1542 result_ = global_context_;
1611 } 1543 }
1612 1544
1613 1545
1614 // Support for thread preemption. 1546 // Support for thread preemption.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 } 1583 }
1652 1584
1653 1585
1654 // Restore statics that are thread local. 1586 // Restore statics that are thread local.
1655 char* BootstrapperActive::RestoreState(char* from) { 1587 char* BootstrapperActive::RestoreState(char* from) {
1656 nesting_ = *reinterpret_cast<int*>(from); 1588 nesting_ = *reinterpret_cast<int*>(from);
1657 return from + sizeof(nesting_); 1589 return from + sizeof(nesting_);
1658 } 1590 }
1659 1591
1660 } } // namespace v8::internal 1592 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/builtins.h » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698