Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 | 28 |
| 29 #if (defined(USING_V8_SHARED) || defined(V8_SHARED)) | |
| 30 #define D8_LIGHT | |
|
Søren Thygesen Gjesse
2011/07/13 14:12:38
How about renaming D8_LIGHT to D8_WITH_SHARED?
It
| |
| 31 #endif | |
| 32 | |
| 29 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 33 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 30 #include <bzlib.h> | 34 #include <bzlib.h> |
| 31 #endif | 35 #endif |
| 36 | |
| 32 #include <errno.h> | 37 #include <errno.h> |
| 33 #include <stdlib.h> | 38 #include <stdlib.h> |
| 39 #include <string.h> | |
| 34 | 40 |
| 35 #include "v8.h" | 41 #ifdef D8_LIGHT |
| 42 #include <assert.h> | |
| 43 #include "../include/v8-testing.h" | |
| 44 #endif // D8_LIGHT | |
|
Søren Thygesen Gjesse
2011/07/13 14:12:38
Two spaces before //. Also in other places below.
| |
| 36 | 45 |
| 37 #include "d8.h" | 46 #include "d8.h" |
| 47 | |
| 48 #ifndef D8_LIGHT | |
| 49 #include "api.h" | |
| 50 #include "checks.h" | |
| 38 #include "d8-debug.h" | 51 #include "d8-debug.h" |
| 39 #include "debug.h" | 52 #include "debug.h" |
| 40 #include "api.h" | |
| 41 #include "natives.h" | 53 #include "natives.h" |
| 42 #include "platform.h" | 54 #include "platform.h" |
| 55 #include "v8.h" | |
| 56 #endif // D8_LIGHT | |
| 43 | 57 |
| 44 #if !defined(_WIN32) && !defined(_WIN64) | 58 #if !defined(_WIN32) && !defined(_WIN64) |
| 45 #include <unistd.h> // NOLINT | 59 #include <unistd.h> // NOLINT |
| 46 #endif | 60 #endif |
| 47 | 61 |
| 62 #ifdef D8_LIGHT | |
| 63 #define ASSERT(condition) assert(condition) | |
| 64 #endif // D8_LIGHT | |
| 65 | |
| 48 namespace v8 { | 66 namespace v8 { |
| 49 | 67 |
| 50 | 68 |
| 69 #ifndef D8_LIGHT | |
| 70 LineEditor *LineEditor::first_ = NULL; | |
| 51 const char* Shell::kHistoryFileName = ".d8_history"; | 71 const char* Shell::kHistoryFileName = ".d8_history"; |
| 52 const char* Shell::kPrompt = "d8> "; | |
| 53 | |
| 54 | |
| 55 LineEditor *LineEditor::first_ = NULL; | |
| 56 | 72 |
| 57 | 73 |
| 58 LineEditor::LineEditor(Type type, const char* name) | 74 LineEditor::LineEditor(Type type, const char* name) |
| 59 : type_(type), | 75 : type_(type), |
| 60 name_(name), | 76 name_(name), |
| 61 next_(first_) { | 77 next_(first_) { |
| 62 first_ = this; | 78 first_ = this; |
| 63 } | 79 } |
| 64 | 80 |
| 65 | 81 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 91 printf("%s", prompt); | 107 printf("%s", prompt); |
| 92 char* str = fgets(buffer, kBufferSize, stdin); | 108 char* str = fgets(buffer, kBufferSize, stdin); |
| 93 return i::SmartPointer<char>(str ? i::StrDup(str) : str); | 109 return i::SmartPointer<char>(str ? i::StrDup(str) : str); |
| 94 } | 110 } |
| 95 | 111 |
| 96 | 112 |
| 97 CounterMap* Shell::counter_map_; | 113 CounterMap* Shell::counter_map_; |
| 98 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; | 114 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; |
| 99 CounterCollection Shell::local_counters_; | 115 CounterCollection Shell::local_counters_; |
| 100 CounterCollection* Shell::counters_ = &local_counters_; | 116 CounterCollection* Shell::counters_ = &local_counters_; |
| 117 i::Mutex* Shell::context_mutex_(i::OS::CreateMutex()); | |
| 101 Persistent<Context> Shell::utility_context_; | 118 Persistent<Context> Shell::utility_context_; |
| 119 #endif // D8_LIGHT | |
| 120 | |
| 102 Persistent<Context> Shell::evaluation_context_; | 121 Persistent<Context> Shell::evaluation_context_; |
| 103 i::Mutex* Shell::context_mutex_(i::OS::CreateMutex()); | |
| 104 ShellOptions Shell::options; | 122 ShellOptions Shell::options; |
| 123 const char* Shell::kPrompt = "d8> "; | |
| 105 | 124 |
| 106 | 125 |
| 126 #ifndef D8_LIGHT | |
| 107 bool CounterMap::Match(void* key1, void* key2) { | 127 bool CounterMap::Match(void* key1, void* key2) { |
| 108 const char* name1 = reinterpret_cast<const char*>(key1); | 128 const char* name1 = reinterpret_cast<const char*>(key1); |
| 109 const char* name2 = reinterpret_cast<const char*>(key2); | 129 const char* name2 = reinterpret_cast<const char*>(key2); |
| 110 return strcmp(name1, name2) == 0; | 130 return strcmp(name1, name2) == 0; |
| 111 } | 131 } |
| 132 #endif // D8_LIGHT | |
| 112 | 133 |
| 113 | 134 |
| 114 // Converts a V8 value to a C string. | 135 // Converts a V8 value to a C string. |
| 115 const char* Shell::ToCString(const v8::String::Utf8Value& value) { | 136 const char* Shell::ToCString(const v8::String::Utf8Value& value) { |
| 116 return *value ? *value : "<string conversion failed>"; | 137 return *value ? *value : "<string conversion failed>"; |
| 117 } | 138 } |
| 118 | 139 |
| 119 | 140 |
| 120 // Executes a string within the current v8 context. | 141 // Executes a string within the current v8 context. |
| 121 bool Shell::ExecuteString(Handle<String> source, | 142 bool Shell::ExecuteString(Handle<String> source, |
| 122 Handle<Value> name, | 143 Handle<Value> name, |
| 123 bool print_result, | 144 bool print_result, |
| 124 bool report_exceptions) { | 145 bool report_exceptions) { |
| 146 #ifndef D8_LIGHT | |
| 147 bool FLAG_debugger = i::FLAG_debugger; | |
| 148 #else | |
| 149 bool FLAG_debugger = false; | |
| 150 #endif // D8_LIGHT | |
| 125 HandleScope handle_scope; | 151 HandleScope handle_scope; |
| 126 TryCatch try_catch; | 152 TryCatch try_catch; |
| 127 options.script_executed = true; | 153 options.script_executed = true; |
| 128 if (i::FLAG_debugger) { | 154 if (FLAG_debugger) { |
| 129 // When debugging make exceptions appear to be uncaught. | 155 // When debugging make exceptions appear to be uncaught. |
| 130 try_catch.SetVerbose(true); | 156 try_catch.SetVerbose(true); |
| 131 } | 157 } |
| 132 Handle<Script> script = Script::Compile(source, name); | 158 Handle<Script> script = Script::Compile(source, name); |
| 133 if (script.IsEmpty()) { | 159 if (script.IsEmpty()) { |
| 134 // Print errors that happened during compilation. | 160 // Print errors that happened during compilation. |
| 135 if (report_exceptions && !i::FLAG_debugger) | 161 if (report_exceptions && !FLAG_debugger) |
| 136 ReportException(&try_catch); | 162 ReportException(&try_catch); |
| 137 return false; | 163 return false; |
| 138 } else { | 164 } else { |
| 139 Handle<Value> result = script->Run(); | 165 Handle<Value> result = script->Run(); |
| 140 if (result.IsEmpty()) { | 166 if (result.IsEmpty()) { |
| 141 ASSERT(try_catch.HasCaught()); | 167 ASSERT(try_catch.HasCaught()); |
| 142 // Print errors that happened during execution. | 168 // Print errors that happened during execution. |
| 143 if (report_exceptions && !i::FLAG_debugger) | 169 if (report_exceptions && !FLAG_debugger) |
| 144 ReportException(&try_catch); | 170 ReportException(&try_catch); |
| 145 return false; | 171 return false; |
| 146 } else { | 172 } else { |
| 147 ASSERT(!try_catch.HasCaught()); | 173 ASSERT(!try_catch.HasCaught()); |
| 148 if (print_result && !result->IsUndefined()) { | 174 if (print_result && !result->IsUndefined()) { |
| 149 // If all went well and the result wasn't undefined then print | 175 // If all went well and the result wasn't undefined then print |
| 150 // the returned value. | 176 // the returned value. |
| 151 v8::String::Utf8Value str(result); | 177 v8::String::Utf8Value str(result); |
| 152 const char* cstr = ToCString(str); | 178 const char* cstr = ToCString(str); |
| 153 printf("%s\n", cstr); | 179 printf("%s\n", cstr); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 } | 215 } |
| 190 Handle<String> source = ReadFile(*file); | 216 Handle<String> source = ReadFile(*file); |
| 191 if (source.IsEmpty()) { | 217 if (source.IsEmpty()) { |
| 192 return ThrowException(String::New("Error loading file")); | 218 return ThrowException(String::New("Error loading file")); |
| 193 } | 219 } |
| 194 return source; | 220 return source; |
| 195 } | 221 } |
| 196 | 222 |
| 197 | 223 |
| 198 Handle<Value> Shell::ReadLine(const Arguments& args) { | 224 Handle<Value> Shell::ReadLine(const Arguments& args) { |
| 199 i::SmartPointer<char> line(i::ReadLine("")); | 225 static const int kBufferSize = 256; |
| 200 if (*line == NULL) { | 226 char buffer[kBufferSize]; |
| 201 return Null(); | 227 if (fgets(buffer, kBufferSize, stdin) == NULL) return Null(); |
| 202 } | 228 buffer[strlen(buffer) - 1] = '\0'; // chomp |
|
Søren Thygesen Gjesse
2011/07/13 14:12:38
Check for '\' before overwriting with '\0'?
Two s
| |
| 203 size_t len = strlen(*line); | 229 return String::New(buffer); |
| 204 if (len > 0 && line[len - 1] == '\n') { | |
| 205 --len; | |
| 206 } | |
| 207 return String::New(*line, len); | |
| 208 } | 230 } |
| 209 | 231 |
| 210 | 232 |
| 211 Handle<Value> Shell::Load(const Arguments& args) { | 233 Handle<Value> Shell::Load(const Arguments& args) { |
| 212 for (int i = 0; i < args.Length(); i++) { | 234 for (int i = 0; i < args.Length(); i++) { |
| 213 HandleScope handle_scope; | 235 HandleScope handle_scope; |
| 214 String::Utf8Value file(args[i]); | 236 String::Utf8Value file(args[i]); |
| 215 if (*file == NULL) { | 237 if (*file == NULL) { |
| 216 return ThrowException(String::New("Error loading file")); | 238 return ThrowException(String::New("Error loading file")); |
| 217 } | 239 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 229 | 251 |
| 230 Handle<Value> Shell::CreateExternalArray(const Arguments& args, | 252 Handle<Value> Shell::CreateExternalArray(const Arguments& args, |
| 231 ExternalArrayType type, | 253 ExternalArrayType type, |
| 232 size_t element_size) { | 254 size_t element_size) { |
| 233 ASSERT(element_size == 1 || element_size == 2 || element_size == 4 || | 255 ASSERT(element_size == 1 || element_size == 2 || element_size == 4 || |
| 234 element_size == 8); | 256 element_size == 8); |
| 235 if (args.Length() != 1) { | 257 if (args.Length() != 1) { |
| 236 return ThrowException( | 258 return ThrowException( |
| 237 String::New("Array constructor needs one parameter.")); | 259 String::New("Array constructor needs one parameter.")); |
| 238 } | 260 } |
| 261 static const int kMaxLength = 0x3fffffff; | |
|
Søren Thygesen Gjesse
2011/07/13 14:12:38
Maybe assert that this is equal to i::ExternalArr
| |
| 239 size_t length = 0; | 262 size_t length = 0; |
| 240 if (args[0]->IsUint32()) { | 263 if (args[0]->IsUint32()) { |
| 241 length = args[0]->Uint32Value(); | 264 length = args[0]->Uint32Value(); |
| 242 } else if (args[0]->IsNumber()) { | 265 } else if (args[0]->IsNumber()) { |
| 243 double raw_length = args[0]->NumberValue(); | 266 double raw_length = args[0]->NumberValue(); |
| 244 if (raw_length < 0) { | 267 if (raw_length < 0) { |
| 245 return ThrowException(String::New("Array length must not be negative.")); | 268 return ThrowException(String::New("Array length must not be negative.")); |
| 246 } | 269 } |
| 247 if (raw_length > i::ExternalArray::kMaxLength) { | 270 if (raw_length > kMaxLength) { |
| 248 return ThrowException( | 271 return ThrowException( |
| 249 String::New("Array length exceeds maximum length.")); | 272 String::New("Array length exceeds maximum length.")); |
| 250 } | 273 } |
| 251 length = static_cast<size_t>(raw_length); | 274 length = static_cast<size_t>(raw_length); |
| 252 } else { | 275 } else { |
| 253 return ThrowException(String::New("Array length must be a number.")); | 276 return ThrowException(String::New("Array length must be a number.")); |
| 254 } | 277 } |
| 255 if (length > static_cast<size_t>(i::ExternalArray::kMaxLength)) { | 278 if (length > static_cast<size_t>(kMaxLength)) { |
| 256 return ThrowException(String::New("Array length exceeds maximum length.")); | 279 return ThrowException(String::New("Array length exceeds maximum length.")); |
| 257 } | 280 } |
| 258 void* data = calloc(length, element_size); | 281 void* data = calloc(length, element_size); |
| 259 if (data == NULL) { | 282 if (data == NULL) { |
| 260 return ThrowException(String::New("Memory allocation failed.")); | 283 return ThrowException(String::New("Memory allocation failed.")); |
| 261 } | 284 } |
| 262 Handle<Object> array = Object::New(); | 285 Handle<Object> array = Object::New(); |
| 263 Persistent<Object> persistent_array = Persistent<Object>::New(array); | 286 Persistent<Object> persistent_array = Persistent<Object>::New(array); |
| 264 persistent_array.MakeWeak(data, ExternalArrayWeakCallback); | 287 persistent_array.MakeWeak(data, ExternalArrayWeakCallback); |
| 265 persistent_array.MarkIndependent(); | 288 persistent_array.MarkIndependent(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 | 348 |
| 326 | 349 |
| 327 Handle<Value> Shell::Yield(const Arguments& args) { | 350 Handle<Value> Shell::Yield(const Arguments& args) { |
| 328 v8::Unlocker unlocker; | 351 v8::Unlocker unlocker; |
| 329 return Undefined(); | 352 return Undefined(); |
| 330 } | 353 } |
| 331 | 354 |
| 332 | 355 |
| 333 Handle<Value> Shell::Quit(const Arguments& args) { | 356 Handle<Value> Shell::Quit(const Arguments& args) { |
| 334 int exit_code = args[0]->Int32Value(); | 357 int exit_code = args[0]->Int32Value(); |
| 358 #ifndef D8_LIGHT | |
| 335 OnExit(); | 359 OnExit(); |
| 360 #endif // D8_LIGHT | |
| 336 exit(exit_code); | 361 exit(exit_code); |
| 337 return Undefined(); | 362 return Undefined(); |
| 338 } | 363 } |
| 339 | 364 |
| 340 | 365 |
| 341 Handle<Value> Shell::Version(const Arguments& args) { | 366 Handle<Value> Shell::Version(const Arguments& args) { |
| 342 return String::New(V8::GetVersion()); | 367 return String::New(V8::GetVersion()); |
| 343 } | 368 } |
| 344 | 369 |
| 345 | 370 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 374 printf("\n"); | 399 printf("\n"); |
| 375 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); | 400 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); |
| 376 if (stack_trace.length() > 0) { | 401 if (stack_trace.length() > 0) { |
| 377 const char* stack_trace_string = ToCString(stack_trace); | 402 const char* stack_trace_string = ToCString(stack_trace); |
| 378 printf("%s\n", stack_trace_string); | 403 printf("%s\n", stack_trace_string); |
| 379 } | 404 } |
| 380 } | 405 } |
| 381 } | 406 } |
| 382 | 407 |
| 383 | 408 |
| 409 #ifndef D8_LIGHT | |
| 384 Handle<Array> Shell::GetCompletions(Handle<String> text, Handle<String> full) { | 410 Handle<Array> Shell::GetCompletions(Handle<String> text, Handle<String> full) { |
| 385 HandleScope handle_scope; | 411 HandleScope handle_scope; |
| 386 Context::Scope context_scope(utility_context_); | 412 Context::Scope context_scope(utility_context_); |
| 387 Handle<Object> global = utility_context_->Global(); | 413 Handle<Object> global = utility_context_->Global(); |
| 388 Handle<Value> fun = global->Get(String::New("GetCompletions")); | 414 Handle<Value> fun = global->Get(String::New("GetCompletions")); |
| 389 static const int kArgc = 3; | 415 static const int kArgc = 3; |
| 390 Handle<Value> argv[kArgc] = { evaluation_context_->Global(), text, full }; | 416 Handle<Value> argv[kArgc] = { evaluation_context_->Global(), text, full }; |
| 391 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); | 417 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); |
| 392 return handle_scope.Close(Handle<Array>::Cast(val)); | 418 return handle_scope.Close(Handle<Array>::Cast(val)); |
| 393 } | 419 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 407 | 433 |
| 408 Handle<Value> Shell::DebugCommandToJSONRequest(Handle<String> command) { | 434 Handle<Value> Shell::DebugCommandToJSONRequest(Handle<String> command) { |
| 409 Context::Scope context_scope(utility_context_); | 435 Context::Scope context_scope(utility_context_); |
| 410 Handle<Object> global = utility_context_->Global(); | 436 Handle<Object> global = utility_context_->Global(); |
| 411 Handle<Value> fun = global->Get(String::New("DebugCommandToJSONRequest")); | 437 Handle<Value> fun = global->Get(String::New("DebugCommandToJSONRequest")); |
| 412 static const int kArgc = 1; | 438 static const int kArgc = 1; |
| 413 Handle<Value> argv[kArgc] = { command }; | 439 Handle<Value> argv[kArgc] = { command }; |
| 414 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); | 440 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); |
| 415 return val; | 441 return val; |
| 416 } | 442 } |
| 417 #endif | 443 #endif // ENABLE_DEBUGGER_SUPPORT |
| 444 #endif // D8_LIGHT | |
| 418 | 445 |
| 419 | 446 |
| 447 #ifndef D8_LIGHT | |
| 420 int32_t* Counter::Bind(const char* name, bool is_histogram) { | 448 int32_t* Counter::Bind(const char* name, bool is_histogram) { |
| 421 int i; | 449 int i; |
| 422 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) | 450 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) |
| 423 name_[i] = static_cast<char>(name[i]); | 451 name_[i] = static_cast<char>(name[i]); |
| 424 name_[i] = '\0'; | 452 name_[i] = '\0'; |
| 425 is_histogram_ = is_histogram; | 453 is_histogram_ = is_histogram; |
| 426 return ptr(); | 454 return ptr(); |
| 427 } | 455 } |
| 428 | 456 |
| 429 | 457 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 441 } | 469 } |
| 442 | 470 |
| 443 | 471 |
| 444 Counter* CounterCollection::GetNextCounter() { | 472 Counter* CounterCollection::GetNextCounter() { |
| 445 if (counters_in_use_ == kMaxCounters) return NULL; | 473 if (counters_in_use_ == kMaxCounters) return NULL; |
| 446 return &counters_[counters_in_use_++]; | 474 return &counters_[counters_in_use_++]; |
| 447 } | 475 } |
| 448 | 476 |
| 449 | 477 |
| 450 void Shell::MapCounters(const char* name) { | 478 void Shell::MapCounters(const char* name) { |
| 451 counters_file_ = i::OS::MemoryMappedFile::create(name, | 479 counters_file_ = i::OS::MemoryMappedFile::create(name, |
|
Søren Thygesen Gjesse
2011/07/13 14:12:38
While at it consider moving name to the line with
| |
| 452 sizeof(CounterCollection), &local_counters_); | 480 sizeof(CounterCollection), &local_counters_); |
| 453 void* memory = (counters_file_ == NULL) ? | 481 void* memory = (counters_file_ == NULL) ? |
| 454 NULL : counters_file_->memory(); | 482 NULL : counters_file_->memory(); |
| 455 if (memory == NULL) { | 483 if (memory == NULL) { |
| 456 printf("Could not map counters file %s\n", name); | 484 printf("Could not map counters file %s\n", name); |
| 457 exit(1); | 485 exit(1); |
| 458 } | 486 } |
| 459 counters_ = static_cast<CounterCollection*>(memory); | 487 counters_ = static_cast<CounterCollection*>(memory); |
| 460 V8::SetCounterFunction(LookupCounter); | 488 V8::SetCounterFunction(LookupCounter); |
| 461 V8::SetCreateHistogramFunction(CreateHistogram); | 489 V8::SetCreateHistogramFunction(CreateHistogram); |
| 462 V8::SetAddHistogramSampleFunction(AddHistogramSample); | 490 V8::SetAddHistogramSampleFunction(AddHistogramSample); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 size_t buckets) { | 535 size_t buckets) { |
| 508 return GetCounter(name, true); | 536 return GetCounter(name, true); |
| 509 } | 537 } |
| 510 | 538 |
| 511 | 539 |
| 512 void Shell::AddHistogramSample(void* histogram, int sample) { | 540 void Shell::AddHistogramSample(void* histogram, int sample) { |
| 513 Counter* counter = reinterpret_cast<Counter*>(histogram); | 541 Counter* counter = reinterpret_cast<Counter*>(histogram); |
| 514 counter->AddSample(sample); | 542 counter->AddSample(sample); |
| 515 } | 543 } |
| 516 | 544 |
| 545 | |
| 517 void Shell::InstallUtilityScript() { | 546 void Shell::InstallUtilityScript() { |
| 518 Locker lock; | 547 Locker lock; |
| 519 HandleScope scope; | 548 HandleScope scope; |
| 520 // If we use the utility context, we have to set the security tokens so that | 549 // If we use the utility context, we have to set the security tokens so that |
| 521 // utility, evaluation and debug context can all access each other. | 550 // utility, evaluation and debug context can all access each other. |
| 522 utility_context_->SetSecurityToken(Undefined()); | 551 utility_context_->SetSecurityToken(Undefined()); |
| 523 evaluation_context_->SetSecurityToken(Undefined()); | 552 evaluation_context_->SetSecurityToken(Undefined()); |
| 524 Context::Scope utility_scope(utility_context_); | 553 Context::Scope utility_scope(utility_context_); |
| 525 | 554 |
| 526 #ifdef ENABLE_DEBUGGER_SUPPORT | 555 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 527 // Install the debugger object in the utility scope | 556 // Install the debugger object in the utility scope |
| 528 i::Debug* debug = i::Isolate::Current()->debug(); | 557 i::Debug* debug = i::Isolate::Current()->debug(); |
| 529 debug->Load(); | 558 debug->Load(); |
| 530 i::Handle<i::JSObject> js_debug | 559 i::Handle<i::JSObject> js_debug |
| 531 = i::Handle<i::JSObject>(debug->debug_context()->global()); | 560 = i::Handle<i::JSObject>(debug->debug_context()->global()); |
| 532 utility_context_->Global()->Set(String::New("$debug"), | 561 utility_context_->Global()->Set(String::New("$debug"), |
| 533 Utils::ToLocal(js_debug)); | 562 Utils::ToLocal(js_debug)); |
| 534 debug->debug_context()->set_security_token(HEAP->undefined_value()); | 563 debug->debug_context()->set_security_token(HEAP->undefined_value()); |
| 535 #endif | 564 #endif // ENABLE_DEBUGGER_SUPPORT |
| 536 | 565 |
| 537 // Run the d8 shell utility script in the utility context | 566 // Run the d8 shell utility script in the utility context |
| 538 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); | 567 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); |
| 539 i::Vector<const char> shell_source = | 568 i::Vector<const char> shell_source = |
| 540 i::NativesCollection<i::D8>::GetRawScriptSource(source_index); | 569 i::NativesCollection<i::D8>::GetRawScriptSource(source_index); |
| 541 i::Vector<const char> shell_source_name = | 570 i::Vector<const char> shell_source_name = |
| 542 i::NativesCollection<i::D8>::GetScriptName(source_index); | 571 i::NativesCollection<i::D8>::GetScriptName(source_index); |
| 543 Handle<String> source = String::New(shell_source.start(), | 572 Handle<String> source = String::New(shell_source.start(), |
| 544 shell_source.length()); | 573 shell_source.length()); |
| 545 Handle<String> name = String::New(shell_source_name.start(), | 574 Handle<String> name = String::New(shell_source_name.start(), |
| 546 shell_source_name.length()); | 575 shell_source_name.length()); |
| 547 Handle<Script> script = Script::Compile(source, name); | 576 Handle<Script> script = Script::Compile(source, name); |
| 548 script->Run(); | 577 script->Run(); |
| 549 // Mark the d8 shell script as native to avoid it showing up as normal source | 578 // Mark the d8 shell script as native to avoid it showing up as normal source |
| 550 // in the debugger. | 579 // in the debugger. |
| 551 i::Handle<i::Object> compiled_script = Utils::OpenHandle(*script); | 580 i::Handle<i::Object> compiled_script = Utils::OpenHandle(*script); |
| 552 i::Handle<i::Script> script_object = compiled_script->IsJSFunction() | 581 i::Handle<i::Script> script_object = compiled_script->IsJSFunction() |
| 553 ? i::Handle<i::Script>(i::Script::cast( | 582 ? i::Handle<i::Script>(i::Script::cast( |
| 554 i::JSFunction::cast(*compiled_script)->shared()->script())) | 583 i::JSFunction::cast(*compiled_script)->shared()->script())) |
| 555 : i::Handle<i::Script>(i::Script::cast( | 584 : i::Handle<i::Script>(i::Script::cast( |
| 556 i::SharedFunctionInfo::cast(*compiled_script)->script())); | 585 i::SharedFunctionInfo::cast(*compiled_script)->script())); |
| 557 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE)); | 586 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE)); |
| 558 | 587 |
| 559 #ifdef ENABLE_DEBUGGER_SUPPORT | 588 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 560 // Start the in-process debugger if requested. | 589 // Start the in-process debugger if requested. |
| 561 if (i::FLAG_debugger && !i::FLAG_debugger_agent) { | 590 if (i::FLAG_debugger && !i::FLAG_debugger_agent) { |
| 562 v8::Debug::SetDebugEventListener(HandleDebugEvent); | 591 v8::Debug::SetDebugEventListener(HandleDebugEvent); |
| 563 } | 592 } |
| 564 #endif | 593 #endif // ENABLE_DEBUGGER_SUPPORT |
| 565 } | 594 } |
| 595 #endif // D8_LIGHT | |
| 566 | 596 |
| 567 | 597 |
| 568 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 598 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 569 class BZip2Decompressor : public v8::StartupDataDecompressor { | 599 class BZip2Decompressor : public v8::StartupDataDecompressor { |
| 570 public: | 600 public: |
| 571 virtual ~BZip2Decompressor() { } | 601 virtual ~BZip2Decompressor() { } |
| 572 | 602 |
| 573 protected: | 603 protected: |
| 574 virtual int DecompressData(char* raw_data, | 604 virtual int DecompressData(char* raw_data, |
| 575 int* raw_data_size, | 605 int* raw_data_size, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 FunctionTemplate::New(Float64Array)); | 652 FunctionTemplate::New(Float64Array)); |
| 623 global_template->Set(String::New("PixelArray"), | 653 global_template->Set(String::New("PixelArray"), |
| 624 FunctionTemplate::New(PixelArray)); | 654 FunctionTemplate::New(PixelArray)); |
| 625 | 655 |
| 626 #ifdef LIVE_OBJECT_LIST | 656 #ifdef LIVE_OBJECT_LIST |
| 627 global_template->Set(String::New("lol_is_enabled"), Boolean::New(true)); | 657 global_template->Set(String::New("lol_is_enabled"), Boolean::New(true)); |
| 628 #else | 658 #else |
| 629 global_template->Set(String::New("lol_is_enabled"), Boolean::New(false)); | 659 global_template->Set(String::New("lol_is_enabled"), Boolean::New(false)); |
| 630 #endif | 660 #endif |
| 631 | 661 |
| 662 #ifndef D8_LIGHT | |
| 632 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); | 663 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); |
| 633 AddOSMethods(os_templ); | 664 AddOSMethods(os_templ); |
| 634 global_template->Set(String::New("os"), os_templ); | 665 global_template->Set(String::New("os"), os_templ); |
| 666 #endif // D8_LIGHT | |
| 635 | 667 |
| 636 return global_template; | 668 return global_template; |
| 637 } | 669 } |
| 638 | 670 |
| 639 | 671 |
| 640 void Shell::Initialize() { | 672 void Shell::Initialize() { |
| 641 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 673 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 642 BZip2Decompressor startup_data_decompressor; | 674 BZip2Decompressor startup_data_decompressor; |
| 643 int bz2_result = startup_data_decompressor.Decompress(); | 675 int bz2_result = startup_data_decompressor.Decompress(); |
| 644 if (bz2_result != BZ_OK) { | 676 if (bz2_result != BZ_OK) { |
| 645 fprintf(stderr, "bzip error code: %d\n", bz2_result); | 677 fprintf(stderr, "bzip error code: %d\n", bz2_result); |
| 646 exit(1); | 678 exit(1); |
| 647 } | 679 } |
| 648 #endif | 680 #endif |
| 649 | 681 |
| 682 #ifndef D8_LIGHT | |
| 650 Shell::counter_map_ = new CounterMap(); | 683 Shell::counter_map_ = new CounterMap(); |
| 651 // Set up counters | 684 // Set up counters |
| 652 if (i::StrLength(i::FLAG_map_counters) != 0) | 685 if (i::StrLength(i::FLAG_map_counters) != 0) |
| 653 MapCounters(i::FLAG_map_counters); | 686 MapCounters(i::FLAG_map_counters); |
| 654 if (i::FLAG_dump_counters) { | 687 if (i::FLAG_dump_counters) { |
| 655 V8::SetCounterFunction(LookupCounter); | 688 V8::SetCounterFunction(LookupCounter); |
| 656 V8::SetCreateHistogramFunction(CreateHistogram); | 689 V8::SetCreateHistogramFunction(CreateHistogram); |
| 657 V8::SetAddHistogramSampleFunction(AddHistogramSample); | 690 V8::SetAddHistogramSampleFunction(AddHistogramSample); |
| 658 } | 691 } |
| 659 | 692 #endif // D8_LIGHT |
| 660 if (options.test_shell) return; | 693 if (options.test_shell) return; |
| 661 | 694 |
| 695 #ifndef D8_LIGHT | |
| 662 Locker lock; | 696 Locker lock; |
| 663 HandleScope scope; | 697 HandleScope scope; |
| 664 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(); | 698 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(); |
| 665 utility_context_ = Context::New(NULL, global_template); | 699 utility_context_ = Context::New(NULL, global_template); |
| 666 | 700 |
| 667 #ifdef ENABLE_DEBUGGER_SUPPORT | 701 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 668 // Start the debugger agent if requested. | 702 // Start the debugger agent if requested. |
| 669 if (i::FLAG_debugger_agent) { | 703 if (i::FLAG_debugger_agent) { |
| 670 v8::Debug::EnableAgent("d8 shell", i::FLAG_debugger_port, true); | 704 v8::Debug::EnableAgent("d8 shell", i::FLAG_debugger_port, true); |
| 671 } | 705 } |
| 672 #endif | 706 #endif // ENABLE_DEBUGGER_SUPPORT |
| 707 #endif // D8_LIGHT | |
| 673 } | 708 } |
| 674 | 709 |
| 675 | 710 |
| 676 Persistent<Context> Shell::CreateEvaluationContext() { | 711 Persistent<Context> Shell::CreateEvaluationContext() { |
| 712 #ifndef D8_LIGHT | |
| 677 // This needs to be a critical section since this is not thread-safe | 713 // This needs to be a critical section since this is not thread-safe |
| 678 i::ScopedLock lock(context_mutex_); | 714 i::ScopedLock lock(context_mutex_); |
| 715 #endif // D8_LIGHT | |
| 679 // Initialize the global objects | 716 // Initialize the global objects |
| 680 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(); | 717 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(); |
| 681 Persistent<Context> context = Context::New(NULL, global_template); | 718 Persistent<Context> context = Context::New(NULL, global_template); |
| 682 Context::Scope scope(context); | 719 Context::Scope scope(context); |
| 683 | 720 |
| 721 #ifndef D8_LIGHT | |
| 684 i::JSArguments js_args = i::FLAG_js_arguments; | 722 i::JSArguments js_args = i::FLAG_js_arguments; |
| 685 i::Handle<i::FixedArray> arguments_array = | 723 i::Handle<i::FixedArray> arguments_array = |
| 686 FACTORY->NewFixedArray(js_args.argc()); | 724 FACTORY->NewFixedArray(js_args.argc()); |
| 687 for (int j = 0; j < js_args.argc(); j++) { | 725 for (int j = 0; j < js_args.argc(); j++) { |
| 688 i::Handle<i::String> arg = | 726 i::Handle<i::String> arg = |
| 689 FACTORY->NewStringFromUtf8(i::CStrVector(js_args[j])); | 727 FACTORY->NewStringFromUtf8(i::CStrVector(js_args[j])); |
| 690 arguments_array->set(j, *arg); | 728 arguments_array->set(j, *arg); |
| 691 } | 729 } |
| 692 i::Handle<i::JSArray> arguments_jsarray = | 730 i::Handle<i::JSArray> arguments_jsarray = |
| 693 FACTORY->NewJSArrayWithElements(arguments_array); | 731 FACTORY->NewJSArrayWithElements(arguments_array); |
| 694 context->Global()->Set(String::New("arguments"), | 732 context->Global()->Set(String::New("arguments"), |
| 695 Utils::ToLocal(arguments_jsarray)); | 733 Utils::ToLocal(arguments_jsarray)); |
| 734 #endif // D8_LIGHT | |
| 696 return context; | 735 return context; |
| 697 } | 736 } |
| 698 | 737 |
| 699 | 738 |
| 739 #ifndef D8_LIGHT | |
| 700 void Shell::OnExit() { | 740 void Shell::OnExit() { |
| 701 if (i::FLAG_dump_counters) { | 741 if (i::FLAG_dump_counters) { |
| 702 printf("+----------------------------------------+-------------+\n"); | 742 printf("+----------------------------------------+-------------+\n"); |
| 703 printf("| Name | Value |\n"); | 743 printf("| Name | Value |\n"); |
| 704 printf("+----------------------------------------+-------------+\n"); | 744 printf("+----------------------------------------+-------------+\n"); |
| 705 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { | 745 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { |
| 706 Counter* counter = i.CurrentValue(); | 746 Counter* counter = i.CurrentValue(); |
| 707 if (counter->is_histogram()) { | 747 if (counter->is_histogram()) { |
| 708 printf("| c:%-36s | %11i |\n", i.CurrentKey(), counter->count()); | 748 printf("| c:%-36s | %11i |\n", i.CurrentKey(), counter->count()); |
| 709 printf("| t:%-36s | %11i |\n", i.CurrentKey(), counter->sample_total()); | 749 printf("| t:%-36s | %11i |\n", i.CurrentKey(), counter->sample_total()); |
| 710 } else { | 750 } else { |
| 711 printf("| %-38s | %11i |\n", i.CurrentKey(), counter->count()); | 751 printf("| %-38s | %11i |\n", i.CurrentKey(), counter->count()); |
| 712 } | 752 } |
| 713 } | 753 } |
| 714 printf("+----------------------------------------+-------------+\n"); | 754 printf("+----------------------------------------+-------------+\n"); |
| 715 } | 755 } |
| 716 if (counters_file_ != NULL) | 756 if (counters_file_ != NULL) |
| 717 delete counters_file_; | 757 delete counters_file_; |
| 718 } | 758 } |
| 759 #endif // D8_LIGHT | |
| 719 | 760 |
| 720 | 761 |
| 721 static char* ReadChars(const char* name, int* size_out) { | 762 static char* ReadChars(const char* name, int* size_out) { |
| 722 // Release the V8 lock while reading files. | 763 // Release the V8 lock while reading files. |
| 723 v8::Unlocker unlocker(Isolate::GetCurrent()); | 764 v8::Unlocker unlocker(Isolate::GetCurrent()); |
| 765 #ifndef D8_LIGHT | |
| 724 FILE* file = i::OS::FOpen(name, "rb"); | 766 FILE* file = i::OS::FOpen(name, "rb"); |
| 767 #else | |
| 768 FILE* file = fopen(name, "rb"); // TODO: reading from a directory hangs! | |
|
Yang
2011/07/13 13:26:10
This is a known minor issue. I'll come with a solu
| |
| 769 #endif // D8_LIGHT | |
| 725 if (file == NULL) return NULL; | 770 if (file == NULL) return NULL; |
| 726 | 771 |
| 727 fseek(file, 0, SEEK_END); | 772 fseek(file, 0, SEEK_END); |
| 728 int size = ftell(file); | 773 int size = ftell(file); |
| 729 rewind(file); | 774 rewind(file); |
| 730 | 775 |
| 731 char* chars = new char[size + 1]; | 776 char* chars = new char[size + 1]; |
| 732 chars[size] = '\0'; | 777 chars[size] = '\0'; |
| 733 for (int i = 0; i < size;) { | 778 for (int i = 0; i < size;) { |
| 734 int read = fread(&chars[i], 1, size - i, file); | 779 int read = fread(&chars[i], 1, size - i, file); |
| 735 i += read; | 780 i += read; |
| 736 } | 781 } |
| 737 fclose(file); | 782 fclose(file); |
| 738 *size_out = size; | 783 *size_out = size; |
| 739 return chars; | 784 return chars; |
| 740 } | 785 } |
| 741 | 786 |
| 742 | 787 |
| 788 #ifndef D8_LIGHT | |
| 743 static char* ReadToken(char* data, char token) { | 789 static char* ReadToken(char* data, char token) { |
| 744 char* next = i::OS::StrChr(data, token); | 790 char* next = i::OS::StrChr(data, token); |
| 745 if (next != NULL) { | 791 if (next != NULL) { |
| 746 *next = '\0'; | 792 *next = '\0'; |
| 747 return (next + 1); | 793 return (next + 1); |
| 748 } | 794 } |
| 749 | 795 |
| 750 return NULL; | 796 return NULL; |
| 751 } | 797 } |
| 752 | 798 |
| 753 | 799 |
| 754 static char* ReadLine(char* data) { | 800 static char* ReadLine(char* data) { |
| 755 return ReadToken(data, '\n'); | 801 return ReadToken(data, '\n'); |
| 756 } | 802 } |
| 757 | 803 |
| 758 | 804 |
| 759 static char* ReadWord(char* data) { | 805 static char* ReadWord(char* data) { |
| 760 return ReadToken(data, ' '); | 806 return ReadToken(data, ' '); |
| 761 } | 807 } |
| 808 #endif // D8_LIGHT | |
| 762 | 809 |
| 763 | 810 |
| 764 // Reads a file into a v8 string. | 811 // Reads a file into a v8 string. |
| 765 Handle<String> Shell::ReadFile(const char* name) { | 812 Handle<String> Shell::ReadFile(const char* name) { |
| 766 int size = 0; | 813 int size = 0; |
| 767 char* chars = ReadChars(name, &size); | 814 char* chars = ReadChars(name, &size); |
| 768 if (chars == NULL) return Handle<String>(); | 815 if (chars == NULL) return Handle<String>(); |
| 769 Handle<String> result = String::New(chars); | 816 Handle<String> result = String::New(chars); |
| 770 delete[] chars; | 817 delete[] chars; |
| 771 return result; | 818 return result; |
| 772 } | 819 } |
| 773 | 820 |
| 774 | 821 |
| 775 void Shell::RunShell() { | 822 void Shell::RunShell() { |
| 823 Locker locker; | |
| 824 Context::Scope context_scope(evaluation_context_); | |
| 825 HandleScope handle_scope; | |
| 826 Handle<String> name = String::New("(d8)"); | |
| 827 #ifndef D8_LIGHT | |
| 776 LineEditor* editor = LineEditor::Get(); | 828 LineEditor* editor = LineEditor::Get(); |
| 777 printf("V8 version %s [console: %s]\n", V8::GetVersion(), editor->name()); | 829 printf("V8 version %s [console: %s]\n", V8::GetVersion(), editor->name()); |
| 778 if (i::FLAG_debugger) { | 830 if (i::FLAG_debugger) { |
| 779 printf("JavaScript debugger enabled\n"); | 831 printf("JavaScript debugger enabled\n"); |
| 780 } | 832 } |
| 781 | |
| 782 editor->Open(); | 833 editor->Open(); |
| 783 while (true) { | 834 while (true) { |
| 784 Locker locker; | |
| 785 HandleScope handle_scope; | |
| 786 Context::Scope context_scope(evaluation_context_); | |
| 787 i::SmartPointer<char> input = editor->Prompt(Shell::kPrompt); | 835 i::SmartPointer<char> input = editor->Prompt(Shell::kPrompt); |
| 788 if (input.is_empty()) | 836 if (input.is_empty()) break; |
| 789 break; | |
| 790 editor->AddHistory(*input); | 837 editor->AddHistory(*input); |
| 791 Handle<String> name = String::New("(d8)"); | |
| 792 ExecuteString(String::New(*input), name, true, true); | 838 ExecuteString(String::New(*input), name, true, true); |
| 793 } | 839 } |
| 794 editor->Close(); | 840 editor->Close(); |
| 841 #else | |
| 842 printf("V8 version %s [D8 light with shared library]\n", V8::GetVersion()); | |
|
Søren Thygesen Gjesse
2011/07/13 14:12:38
with -> using
| |
| 843 static const int kBufferSize = 256; | |
| 844 while (true) { | |
| 845 char buffer[kBufferSize]; | |
| 846 printf("%s", Shell::kPrompt); | |
| 847 if (fgets(buffer, kBufferSize, stdin) == NULL) break; | |
| 848 ExecuteString(String::New(buffer), name, true, true); | |
| 849 } | |
| 850 #endif // D8_LIGHT | |
| 795 printf("\n"); | 851 printf("\n"); |
| 796 } | 852 } |
| 797 | 853 |
| 798 | 854 |
| 855 #ifndef D8_LIGHT | |
| 799 class ShellThread : public i::Thread { | 856 class ShellThread : public i::Thread { |
| 800 public: | 857 public: |
| 801 ShellThread(int no, i::Vector<const char> files) | 858 ShellThread(int no, i::Vector<const char> files) |
| 802 : Thread("d8:ShellThread"), | 859 : Thread("d8:ShellThread"), |
| 803 no_(no), files_(files) { } | 860 no_(no), files_(files) { } |
| 804 virtual void Run(); | 861 virtual void Run(); |
| 805 private: | 862 private: |
| 806 int no_; | 863 int no_; |
| 807 i::Vector<const char> files_; | 864 i::Vector<const char> files_; |
| 808 }; | 865 }; |
| 809 | 866 |
| 810 | 867 |
| 811 void ShellThread::Run() { | 868 void ShellThread::Run() { |
| 812 char* ptr = const_cast<char*>(files_.start()); | 869 char* ptr = const_cast<char*>(files_.start()); |
| 813 while ((ptr != NULL) && (*ptr != '\0')) { | 870 while ((ptr != NULL) && (*ptr != '\0')) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 841 break; | 898 break; |
| 842 } | 899 } |
| 843 | 900 |
| 844 Shell::ExecuteString(str, String::New(filename), false, false); | 901 Shell::ExecuteString(str, String::New(filename), false, false); |
| 845 } | 902 } |
| 846 | 903 |
| 847 thread_context.Dispose(); | 904 thread_context.Dispose(); |
| 848 ptr = next_line; | 905 ptr = next_line; |
| 849 } | 906 } |
| 850 } | 907 } |
| 908 #endif // D8_LIGHT | |
| 851 | 909 |
| 852 | 910 |
| 853 void SourceGroup::ExitShell(int exit_code) { | 911 void SourceGroup::ExitShell(int exit_code) { |
| 854 // Use _exit instead of exit to avoid races between isolate | 912 // Use _exit instead of exit to avoid races between isolate |
| 855 // threads and static destructors. | 913 // threads and static destructors. |
| 856 fflush(stdout); | 914 fflush(stdout); |
| 857 fflush(stderr); | 915 fflush(stderr); |
| 858 _exit(exit_code); | 916 _exit(exit_code); |
| 859 } | 917 } |
| 860 | 918 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 887 if (!Shell::ExecuteString(source, file_name, false, true)) { | 945 if (!Shell::ExecuteString(source, file_name, false, true)) { |
| 888 ExitShell(1); | 946 ExitShell(1); |
| 889 return; | 947 return; |
| 890 } | 948 } |
| 891 } | 949 } |
| 892 } | 950 } |
| 893 } | 951 } |
| 894 | 952 |
| 895 | 953 |
| 896 Handle<String> SourceGroup::ReadFile(const char* name) { | 954 Handle<String> SourceGroup::ReadFile(const char* name) { |
| 897 FILE* file = fopen(name, "rb"); | 955 #ifndef D8_LIGHT |
| 956 FILE* file = i::OS::FOpen(name, "rb"); | |
| 957 #else | |
| 958 FILE* file = fopen(name, "rb"); // TODO: reading from a directory hangs! | |
|
Yang
2011/07/13 13:26:10
Ditto.
| |
| 959 #endif // D8_LIGHT | |
| 898 if (file == NULL) return Handle<String>(); | 960 if (file == NULL) return Handle<String>(); |
| 899 | 961 |
| 900 fseek(file, 0, SEEK_END); | 962 fseek(file, 0, SEEK_END); |
| 901 int size = ftell(file); | 963 int size = ftell(file); |
| 902 rewind(file); | 964 rewind(file); |
| 903 | 965 |
| 904 char* chars = new char[size + 1]; | 966 char* chars = new char[size + 1]; |
| 905 chars[size] = '\0'; | 967 chars[size] = '\0'; |
| 906 for (int i = 0; i < size;) { | 968 for (int i = 0; i < size;) { |
| 907 int read = fread(&chars[i], 1, size - i, file); | 969 int read = fread(&chars[i], 1, size - i, file); |
| 908 i += read; | 970 i += read; |
| 909 } | 971 } |
| 910 fclose(file); | 972 fclose(file); |
| 911 Handle<String> result = String::New(chars, size); | 973 Handle<String> result = String::New(chars, size); |
| 912 delete[] chars; | 974 delete[] chars; |
| 913 return result; | 975 return result; |
| 914 } | 976 } |
| 915 | 977 |
| 916 | 978 |
| 979 #ifndef D8_LIGHT | |
| 917 i::Thread::Options SourceGroup::GetThreadOptions() { | 980 i::Thread::Options SourceGroup::GetThreadOptions() { |
| 918 i::Thread::Options options; | 981 i::Thread::Options options; |
| 919 options.name = "IsolateThread"; | 982 options.name = "IsolateThread"; |
| 920 // On some systems (OSX 10.6) the stack size default is 0.5Mb or less | 983 // On some systems (OSX 10.6) the stack size default is 0.5Mb or less |
| 921 // which is not enough to parse the big literal expressions used in tests. | 984 // which is not enough to parse the big literal expressions used in tests. |
| 922 // The stack size should be at least StackGuard::kLimitSize + some | 985 // The stack size should be at least StackGuard::kLimitSize + some |
| 923 // OS-specific padding for thread startup code. | 986 // OS-specific padding for thread startup code. |
| 924 options.stack_size = 2 << 20; // 2 Mb seems to be enough | 987 options.stack_size = 2 << 20; // 2 Mb seems to be enough |
| 925 return options; | 988 return options; |
| 926 } | 989 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 | 1021 |
| 959 void SourceGroup::WaitForThread() { | 1022 void SourceGroup::WaitForThread() { |
| 960 if (thread_ == NULL) return; | 1023 if (thread_ == NULL) return; |
| 961 if (Shell::options.last_run) { | 1024 if (Shell::options.last_run) { |
| 962 thread_->Join(); | 1025 thread_->Join(); |
| 963 thread_ = NULL; | 1026 thread_ = NULL; |
| 964 } else { | 1027 } else { |
| 965 done_semaphore_->Wait(); | 1028 done_semaphore_->Wait(); |
| 966 } | 1029 } |
| 967 } | 1030 } |
| 1031 #endif // D8_LIGHT | |
| 968 | 1032 |
| 969 | 1033 |
| 970 bool Shell::SetOptions(int argc, char* argv[]) { | 1034 bool Shell::SetOptions(int argc, char* argv[]) { |
| 971 for (int i = 0; i < argc; i++) { | 1035 for (int i = 0; i < argc; i++) { |
| 972 if (strcmp(argv[i], "--stress-opt") == 0) { | 1036 if (strcmp(argv[i], "--stress-opt") == 0) { |
| 973 options.stress_opt = true; | 1037 options.stress_opt = true; |
| 974 argv[i] = NULL; | 1038 argv[i] = NULL; |
| 975 } else if (strcmp(argv[i], "--stress-deopt") == 0) { | 1039 } else if (strcmp(argv[i], "--stress-deopt") == 0) { |
| 976 options.stress_deopt = true; | 1040 options.stress_deopt = true; |
| 977 argv[i] = NULL; | 1041 argv[i] = NULL; |
| 978 } else if (strcmp(argv[i], "--noalways-opt") == 0) { | 1042 } else if (strcmp(argv[i], "--noalways-opt") == 0) { |
| 979 // No support for stressing if we can't use --always-opt. | 1043 // No support for stressing if we can't use --always-opt. |
| 980 options.stress_opt = false; | 1044 options.stress_opt = false; |
| 981 options.stress_deopt = false; | 1045 options.stress_deopt = false; |
| 982 } else if (strcmp(argv[i], "--shell") == 0) { | 1046 } else if (strcmp(argv[i], "--shell") == 0) { |
| 983 options.interactive_shell = true; | 1047 options.interactive_shell = true; |
| 984 argv[i] = NULL; | 1048 argv[i] = NULL; |
| 985 } else if (strcmp(argv[i], "--test") == 0) { | 1049 } else if (strcmp(argv[i], "--test") == 0) { |
| 986 options.test_shell = true; | 1050 options.test_shell = true; |
| 987 argv[i] = NULL; | 1051 argv[i] = NULL; |
| 988 } else if (strcmp(argv[i], "--preemption") == 0) { | 1052 } else if (strcmp(argv[i], "--preemption") == 0) { |
|
Yang
2011/07/13 13:26:10
Many options are not supported by the light versio
| |
| 1053 #ifdef D8_LIGHT | |
| 1054 printf("D8 with shared library does not support multi-threading\n"); | |
| 1055 return false; | |
| 1056 #else | |
| 989 options.use_preemption = true; | 1057 options.use_preemption = true; |
| 990 argv[i] = NULL; | 1058 argv[i] = NULL; |
| 1059 #endif // D8_LIGHT | |
| 991 } else if (strcmp(argv[i], "--no-preemption") == 0) { | 1060 } else if (strcmp(argv[i], "--no-preemption") == 0) { |
| 1061 #ifdef D8_LIGHT | |
| 1062 printf("D8 with shared library does not support multi-threading\n"); | |
| 1063 return false; | |
| 1064 #else | |
| 992 options.use_preemption = false; | 1065 options.use_preemption = false; |
| 993 argv[i] = NULL; | 1066 argv[i] = NULL; |
| 1067 #endif // D8_LIGHT | |
| 994 } else if (strcmp(argv[i], "--preemption-interval") == 0) { | 1068 } else if (strcmp(argv[i], "--preemption-interval") == 0) { |
| 1069 #ifdef D8_LIGHT | |
| 1070 printf("D8 with shared library does not support multi-threading\n"); | |
| 1071 return false; | |
| 1072 #else | |
| 995 if (++i < argc) { | 1073 if (++i < argc) { |
| 996 argv[i-1] = NULL; | 1074 argv[i-1] = NULL; |
| 997 char* end = NULL; | 1075 char* end = NULL; |
| 998 options.preemption_interval = strtol(argv[i], &end, 10); // NOLINT | 1076 options.preemption_interval = strtol(argv[i], &end, 10); // NOLINT |
| 999 if (options.preemption_interval <= 0 | 1077 if (options.preemption_interval <= 0 |
| 1000 || *end != '\0' | 1078 || *end != '\0' |
| 1001 || errno == ERANGE) { | 1079 || errno == ERANGE) { |
| 1002 printf("Invalid value for --preemption-interval '%s'\n", argv[i]); | 1080 printf("Invalid value for --preemption-interval '%s'\n", argv[i]); |
| 1003 return false; | 1081 return false; |
| 1004 } | 1082 } |
| 1005 argv[i] = NULL; | 1083 argv[i] = NULL; |
| 1006 } else { | 1084 } else { |
| 1007 printf("Missing value for --preemption-interval\n"); | 1085 printf("Missing value for --preemption-interval\n"); |
| 1008 return false; | 1086 return false; |
| 1009 } | 1087 } |
| 1088 #endif // D8_LIGHT | |
| 1010 } else if (strcmp(argv[i], "-f") == 0) { | 1089 } else if (strcmp(argv[i], "-f") == 0) { |
| 1011 // Ignore any -f flags for compatibility with other stand-alone | 1090 // Ignore any -f flags for compatibility with other stand-alone |
| 1012 // JavaScript engines. | 1091 // JavaScript engines. |
| 1013 continue; | 1092 continue; |
| 1014 } else if (strcmp(argv[i], "--isolate") == 0) { | 1093 } else if (strcmp(argv[i], "--isolate") == 0) { |
| 1094 #ifdef D8_LIGHT | |
| 1095 printf("D8 with shared library does not support multi-threading\n"); | |
| 1096 return false; | |
| 1097 #endif // D8_LIGHT | |
| 1015 options.num_isolates++; | 1098 options.num_isolates++; |
| 1016 } | 1099 } |
| 1100 #ifdef D8_LIGHT | |
| 1101 else if (strcmp(argv[i], "--dump-counters") == 0) { | |
| 1102 printf("D8 with shared library does not include counters\n"); | |
| 1103 return false; | |
| 1104 } else if (strcmp(argv[i], "-p") == 0) { | |
| 1105 printf("D8 with shared library does not support multi-threading\n"); | |
| 1106 return false; | |
| 1107 } else if (strcmp(argv[i], "--debugger") == 0) { | |
| 1108 printf("Javascript debugger not included\n"); | |
| 1109 return false; | |
| 1110 } | |
| 1111 #endif // D8_LIGHT | |
| 1017 } | 1112 } |
| 1018 | 1113 |
| 1114 #ifndef D8_LIGHT | |
| 1019 // Run parallel threads if we are not using --isolate | 1115 // Run parallel threads if we are not using --isolate |
| 1020 for (int i = 1; i < argc; i++) { | 1116 for (int i = 1; i < argc; i++) { |
| 1021 if (argv[i] == NULL) continue; | 1117 if (argv[i] == NULL) continue; |
| 1022 if (strcmp(argv[i], "-p") == 0 && i + 1 < argc) { | 1118 if (strcmp(argv[i], "-p") == 0 && i + 1 < argc) { |
| 1023 if (options.num_isolates > 1) { | 1119 if (options.num_isolates > 1) { |
| 1024 printf("-p is not compatible with --isolate\n"); | 1120 printf("-p is not compatible with --isolate\n"); |
| 1025 return false; | 1121 return false; |
| 1026 } | 1122 } |
| 1027 argv[i] = NULL; | 1123 argv[i] = NULL; |
| 1028 if (options.parallel_files == NULL) { | 1124 if (options.parallel_files == NULL) { |
| 1029 options.parallel_files = new i::List<i::Vector<const char> >(); | 1125 options.parallel_files = new i::List<i::Vector<const char> >(); |
| 1030 } | 1126 } |
| 1031 int size = 0; | 1127 int size = 0; |
| 1032 const char* files = ReadChars(argv[++i], &size); | 1128 const char* files = ReadChars(argv[++i], &size); |
| 1033 if (files == NULL) { | 1129 if (files == NULL) { |
| 1034 printf("-p option incomplete\n"); | 1130 printf("-p option incomplete\n"); |
| 1035 return false; | 1131 return false; |
| 1036 } | 1132 } |
| 1037 argv[i] = NULL; | 1133 argv[i] = NULL; |
| 1038 options.parallel_files->Add(i::Vector<const char>(files, size)); | 1134 options.parallel_files->Add(i::Vector<const char>(files, size)); |
| 1039 } | 1135 } |
| 1040 } | 1136 } |
| 1137 #endif // D8_LIGHT | |
| 1041 | 1138 |
| 1042 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 1139 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
| 1043 | 1140 |
| 1044 // set up isolated source groups | 1141 // set up isolated source groups |
| 1045 options.isolate_sources = new SourceGroup[options.num_isolates]; | 1142 options.isolate_sources = new SourceGroup[options.num_isolates]; |
| 1046 SourceGroup* current = options.isolate_sources; | 1143 SourceGroup* current = options.isolate_sources; |
| 1047 current->Begin(argv, 1); | 1144 current->Begin(argv, 1); |
| 1048 for (int i = 1; i < argc; i++) { | 1145 for (int i = 1; i < argc; i++) { |
| 1049 const char* str = argv[i]; | 1146 const char* str = argv[i]; |
| 1050 if (strcmp(str, "--isolate") == 0) { | 1147 if (strcmp(str, "--isolate") == 0) { |
| 1051 current->End(i); | 1148 current->End(i); |
| 1052 current++; | 1149 current++; |
| 1053 current->Begin(argv, i + 1); | 1150 current->Begin(argv, i + 1); |
| 1054 } else if (strncmp(argv[i], "--", 2) == 0) { | 1151 } else if (strncmp(argv[i], "--", 2) == 0) { |
| 1055 printf("Warning: unknown flag %s.\nTry --help for options\n", argv[i]); | 1152 printf("Warning: unknown flag %s.\nTry --help for options\n", argv[i]); |
| 1056 } | 1153 } |
| 1057 } | 1154 } |
| 1058 current->End(argc); | 1155 current->End(argc); |
| 1059 | 1156 |
| 1060 return true; | 1157 return true; |
| 1061 } | 1158 } |
| 1062 | 1159 |
| 1063 | 1160 |
| 1064 int Shell::RunMain(int argc, char* argv[]) { | 1161 int Shell::RunMain(int argc, char* argv[]) { |
| 1162 #ifndef D8_LIGHT | |
| 1065 i::List<i::Thread*> threads(1); | 1163 i::List<i::Thread*> threads(1); |
| 1066 | 1164 #endif // D8_LIGHT |
| 1067 { | 1165 { |
| 1166 #ifndef D8_LIGHT | |
| 1068 if (options.parallel_files != NULL) | 1167 if (options.parallel_files != NULL) |
| 1069 for (int i = 0; i < options.parallel_files->length(); i++) { | 1168 for (int i = 0; i < options.parallel_files->length(); i++) { |
| 1070 i::Vector<const char> files = options.parallel_files->at(i); | 1169 i::Vector<const char> files = options.parallel_files->at(i); |
| 1071 ShellThread* thread = new ShellThread(threads.length(), files); | 1170 ShellThread* thread = new ShellThread(threads.length(), files); |
| 1072 thread->Start(); | 1171 thread->Start(); |
| 1073 threads.Add(thread); | 1172 threads.Add(thread); |
| 1074 } | 1173 } |
| 1075 | 1174 |
| 1076 for (int i = 1; i < options.num_isolates; ++i) { | 1175 for (int i = 1; i < options.num_isolates; ++i) { |
| 1077 options.isolate_sources[i].StartExecuteInThread(); | 1176 options.isolate_sources[i].StartExecuteInThread(); |
| 1078 } | 1177 } |
| 1178 #endif // D8_LIGHT | |
| 1079 | 1179 |
| 1080 Locker lock; | 1180 Locker lock; |
| 1081 HandleScope scope; | 1181 HandleScope scope; |
| 1082 Persistent<Context> context = CreateEvaluationContext(); | 1182 Persistent<Context> context = CreateEvaluationContext(); |
| 1083 { | 1183 { |
| 1084 Context::Scope cscope(context); | 1184 Context::Scope cscope(context); |
| 1085 options.isolate_sources[0].Execute(); | 1185 options.isolate_sources[0].Execute(); |
| 1086 } | 1186 } |
| 1087 if (options.last_run) { | 1187 if (options.last_run) { |
| 1088 // Keep using the same context in the interactive shell | 1188 // Keep using the same context in the interactive shell |
| 1089 evaluation_context_ = context; | 1189 evaluation_context_ = context; |
| 1090 } else { | 1190 } else { |
| 1091 context.Dispose(); | 1191 context.Dispose(); |
| 1092 } | 1192 } |
| 1193 | |
| 1194 #ifndef D8_LIGHT | |
| 1093 // Start preemption if threads have been created and preemption is enabled. | 1195 // Start preemption if threads have been created and preemption is enabled. |
| 1094 if (options.parallel_files != NULL | 1196 if (options.parallel_files != NULL |
| 1095 && threads.length() > 0 | 1197 && threads.length() > 0 |
| 1096 && options.use_preemption) { | 1198 && options.use_preemption) { |
| 1097 Locker::StartPreemption(options.preemption_interval); | 1199 Locker::StartPreemption(options.preemption_interval); |
| 1098 } | 1200 } |
| 1201 #endif // D8_LIGHT | |
| 1099 } | 1202 } |
| 1100 | 1203 |
| 1204 #ifndef D8_LIGHT | |
| 1101 for (int i = 1; i < options.num_isolates; ++i) { | 1205 for (int i = 1; i < options.num_isolates; ++i) { |
| 1102 options.isolate_sources[i].WaitForThread(); | 1206 options.isolate_sources[i].WaitForThread(); |
| 1103 } | 1207 } |
| 1104 | 1208 |
| 1105 if (options.parallel_files != NULL) | 1209 if (options.parallel_files != NULL) |
| 1106 for (int i = 0; i < threads.length(); i++) { | 1210 for (int i = 0; i < threads.length(); i++) { |
| 1107 i::Thread* thread = threads[i]; | 1211 i::Thread* thread = threads[i]; |
| 1108 thread->Join(); | 1212 thread->Join(); |
| 1109 delete thread; | 1213 delete thread; |
| 1110 } | 1214 } |
| 1111 | 1215 |
| 1112 OnExit(); | 1216 OnExit(); |
| 1217 #endif // D8_LIGHT | |
| 1113 return 0; | 1218 return 0; |
| 1114 } | 1219 } |
| 1115 | 1220 |
| 1116 | 1221 |
| 1117 int Shell::Main(int argc, char* argv[]) { | 1222 int Shell::Main(int argc, char* argv[]) { |
| 1118 if (!SetOptions(argc, argv)) return 1; | 1223 if (!SetOptions(argc, argv)) return 1; |
| 1119 Initialize(); | 1224 Initialize(); |
| 1120 | 1225 |
| 1121 int result = 0; | 1226 int result = 0; |
| 1122 if (options.stress_opt || options.stress_deopt) { | 1227 if (options.stress_opt || options.stress_deopt) { |
| 1123 Testing::SetStressRunType( | 1228 Testing::SetStressRunType( |
| 1124 options.stress_opt ? Testing::kStressTypeOpt | 1229 options.stress_opt ? Testing::kStressTypeOpt |
| 1125 : Testing::kStressTypeDeopt); | 1230 : Testing::kStressTypeDeopt); |
| 1126 int stress_runs = Testing::GetStressRuns(); | 1231 int stress_runs = Testing::GetStressRuns(); |
| 1127 for (int i = 0; i < stress_runs && result == 0; i++) { | 1232 for (int i = 0; i < stress_runs && result == 0; i++) { |
| 1128 printf("============ Stress %d/%d ============\n", i + 1, stress_runs); | 1233 printf("============ Stress %d/%d ============\n", i + 1, stress_runs); |
| 1129 Testing::PrepareStressRun(i); | 1234 Testing::PrepareStressRun(i); |
| 1130 options.last_run = (i == stress_runs - 1); | 1235 options.last_run = (i == stress_runs - 1); |
| 1131 result = RunMain(argc, argv); | 1236 result = RunMain(argc, argv); |
| 1132 } | 1237 } |
| 1133 printf("======== Full Deoptimization =======\n"); | 1238 printf("======== Full Deoptimization =======\n"); |
| 1134 Testing::DeoptimizeAll(); | 1239 Testing::DeoptimizeAll(); |
| 1135 } else { | 1240 } else { |
| 1136 result = RunMain(argc, argv); | 1241 result = RunMain(argc, argv); |
| 1137 } | 1242 } |
| 1138 | 1243 |
| 1139 #ifdef ENABLE_DEBUGGER_SUPPORT | 1244 |
| 1245 #if defined(D8_FULL) && defined(ENABLE_DEBUGGER_SUPPORT) | |
|
Søren Thygesen Gjesse
2011/07/13 14:12:38
D8_FULL is newer defined. Did you mean !defined(V8
| |
| 1140 // Run remote debugger if requested, but never on --test | 1246 // Run remote debugger if requested, but never on --test |
| 1141 if (i::FLAG_remote_debugger && !options.test_shell) { | 1247 if (i::FLAG_remote_debugger && !options.test_shell) { |
| 1142 InstallUtilityScript(); | 1248 InstallUtilityScript(); |
| 1143 RunRemoteDebugger(i::FLAG_debugger_port); | 1249 RunRemoteDebugger(i::FLAG_debugger_port); |
| 1144 return 0; | 1250 return 0; |
| 1145 } | 1251 } |
| 1146 #endif | 1252 #endif // D8_LIGHT && ENABLE_DEBUGGER_SUPPORT |
| 1147 | 1253 |
| 1148 // Run interactive shell if explicitly requested or if no script has been | 1254 // Run interactive shell if explicitly requested or if no script has been |
| 1149 // executed, but never on --test | 1255 // executed, but never on --test |
| 1150 | 1256 |
| 1151 if (( options.interactive_shell | 1257 if (( options.interactive_shell |
| 1152 || !options.script_executed ) | 1258 || !options.script_executed ) |
| 1153 && !options.test_shell ) { | 1259 && !options.test_shell ) { |
| 1260 #ifndef D8_LIGHT | |
| 1154 InstallUtilityScript(); | 1261 InstallUtilityScript(); |
| 1262 #endif // D8_LIGHT | |
| 1155 RunShell(); | 1263 RunShell(); |
| 1156 } | 1264 } |
| 1157 | 1265 |
| 1158 V8::Dispose(); | 1266 V8::Dispose(); |
| 1159 | 1267 |
| 1160 return result; | 1268 return result; |
| 1161 } | 1269 } |
| 1162 | 1270 |
| 1163 } // namespace v8 | 1271 } // namespace v8 |
| 1164 | 1272 |
| 1165 | 1273 |
| 1166 #ifndef GOOGLE3 | 1274 #ifndef GOOGLE3 |
| 1167 int main(int argc, char* argv[]) { | 1275 int main(int argc, char* argv[]) { |
| 1168 return v8::Shell::Main(argc, argv); | 1276 return v8::Shell::Main(argc, argv); |
| 1169 } | 1277 } |
| 1170 #endif | 1278 #endif |
| 1279 | |
| 1280 #undef D8_LIGHT | |
| 1281 #undef D8_FULL | |
|
Søren Thygesen Gjesse
2011/07/13 14:12:38
D8_FULL?
| |
| OLD | NEW |