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

Side by Side Diff: runtime/vm/stub_code.cc

Issue 600243002: Patchable AllocateArray stub, like instance allocation stubs. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 | « runtime/vm/stub_code.h ('k') | runtime/vm/stub_code_arm.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/stub_code.h" 5 #include "vm/stub_code.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "platform/globals.h" 8 #include "platform/globals.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/disassembler.h" 10 #include "vm/disassembler.h"
11 #include "vm/flags.h" 11 #include "vm/flags.h"
12 #include "vm/object_store.h"
12 #include "vm/virtual_memory.h" 13 #include "vm/virtual_memory.h"
13 #include "vm/visitor.h" 14 #include "vm/visitor.h"
14 15
15 namespace dart { 16 namespace dart {
16 17
17 DEFINE_FLAG(bool, disassemble_stubs, false, "Disassemble generated stubs."); 18 DEFINE_FLAG(bool, disassemble_stubs, false, "Disassemble generated stubs.");
18 19
19 #define STUB_CODE_DECLARE(name) \ 20 #define STUB_CODE_DECLARE(name) \
20 StubEntry* StubCode::name##_entry_ = NULL; 21 StubEntry* StubCode::name##_entry_ = NULL;
21 VM_STUB_CODE_LIST(STUB_CODE_DECLARE); 22 VM_STUB_CODE_LIST(STUB_CODE_DECLARE);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void StubCode::GenerateFor(Isolate* init) { 61 void StubCode::GenerateFor(Isolate* init) {
61 // Generate all the stubs. 62 // Generate all the stubs.
62 Code& code = Code::Handle(); 63 Code& code = Code::Handle();
63 STUB_CODE_LIST(STUB_CODE_GENERATE); 64 STUB_CODE_LIST(STUB_CODE_GENERATE);
64 } 65 }
65 66
66 #undef STUB_CODE_GENERATE 67 #undef STUB_CODE_GENERATE
67 68
68 69
69 void StubCode::Init(Isolate* isolate) { 70 void StubCode::Init(Isolate* isolate) {
70 StubCode* stubs = new StubCode(); 71 StubCode* stubs = new StubCode(isolate);
71 isolate->set_stub_code(stubs); 72 isolate->set_stub_code(stubs);
72 stubs->GenerateFor(isolate); 73 stubs->GenerateFor(isolate);
73 } 74 }
74 75
75 76
76 void StubCode::VisitObjectPointers(ObjectPointerVisitor* visitor) { 77 void StubCode::VisitObjectPointers(ObjectPointerVisitor* visitor) {
77 // The current isolate is needed as part of the macro. 78 // The current isolate is needed as part of the macro.
78 Isolate* isolate = Isolate::Current(); 79 Isolate* isolate = Isolate::Current();
79 StubCode* stubs = isolate->stub_code(); 80 StubCode* stubs = isolate->stub_code();
80 if (stubs == NULL) return; 81 if (stubs == NULL) return;
(...skipping 22 matching lines...) Expand all
103 } 104 }
104 105
105 106
106 bool StubCode::InJumpToExceptionHandlerStub(uword pc) { 107 bool StubCode::InJumpToExceptionHandlerStub(uword pc) {
107 uword entry = StubCode::JumpToExceptionHandlerEntryPoint(); 108 uword entry = StubCode::JumpToExceptionHandlerEntryPoint();
108 uword size = StubCode::JumpToExceptionHandlerSize(); 109 uword size = StubCode::JumpToExceptionHandlerSize();
109 return (pc >= entry) && (pc < (entry + size)); 110 return (pc >= entry) && (pc < (entry + size));
110 } 111 }
111 112
112 113
114 RawCode* StubCode::GetAllocateArrayStub() {
115 const Class& array_cls = Class::Handle(isolate_,
116 isolate_->object_store()->array_class());
117 return GetAllocationStubForClass(array_cls);
118 }
119
120
113 RawCode* StubCode::GetAllocationStubForClass(const Class& cls) { 121 RawCode* StubCode::GetAllocationStubForClass(const Class& cls) {
114 Isolate* isolate = Isolate::Current(); 122 Isolate* isolate = Isolate::Current();
115 const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate)); 123 const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate));
116 ASSERT(error.IsNull()); 124 ASSERT(error.IsNull());
117 Code& stub = Code::Handle(isolate, cls.allocation_stub()); 125 Code& stub = Code::Handle(isolate, cls.allocation_stub());
118 if (stub.IsNull()) { 126 if (stub.IsNull()) {
119 Assembler assembler; 127 Assembler assembler;
120 const char* name = cls.ToCString(); 128 const char* name = cls.ToCString();
121 uword patch_code_offset = 0; 129 uword patch_code_offset = 0;
122 uword entry_patch_offset = 0; 130 uword entry_patch_offset = 0;
123 StubCode::GenerateAllocationStubForClass( 131 if (cls.id() == kArrayCid) {
124 &assembler, cls, &entry_patch_offset, &patch_code_offset); 132 StubCode::GeneratePatchableAllocateArrayStub(
133 &assembler, &entry_patch_offset, &patch_code_offset);
134 } else {
135 StubCode::GenerateAllocationStubForClass(
136 &assembler, cls, &entry_patch_offset, &patch_code_offset);
137 }
125 stub ^= Code::FinalizeCode(name, &assembler); 138 stub ^= Code::FinalizeCode(name, &assembler);
126 stub.set_owner(cls); 139 stub.set_owner(cls);
127 cls.set_allocation_stub(stub); 140 cls.set_allocation_stub(stub);
128 if (FLAG_disassemble_stubs) { 141 if (FLAG_disassemble_stubs) {
129 OS::Print("Code for allocation stub '%s': {\n", name); 142 OS::Print("Code for allocation stub '%s': {\n", name);
130 DisassembleToStdout formatter; 143 DisassembleToStdout formatter;
131 stub.Disassemble(&formatter); 144 stub.Disassemble(&formatter);
132 OS::Print("}\n"); 145 OS::Print("}\n");
133 } 146 }
134 stub.set_entry_patch_pc_offset(entry_patch_offset); 147 stub.set_entry_patch_pc_offset(entry_patch_offset);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 Isolate* isolate = Isolate::Current(); 196 Isolate* isolate = Isolate::Current();
184 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { 197 if ((isolate != NULL) && (isolate->stub_code() != NULL)) {
185 STUB_CODE_LIST(STUB_CODE_TESTER); 198 STUB_CODE_LIST(STUB_CODE_TESTER);
186 } 199 }
187 #undef VM_STUB_CODE_TESTER 200 #undef VM_STUB_CODE_TESTER
188 #undef STUB_CODE_TESTER 201 #undef STUB_CODE_TESTER
189 return NULL; 202 return NULL;
190 } 203 }
191 204
192 } // namespace dart 205 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/stub_code.h ('k') | runtime/vm/stub_code_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698