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

Unified Diff: src/bootstrapper.cc

Issue 660095: Merge revision 3813 to 3930 from bleeding_edge to partial snapshots branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: '' Created 10 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/bootstrapper.h ('k') | src/builtins.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
===================================================================
--- src/bootstrapper.cc (revision 3935)
+++ src/bootstrapper.cc (working copy)
@@ -177,116 +177,6 @@
}
-// Pending fixups are code positions that refer to builtin code
-// objects that were not available at the time the code was generated.
-// The pending list is processed whenever an environment has been
-// created.
-class PendingFixups : public AllStatic {
- public:
- static void Add(Code* code, MacroAssembler* masm);
- static bool Process(Handle<JSBuiltinsObject> builtins);
-
- static void Iterate(ObjectVisitor* v);
-
- private:
- static List<Object*> code_;
- static List<const char*> name_;
- static List<int> pc_;
- static List<uint32_t> flags_;
-
- static void Clear();
-};
-
-
-List<Object*> PendingFixups::code_(0);
-List<const char*> PendingFixups::name_(0);
-List<int> PendingFixups::pc_(0);
-List<uint32_t> PendingFixups::flags_(0);
-
-
-void PendingFixups::Add(Code* code, MacroAssembler* masm) {
- // Note this code is not only called during bootstrapping.
- List<MacroAssembler::Unresolved>* unresolved = masm->unresolved();
- int n = unresolved->length();
- for (int i = 0; i < n; i++) {
- const char* name = unresolved->at(i).name;
- code_.Add(code);
- name_.Add(name);
- pc_.Add(unresolved->at(i).pc);
- flags_.Add(unresolved->at(i).flags);
- LOG(StringEvent("unresolved", name));
- }
-}
-
-
-bool PendingFixups::Process(Handle<JSBuiltinsObject> builtins) {
- HandleScope scope;
- // NOTE: Extra fixups may be added to the list during the iteration
- // due to lazy compilation of functions during the processing. Do not
- // cache the result of getting the length of the code list.
- for (int i = 0; i < code_.length(); i++) {
- const char* name = name_[i];
- uint32_t flags = flags_[i];
- Handle<String> symbol = Factory::LookupAsciiSymbol(name);
- Object* o = builtins->GetProperty(*symbol);
-#ifdef DEBUG
- if (!o->IsJSFunction()) {
- V8_Fatal(__FILE__, __LINE__, "Cannot resolve call to builtin %s", name);
- }
-#endif
- Handle<SharedFunctionInfo> shared(JSFunction::cast(o)->shared());
- // Make sure the number of parameters match the formal parameter count.
- int argc = Bootstrapper::FixupFlagsArgumentsCount::decode(flags);
- USE(argc);
- ASSERT(shared->formal_parameter_count() == argc);
- // Do lazy compilation if necessary and check for stack overflows.
- if (!EnsureCompiled(shared, CLEAR_EXCEPTION)) {
- Clear();
- return false;
- }
- Code* code = Code::cast(code_[i]);
- Address pc = code->instruction_start() + pc_[i];
- RelocInfo target(pc, RelocInfo::CODE_TARGET, 0);
- bool use_code_object = Bootstrapper::FixupFlagsUseCodeObject::decode(flags);
- if (use_code_object) {
- target.set_target_object(shared->code());
- } else {
- target.set_target_address(shared->code()->instruction_start());
- }
- LOG(StringEvent("resolved", name));
- }
- Clear();
-
- // TODO(1240818): We should probably try to avoid doing this for all
- // the V8 builtin JS files. It should only happen after running
- // runtime.js - just like there shouldn't be any fixups left after
- // that.
- for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
- Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
- Handle<String> name = Factory::LookupAsciiSymbol(Builtins::GetName(id));
- JSFunction* function = JSFunction::cast(builtins->GetProperty(*name));
- builtins->set_javascript_builtin(id, function);
- }
-
- return true;
-}
-
-
-void PendingFixups::Clear() {
- code_.Clear();
- name_.Clear();
- pc_.Clear();
- flags_.Clear();
-}
-
-
-void PendingFixups::Iterate(ObjectVisitor* v) {
- if (!code_.is_empty()) {
- v->VisitPointers(&code_[0], &code_[0] + code_.length());
- }
-}
-
-
class Genesis BASE_EMBEDDED {
public:
Genesis(Handle<Object> global_object,
@@ -341,6 +231,7 @@
static bool InstallExtension(const char* name);
static bool InstallExtension(v8::RegisteredExtension* current);
static void InstallSpecialObjects(Handle<Context> global_context);
+ bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins);
bool ConfigureApiObject(Handle<JSObject> object,
Handle<ObjectTemplateInfo> object_template);
bool ConfigureGlobalObjects(v8::Handle<v8::ObjectTemplate> global_template);
@@ -385,18 +276,9 @@
void Bootstrapper::Iterate(ObjectVisitor* v) {
extensions_cache.Iterate(v);
v->Synchronize("Extensions");
- PendingFixups::Iterate(v);
- v->Synchronize("PendingFixups");
}
-// While setting up the environment, we collect code positions that
-// need to be patched before we can run any code in the environment.
-void Bootstrapper::AddFixup(Code* code, MacroAssembler* masm) {
- PendingFixups::Add(code, masm);
-}
-
-
Handle<Context> Bootstrapper::CreateEnvironment(
Handle<Object> global_object,
v8::Handle<v8::ObjectTemplate> global_template,
@@ -865,11 +747,11 @@
#ifdef DEBUG
LookupResult lookup;
result->LocalLookup(Heap::callee_symbol(), &lookup);
- ASSERT(lookup.IsValid() && (lookup.type() == FIELD));
+ ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
ASSERT(lookup.GetFieldIndex() == Heap::arguments_callee_index);
result->LocalLookup(Heap::length_symbol(), &lookup);
- ASSERT(lookup.IsValid() && (lookup.type() == FIELD));
+ ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
ASSERT(lookup.GetFieldIndex() == Heap::arguments_length_index);
ASSERT(result->map()->inobject_properties() > Heap::arguments_callee_index);
@@ -977,6 +859,7 @@
0,
extension,
NULL,
+ Handle<String>::null(),
use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE);
if (boilerplate.is_null()) return false;
if (cache != NULL) cache->Add(name, boilerplate);
@@ -1003,8 +886,7 @@
Handle<Object> result =
Execution::Call(fun, receiver, 0, NULL, &has_pending_exception);
if (has_pending_exception) return false;
- return PendingFixups::Process(
- Handle<JSBuiltinsObject>(top_context->builtins()));
+ return true;
}
@@ -1024,7 +906,6 @@
INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun);
INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun);
INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun);
- INSTALL_NATIVE(JSFunction, "ToBoolean", to_boolean_fun);
INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun);
INSTALL_NATIVE(JSFunction, "Instantiate", instantiate_fun);
INSTALL_NATIVE(JSFunction, "ConfigureTemplateInstance",
@@ -1211,6 +1092,10 @@
i++) {
Vector<const char> name = Natives::GetScriptName(i);
if (!CompileBuiltin(i)) return false;
+ // TODO(ager): We really only need to install the JS builtin
+ // functions on the builtins object after compiling and running
+ // runtime.js.
+ if (!InstallJSBuiltins(builtins)) return false;
}
InstallNativeFunctions();
@@ -1411,6 +1296,22 @@
}
+bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
+ HandleScope scope;
+ for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
+ Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
+ Handle<String> name = Factory::LookupAsciiSymbol(Builtins::GetName(id));
+ Handle<JSFunction> function
+ = Handle<JSFunction>(JSFunction::cast(builtins->GetProperty(*name)));
+ builtins->set_javascript_builtin(id, *function);
+ Handle<SharedFunctionInfo> shared
+ = Handle<SharedFunctionInfo>(function->shared());
+ if (!EnsureCompiled(shared, CLEAR_EXCEPTION)) return false;
+ }
+ return true;
+}
+
+
bool Genesis::ConfigureGlobalObjects(
v8::Handle<v8::ObjectTemplate> global_proxy_template) {
Handle<JSObject> global_proxy(
@@ -1485,7 +1386,7 @@
LookupResult result;
to->LocalLookup(descs->GetKey(i), &result);
// If the property is already there we skip it
- if (result.IsValid()) continue;
+ if (result.IsProperty()) continue;
HandleScope inner;
ASSERT(!to->HasFastProperties());
// Add to dictionary.
@@ -1520,7 +1421,7 @@
// If the property is already there we skip it.
LookupResult result;
to->LocalLookup(String::cast(raw_key), &result);
- if (result.IsValid()) continue;
+ if (result.IsProperty()) continue;
// Set the property.
Handle<String> key = Handle<String>(String::cast(raw_key));
Handle<Object> value = Handle<Object>(properties->ValueAt(i));
@@ -1604,25 +1505,33 @@
void Genesis::BuildSpecialFunctionTable() {
HandleScope scope;
Handle<JSObject> global = Handle<JSObject>(global_context()->global());
- // Add special versions for Array.prototype.pop and push.
+ // Add special versions for some Array.prototype functions.
Handle<JSFunction> function =
Handle<JSFunction>(
JSFunction::cast(global->GetProperty(Heap::Array_symbol())));
Handle<JSObject> visible_prototype =
Handle<JSObject>(JSObject::cast(function->prototype()));
- // Remember to put push and pop on the hidden prototype if it's there.
- Handle<JSObject> push_and_pop_prototype;
+ // Remember to put those specializations on the hidden prototype if present.
+ Handle<JSObject> special_prototype;
Handle<Object> superproto(visible_prototype->GetPrototype());
if (superproto->IsJSObject() &&
JSObject::cast(*superproto)->map()->is_hidden_prototype()) {
- push_and_pop_prototype = Handle<JSObject>::cast(superproto);
+ special_prototype = Handle<JSObject>::cast(superproto);
} else {
- push_and_pop_prototype = visible_prototype;
+ special_prototype = visible_prototype;
}
- AddSpecialFunction(push_and_pop_prototype, "pop",
+ AddSpecialFunction(special_prototype, "pop",
Handle<Code>(Builtins::builtin(Builtins::ArrayPop)));
- AddSpecialFunction(push_and_pop_prototype, "push",
+ AddSpecialFunction(special_prototype, "push",
Handle<Code>(Builtins::builtin(Builtins::ArrayPush)));
+ AddSpecialFunction(special_prototype, "shift",
+ Handle<Code>(Builtins::builtin(Builtins::ArrayShift)));
+ AddSpecialFunction(special_prototype, "unshift",
+ Handle<Code>(Builtins::builtin(Builtins::ArrayUnshift)));
+ AddSpecialFunction(special_prototype, "slice",
+ Handle<Code>(Builtins::builtin(Builtins::ArraySlice)));
+ AddSpecialFunction(special_prototype, "splice",
+ Handle<Code>(Builtins::builtin(Builtins::ArraySplice)));
}
« no previous file with comments | « src/bootstrapper.h ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698