Commit 8330176f authored by yangguo@chromium.org's avatar yangguo@chromium.org

ported --isolate option to d8 and refactored to group together option parsing

TEST=tools/test.py -j15 --shell d8 --isolates

Review URL: http://codereview.chromium.org/7318002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8588 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cbaf1bc9
This diff is collapsed.
......@@ -112,6 +112,87 @@ class CounterMap {
};
class SourceGroup {
public:
SourceGroup()
: next_semaphore_(v8::internal::OS::CreateSemaphore(0)),
done_semaphore_(v8::internal::OS::CreateSemaphore(0)),
thread_(NULL),
argv_(NULL),
begin_offset_(0),
end_offset_(0) { }
void Begin(char** argv, int offset) {
argv_ = const_cast<const char**>(argv);
begin_offset_ = offset;
}
void End(int offset) { end_offset_ = offset; }
void Execute();
void StartExecuteInThread();
void WaitForThread();
private:
class IsolateThread : public i::Thread {
public:
explicit IsolateThread(SourceGroup* group)
: i::Thread(GetThreadOptions()), group_(group) {}
virtual void Run() {
group_->ExecuteInThread();
}
private:
SourceGroup* group_;
};
static i::Thread::Options GetThreadOptions();
void ExecuteInThread();
i::Semaphore* next_semaphore_;
i::Semaphore* done_semaphore_;
i::Thread* thread_;
void ExitShell(int exit_code);
Handle<String> ReadFile(const char* name);
const char** argv_;
int begin_offset_;
int end_offset_;
};
class ShellOptions {
public:
ShellOptions()
: script_executed(false),
last_run(true),
stress_opt(false),
stress_deopt(false),
interactive_shell(false),
test_shell(false),
use_preemption(true),
preemption_interval(10),
num_isolates(1),
isolate_sources(NULL),
parallel_files(NULL) { }
bool script_executed;
bool last_run;
bool stress_opt;
bool stress_deopt;
bool interactive_shell;
bool test_shell;
bool use_preemption;
int preemption_interval;
int num_isolates;
SourceGroup* isolate_sources;
i::List< i::Vector<const char> >* parallel_files;
};
class Shell: public i::AllStatic {
public:
static bool ExecuteString(Handle<String> source,
......@@ -129,12 +210,13 @@ class Shell: public i::AllStatic {
static void AddHistogramSample(void* histogram, int sample);
static void MapCounters(const char* name);
static Handle<String> ReadFile(const char* name);
static void Initialize(bool test_shell);
static void RenewEvaluationContext();
static void Initialize();
static Persistent<Context> CreateEvaluationContext();
static void InstallUtilityScript();
static void RunShell();
static bool SetOptions(int argc, char* argv[]);
static int RunScript(char* filename);
static int RunMain(int argc, char* argv[], bool* executed);
static int RunMain(int argc, char* argv[]);
static int Main(int argc, char* argv[]);
static Handle<ObjectTemplate> CreateGlobalTemplate();
static Handle<Array> GetCompletions(Handle<String> text,
......@@ -205,6 +287,8 @@ class Shell: public i::AllStatic {
static const char* kHistoryFileName;
static const char* kPrompt;
static ShellOptions options;
private:
static Persistent<Context> utility_context_;
static Persistent<Context> evaluation_context_;
......@@ -214,6 +298,7 @@ class Shell: public i::AllStatic {
static CounterCollection local_counters_;
static CounterCollection* counters_;
static i::OS::MemoryMappedFile* counters_file_;
static i::Mutex* context_mutex_;
static Counter* GetCounter(const char* name, bool is_histogram);
static Handle<Value> CreateExternalArray(const Arguments& args,
ExternalArrayType type,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment