summaryrefslogtreecommitdiff
path: root/deps/v8/src/code-stubs.cc
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2009-12-19 01:04:19 +0100
committerRyan Dahl <ry@tinyclouds.org>2009-12-19 01:04:19 +0100
commita98afdfb2f05d163b2d4145f2d98c4a7ffd13bfd (patch)
tree7efd649b7aceaab2d4d847ce79c4517fb616afe3 /deps/v8/src/code-stubs.cc
parent0981e7f663c9f6cfbccb49aa2956df499a63e60d (diff)
downloadnode-new-a98afdfb2f05d163b2d4145f2d98c4a7ffd13bfd.tar.gz
Revert "Upgrade V8 to 2.0.5"
This reverts commit 20b945df706b2b9fcbc1a84230372d288d497544. Broken on Hagen's Macintosh. Don't have time to investigate.
Diffstat (limited to 'deps/v8/src/code-stubs.cc')
-rw-r--r--deps/v8/src/code-stubs.cc143
1 files changed, 54 insertions, 89 deletions
diff --git a/deps/v8/src/code-stubs.cc b/deps/v8/src/code-stubs.cc
index 09581aa82a..dbc39ff3bf 100644
--- a/deps/v8/src/code-stubs.cc
+++ b/deps/v8/src/code-stubs.cc
@@ -35,117 +35,82 @@
namespace v8 {
namespace internal {
-bool CodeStub::FindCodeInCache(Code** code_out) {
- if (has_custom_cache()) return GetCustomCache(code_out);
- int index = Heap::code_stubs()->FindEntry(GetKey());
- if (index != NumberDictionary::kNotFound) {
- *code_out = Code::cast(Heap::code_stubs()->ValueAt(index));
- return true;
- }
- return false;
-}
-
-
-void CodeStub::GenerateCode(MacroAssembler* masm) {
- // Update the static counter each time a new code stub is generated.
- Counters::code_stubs.Increment();
- // Nested stubs are not allowed for leafs.
- masm->set_allow_stub_calls(AllowsStubCalls());
- // Generate the code for the stub.
- masm->set_generating_stub(true);
- Generate(masm);
-}
-
-
-void CodeStub::RecordCodeGeneration(Code* code, MacroAssembler* masm) {
- code->set_major_key(MajorKey());
-
- // Add unresolved entries in the code to the fixup list.
- Bootstrapper::AddFixup(code, masm);
-
- LOG(CodeCreateEvent(Logger::STUB_TAG, code, GetName()));
- Counters::total_stubs_code_size.Increment(code->instruction_size());
-
-#ifdef ENABLE_DISASSEMBLER
- if (FLAG_print_code_stubs) {
-#ifdef DEBUG
- Print();
-#endif
- code->Disassemble(GetName());
- PrintF("\n");
+Handle<Code> CodeStub::GetCode() {
+ bool custom_cache = has_custom_cache();
+
+ int index = 0;
+ uint32_t key = 0;
+ if (custom_cache) {
+ Code* cached;
+ if (GetCustomCache(&cached)) {
+ return Handle<Code>(cached);
+ } else {
+ index = NumberDictionary::kNotFound;
+ }
+ } else {
+ key = GetKey();
+ index = Heap::code_stubs()->FindEntry(key);
+ if (index != NumberDictionary::kNotFound)
+ return Handle<Code>(Code::cast(Heap::code_stubs()->ValueAt(index)));
}
-#endif
-}
-
-Handle<Code> CodeStub::GetCode() {
- Code* code;
- if (!FindCodeInCache(&code)) {
+ Code* result;
+ {
v8::HandleScope scope;
+ // Update the static counter each time a new code stub is generated.
+ Counters::code_stubs.Increment();
+
// Generate the new code.
MacroAssembler masm(NULL, 256);
- GenerateCode(&masm);
+
+ // Nested stubs are not allowed for leafs.
+ masm.set_allow_stub_calls(AllowsStubCalls());
+
+ // Generate the code for the stub.
+ masm.set_generating_stub(true);
+ Generate(&masm);
// Create the code object.
CodeDesc desc;
masm.GetCode(&desc);
- // Copy the generated code into a heap object.
+ // Copy the generated code into a heap object, and store the major key.
Code::Flags flags = Code::ComputeFlags(Code::STUB, InLoop());
- Handle<Code> new_object =
- Factory::NewCode(desc, NULL, flags, masm.CodeObject());
- RecordCodeGeneration(*new_object, &masm);
+ Handle<Code> code = Factory::NewCode(desc, NULL, flags, masm.CodeObject());
+ code->set_major_key(MajorKey());
- if (has_custom_cache()) {
- SetCustomCache(*new_object);
+ // Add unresolved entries in the code to the fixup list.
+ Bootstrapper::AddFixup(*code, &masm);
+
+ LOG(CodeCreateEvent(Logger::STUB_TAG, *code, GetName()));
+ Counters::total_stubs_code_size.Increment(code->instruction_size());
+
+#ifdef ENABLE_DISASSEMBLER
+ if (FLAG_print_code_stubs) {
+#ifdef DEBUG
+ Print();
+#endif
+ code->Disassemble(GetName());
+ PrintF("\n");
+ }
+#endif
+
+ if (custom_cache) {
+ SetCustomCache(*code);
} else {
// Update the dictionary and the root in Heap.
Handle<NumberDictionary> dict =
Factory::DictionaryAtNumberPut(
Handle<NumberDictionary>(Heap::code_stubs()),
- GetKey(),
- new_object);
+ key,
+ code);
Heap::public_set_code_stubs(*dict);
}
- code = *new_object;
- }
-
- return Handle<Code>(code);
-}
-
-
-Object* CodeStub::TryGetCode() {
- Code* code;
- if (!FindCodeInCache(&code)) {
- // Generate the new code.
- MacroAssembler masm(NULL, 256);
- GenerateCode(&masm);
-
- // Create the code object.
- CodeDesc desc;
- masm.GetCode(&desc);
-
- // Try to copy the generated code into a heap object.
- Code::Flags flags = Code::ComputeFlags(Code::STUB, InLoop());
- Object* new_object =
- Heap::CreateCode(desc, NULL, flags, masm.CodeObject());
- if (new_object->IsFailure()) return new_object;
- code = Code::cast(new_object);
- RecordCodeGeneration(code, &masm);
-
- if (has_custom_cache()) {
- SetCustomCache(code);
- } else {
- // Try to update the code cache but do not fail if unable.
- new_object = Heap::code_stubs()->AtNumberPut(GetKey(), code);
- if (!new_object->IsFailure()) {
- Heap::public_set_code_stubs(NumberDictionary::cast(new_object));
- }
- }
+ result = *code;
}
- return code;
+ return Handle<Code>(result);
}