Skip to content

Commit 93aae5c

Browse files
Unbreak samples and tools.
Removed a related TODO in d8.cc on the way. BUG=v8::3318 LOG=y [email protected] Review URL: https://codereview.chromium.org/275463002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21195 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
1 parent 66abee2 commit 93aae5c

File tree

6 files changed

+28
-23
lines changed

6 files changed

+28
-23
lines changed

samples/lineprocessor.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ void DispatchDebugMessages() {
133133

134134
int RunMain(int argc, char* argv[]) {
135135
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
136-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
136+
v8::Isolate* isolate = v8::Isolate::New();
137+
v8::Isolate::Scope isolate_scope(isolate);
138+
v8::Locker locker(isolate);
137139
v8::HandleScope handle_scope(isolate);
138140

139141
v8::Handle<v8::String> script_source;
@@ -212,8 +214,6 @@ int RunMain(int argc, char* argv[]) {
212214

213215
debug_message_context.Reset(isolate, context);
214216

215-
v8::Locker locker(isolate);
216-
217217
if (support_callback) {
218218
v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true);
219219
}

samples/process.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,8 @@ int main(int argc, char* argv[]) {
651651
fprintf(stderr, "No script was specified.\n");
652652
return 1;
653653
}
654-
Isolate* isolate = Isolate::GetCurrent();
654+
Isolate* isolate = Isolate::New();
655+
Isolate::Scope isolate_scope(isolate);
655656
HandleScope scope(isolate);
656657
Handle<String> source = ReadFile(isolate, file);
657658
if (source.IsEmpty()) {

samples/shell.cc

+15-3
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,35 @@ void ReportException(v8::Isolate* isolate, v8::TryCatch* handler);
6565
static bool run_shell;
6666

6767

68+
class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
69+
public:
70+
virtual void* Allocate(size_t length) {
71+
return memset(AllocateUninitialized(length), 0, length);
72+
}
73+
virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
74+
virtual void Free(void* data, size_t) { free(data); }
75+
};
76+
77+
6878
int main(int argc, char* argv[]) {
6979
v8::V8::InitializeICU();
7080
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
71-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
81+
ShellArrayBufferAllocator array_buffer_allocator;
82+
v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
83+
v8::Isolate* isolate = v8::Isolate::New();
7284
run_shell = (argc == 1);
7385
int result;
7486
{
87+
v8::Isolate::Scope isolate_scope(isolate);
7588
v8::HandleScope handle_scope(isolate);
7689
v8::Handle<v8::Context> context = CreateShellContext(isolate);
7790
if (context.IsEmpty()) {
7891
fprintf(stderr, "Error creating context\n");
7992
return 1;
8093
}
81-
context->Enter();
94+
v8::Context::Scope context_scope(context);
8295
result = RunMain(isolate, argc, argv);
8396
if (run_shell) RunShell(context);
84-
context->Exit();
8597
}
8698
v8::V8::Dispose();
8799
return result;

src/d8.cc

+2-12
Original file line numberDiff line numberDiff line change
@@ -1612,20 +1612,10 @@ static void DumpHeapConstants(i::Isolate* isolate) {
16121612
class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
16131613
public:
16141614
virtual void* Allocate(size_t length) {
1615-
void* result = malloc(length);
1616-
memset(result, 0, length);
1617-
return result;
1618-
}
1619-
virtual void* AllocateUninitialized(size_t length) {
1620-
return malloc(length);
1615+
return memset(AllocateUninitialized(length), 0, length);
16211616
}
1617+
virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
16221618
virtual void Free(void* data, size_t) { free(data); }
1623-
// TODO(dslomov): Remove when v8:2823 is fixed.
1624-
virtual void Free(void* data) {
1625-
#ifndef V8_SHARED
1626-
UNREACHABLE();
1627-
#endif
1628-
}
16291619
};
16301620

16311621

tools/lexer-shell.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,20 @@ int main(int argc, char* argv[]) {
206206
fnames.push_back(std::string(argv[i]));
207207
}
208208
}
209-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
209+
v8::Isolate* isolate = v8::Isolate::New();
210210
{
211+
v8::Isolate::Scope isolate_scope(isolate);
211212
v8::HandleScope handle_scope(isolate);
212213
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
213214
v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
214215
ASSERT(!context.IsEmpty());
215216
{
216217
v8::Context::Scope scope(context);
217-
Isolate* isolate = Isolate::Current();
218218
double baseline_total = 0;
219219
for (size_t i = 0; i < fnames.size(); i++) {
220220
TimeDelta time;
221-
time = ProcessFile(fnames[i].c_str(), encoding, isolate, print_tokens,
221+
time = ProcessFile(fnames[i].c_str(), encoding,
222+
reinterpret_cast<Isolate*>(isolate), print_tokens,
222223
repeat);
223224
baseline_total += time.InMillisecondsF();
224225
}

tools/parser-shell.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ int main(int argc, char* argv[]) {
128128
fnames.push_back(std::string(argv[i]));
129129
}
130130
}
131-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
131+
v8::Isolate* isolate = v8::Isolate::New();
132132
{
133+
v8::Isolate::Scope isolate_scope(isolate);
133134
v8::HandleScope handle_scope(isolate);
134135
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
135136
v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);

0 commit comments

Comments
 (0)