| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 34 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 35 #include <bzlib.h> | 35 #include <bzlib.h> |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 #include <errno.h> | 38 #include <errno.h> |
| 39 #include <stdlib.h> | 39 #include <stdlib.h> |
| 40 #include <string.h> | 40 #include <string.h> |
| 41 #include <sys/stat.h> | 41 #include <sys/stat.h> |
| 42 | 42 |
| 43 // TODO(dcarney): remove | |
| 44 #define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW | |
| 45 #define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | |
| 46 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT | |
| 47 | |
| 48 #ifdef V8_SHARED | 43 #ifdef V8_SHARED |
| 49 #include <assert.h> | 44 #include <assert.h> |
| 50 #endif // V8_SHARED | 45 #endif // V8_SHARED |
| 51 | 46 |
| 52 #ifndef V8_SHARED | 47 #ifndef V8_SHARED |
| 53 #include <algorithm> | 48 #include <algorithm> |
| 54 #endif // !V8_SHARED | 49 #endif // !V8_SHARED |
| 55 | 50 |
| 56 #ifdef V8_SHARED | 51 #ifdef V8_SHARED |
| 57 #include "../include/v8-testing.h" | 52 #include "../include/v8-testing.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 v8::String::Utf8Value str(result); | 234 v8::String::Utf8Value str(result); |
| 240 fwrite(*str, sizeof(**str), str.length(), stdout); | 235 fwrite(*str, sizeof(**str), str.length(), stdout); |
| 241 printf("\n"); | 236 printf("\n"); |
| 242 } | 237 } |
| 243 #if !defined(V8_SHARED) | 238 #if !defined(V8_SHARED) |
| 244 } else { | 239 } else { |
| 245 v8::TryCatch try_catch; | 240 v8::TryCatch try_catch; |
| 246 v8::Local<v8::Context> context = | 241 v8::Local<v8::Context> context = |
| 247 v8::Local<v8::Context>::New(isolate, utility_context_); | 242 v8::Local<v8::Context>::New(isolate, utility_context_); |
| 248 v8::Context::Scope context_scope(context); | 243 v8::Context::Scope context_scope(context); |
| 249 Handle<Object> global = utility_context_->Global(); | 244 Handle<Object> global = context->Global(); |
| 250 Handle<Value> fun = global->Get(String::New("Stringify")); | 245 Handle<Value> fun = global->Get(String::New("Stringify")); |
| 251 Handle<Value> argv[1] = { result }; | 246 Handle<Value> argv[1] = { result }; |
| 252 Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv); | 247 Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv); |
| 253 if (try_catch.HasCaught()) return true; | 248 if (try_catch.HasCaught()) return true; |
| 254 v8::String::Utf8Value str(s); | 249 v8::String::Utf8Value str(s); |
| 255 fwrite(*str, sizeof(**str), str.length(), stdout); | 250 fwrite(*str, sizeof(**str), str.length(), stdout); |
| 256 printf("\n"); | 251 printf("\n"); |
| 257 } | 252 } |
| 258 #endif | 253 #endif |
| 259 } | 254 } |
| 260 return true; | 255 return true; |
| 261 } | 256 } |
| 262 } | 257 } |
| 263 } | 258 } |
| 264 | 259 |
| 265 | 260 |
| 266 PerIsolateData::RealmScope::RealmScope(PerIsolateData* data) : data_(data) { | 261 PerIsolateData::RealmScope::RealmScope(PerIsolateData* data) : data_(data) { |
| 267 data_->realm_count_ = 1; | 262 data_->realm_count_ = 1; |
| 268 data_->realm_current_ = 0; | 263 data_->realm_current_ = 0; |
| 269 data_->realm_switch_ = 0; | 264 data_->realm_switch_ = 0; |
| 270 data_->realms_ = new Persistent<Context>[1]; | 265 data_->realms_ = new Persistent<Context>[1]; |
| 271 data_->realms_[0] = | 266 data_->realms_[0].Reset(data_->isolate_, Context::GetEntered()); |
| 272 Persistent<Context>::New(data_->isolate_, Context::GetEntered()); | |
| 273 data_->realm_shared_.Clear(); | 267 data_->realm_shared_.Clear(); |
| 274 } | 268 } |
| 275 | 269 |
| 276 | 270 |
| 277 PerIsolateData::RealmScope::~RealmScope() { | 271 PerIsolateData::RealmScope::~RealmScope() { |
| 278 // Drop realms to avoid keeping them alive. | 272 // Drop realms to avoid keeping them alive. |
| 279 for (int i = 0; i < data_->realm_count_; ++i) | 273 for (int i = 0; i < data_->realm_count_; ++i) |
| 280 data_->realms_[i].Dispose(data_->isolate_); | 274 data_->realms_[i].Dispose(data_->isolate_); |
| 281 delete[] data_->realms_; | 275 delete[] data_->realms_; |
| 282 if (!data_->realm_shared_.IsEmpty()) | 276 if (!data_->realm_shared_.IsEmpty()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // (Note that properties of global objects cannot be read/written cross-realm.) | 313 // (Note that properties of global objects cannot be read/written cross-realm.) |
| 320 Handle<Value> Shell::RealmGlobal(const Arguments& args) { | 314 Handle<Value> Shell::RealmGlobal(const Arguments& args) { |
| 321 PerIsolateData* data = PerIsolateData::Get(args.GetIsolate()); | 315 PerIsolateData* data = PerIsolateData::Get(args.GetIsolate()); |
| 322 if (args.Length() < 1 || !args[0]->IsNumber()) { | 316 if (args.Length() < 1 || !args[0]->IsNumber()) { |
| 323 return Throw("Invalid argument"); | 317 return Throw("Invalid argument"); |
| 324 } | 318 } |
| 325 int index = args[0]->Uint32Value(); | 319 int index = args[0]->Uint32Value(); |
| 326 if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) { | 320 if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) { |
| 327 return Throw("Invalid realm index"); | 321 return Throw("Invalid realm index"); |
| 328 } | 322 } |
| 329 return data->realms_[index]->Global(); | 323 return |
| 324 Local<Context>::New(args.GetIsolate(), data->realms_[index])->Global(); |
| 330 } | 325 } |
| 331 | 326 |
| 332 | 327 |
| 333 // Realm.create() creates a new realm and returns its index. | 328 // Realm.create() creates a new realm and returns its index. |
| 334 Handle<Value> Shell::RealmCreate(const Arguments& args) { | 329 Handle<Value> Shell::RealmCreate(const Arguments& args) { |
| 335 Isolate* isolate = args.GetIsolate(); | 330 Isolate* isolate = args.GetIsolate(); |
| 336 PerIsolateData* data = PerIsolateData::Get(isolate); | 331 PerIsolateData* data = PerIsolateData::Get(isolate); |
| 337 Persistent<Context>* old_realms = data->realms_; | 332 Persistent<Context>* old_realms = data->realms_; |
| 338 int index = data->realm_count_; | 333 int index = data->realm_count_; |
| 339 data->realms_ = new Persistent<Context>[++data->realm_count_]; | 334 data->realms_ = new Persistent<Context>[++data->realm_count_]; |
| 340 for (int i = 0; i < index; ++i) data->realms_[i] = old_realms[i]; | 335 for (int i = 0; i < index; ++i) { |
| 336 data->realms_[i].Reset(isolate, old_realms[i]); |
| 337 } |
| 341 delete[] old_realms; | 338 delete[] old_realms; |
| 342 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); | 339 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); |
| 343 data->realms_[index] = Persistent<Context>::New( | 340 data->realms_[index].Reset( |
| 344 isolate, Context::New(isolate, NULL, global_template)); | 341 isolate, Context::New(isolate, NULL, global_template)); |
| 345 return Number::New(index); | 342 return Number::New(index); |
| 346 } | 343 } |
| 347 | 344 |
| 348 | 345 |
| 349 // Realm.dispose(i) disposes the reference to the realm i. | 346 // Realm.dispose(i) disposes the reference to the realm i. |
| 350 Handle<Value> Shell::RealmDispose(const Arguments& args) { | 347 Handle<Value> Shell::RealmDispose(const Arguments& args) { |
| 351 Isolate* isolate = args.GetIsolate(); | 348 Isolate* isolate = args.GetIsolate(); |
| 352 PerIsolateData* data = PerIsolateData::Get(isolate); | 349 PerIsolateData* data = PerIsolateData::Get(isolate); |
| 353 if (args.Length() < 1 || !args[0]->IsNumber()) { | 350 if (args.Length() < 1 || !args[0]->IsNumber()) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 if (data->realm_shared_.IsEmpty()) return Undefined(isolate); | 407 if (data->realm_shared_.IsEmpty()) return Undefined(isolate); |
| 411 return Local<Value>::New(isolate, data->realm_shared_); | 408 return Local<Value>::New(isolate, data->realm_shared_); |
| 412 } | 409 } |
| 413 | 410 |
| 414 void Shell::RealmSharedSet(Local<String> property, | 411 void Shell::RealmSharedSet(Local<String> property, |
| 415 Local<Value> value, | 412 Local<Value> value, |
| 416 const AccessorInfo& info) { | 413 const AccessorInfo& info) { |
| 417 Isolate* isolate = info.GetIsolate(); | 414 Isolate* isolate = info.GetIsolate(); |
| 418 PerIsolateData* data = PerIsolateData::Get(isolate); | 415 PerIsolateData* data = PerIsolateData::Get(isolate); |
| 419 if (!data->realm_shared_.IsEmpty()) data->realm_shared_.Dispose(isolate); | 416 if (!data->realm_shared_.IsEmpty()) data->realm_shared_.Dispose(isolate); |
| 420 data->realm_shared_ = Persistent<Value>::New(isolate, value); | 417 data->realm_shared_.Reset(isolate, value); |
| 421 } | 418 } |
| 422 | 419 |
| 423 | 420 |
| 424 Handle<Value> Shell::Print(const Arguments& args) { | 421 Handle<Value> Shell::Print(const Arguments& args) { |
| 425 Handle<Value> val = Write(args); | 422 Handle<Value> val = Write(args); |
| 426 printf("\n"); | 423 printf("\n"); |
| 427 fflush(stdout); | 424 fflush(stdout); |
| 428 return val; | 425 return val; |
| 429 } | 426 } |
| 430 | 427 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 | 536 |
| 540 | 537 |
| 541 Handle<Value> Shell::Version(const Arguments& args) { | 538 Handle<Value> Shell::Version(const Arguments& args) { |
| 542 return String::New(V8::GetVersion()); | 539 return String::New(V8::GetVersion()); |
| 543 } | 540 } |
| 544 | 541 |
| 545 | 542 |
| 546 void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) { | 543 void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) { |
| 547 HandleScope handle_scope(isolate); | 544 HandleScope handle_scope(isolate); |
| 548 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) | 545 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) |
| 546 Handle<Context> utility_context; |
| 549 bool enter_context = !Context::InContext(); | 547 bool enter_context = !Context::InContext(); |
| 550 if (enter_context) utility_context_->Enter(); | 548 if (enter_context) { |
| 549 utility_context = Local<Context>::New(isolate, utility_context_); |
| 550 utility_context->Enter(); |
| 551 } |
| 551 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT | 552 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT |
| 552 v8::String::Utf8Value exception(try_catch->Exception()); | 553 v8::String::Utf8Value exception(try_catch->Exception()); |
| 553 const char* exception_string = ToCString(exception); | 554 const char* exception_string = ToCString(exception); |
| 554 Handle<Message> message = try_catch->Message(); | 555 Handle<Message> message = try_catch->Message(); |
| 555 if (message.IsEmpty()) { | 556 if (message.IsEmpty()) { |
| 556 // V8 didn't provide any extra information about this error; just | 557 // V8 didn't provide any extra information about this error; just |
| 557 // print the exception. | 558 // print the exception. |
| 558 printf("%s\n", exception_string); | 559 printf("%s\n", exception_string); |
| 559 } else { | 560 } else { |
| 560 // Print (filename):(line number): (message). | 561 // Print (filename):(line number): (message). |
| (...skipping 16 matching lines...) Expand all Loading... |
| 577 } | 578 } |
| 578 printf("\n"); | 579 printf("\n"); |
| 579 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); | 580 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); |
| 580 if (stack_trace.length() > 0) { | 581 if (stack_trace.length() > 0) { |
| 581 const char* stack_trace_string = ToCString(stack_trace); | 582 const char* stack_trace_string = ToCString(stack_trace); |
| 582 printf("%s\n", stack_trace_string); | 583 printf("%s\n", stack_trace_string); |
| 583 } | 584 } |
| 584 } | 585 } |
| 585 printf("\n"); | 586 printf("\n"); |
| 586 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) | 587 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) |
| 587 if (enter_context) utility_context_->Exit(); | 588 if (enter_context) utility_context->Exit(); |
| 588 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT | 589 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT |
| 589 } | 590 } |
| 590 | 591 |
| 591 | 592 |
| 592 #ifndef V8_SHARED | 593 #ifndef V8_SHARED |
| 593 Handle<Array> Shell::GetCompletions(Isolate* isolate, | 594 Handle<Array> Shell::GetCompletions(Isolate* isolate, |
| 594 Handle<String> text, | 595 Handle<String> text, |
| 595 Handle<String> full) { | 596 Handle<String> full) { |
| 596 HandleScope handle_scope(isolate); | 597 HandleScope handle_scope(isolate); |
| 597 v8::Local<v8::Context> context = | 598 v8::Local<v8::Context> utility_context = |
| 598 v8::Local<v8::Context>::New(isolate, utility_context_); | 599 v8::Local<v8::Context>::New(isolate, utility_context_); |
| 599 v8::Context::Scope context_scope(context); | 600 v8::Context::Scope context_scope(utility_context); |
| 600 Handle<Object> global = utility_context_->Global(); | 601 Handle<Object> global = utility_context->Global(); |
| 601 Handle<Value> fun = global->Get(String::New("GetCompletions")); | 602 Handle<Value> fun = global->Get(String::New("GetCompletions")); |
| 602 static const int kArgc = 3; | 603 static const int kArgc = 3; |
| 603 Handle<Value> argv[kArgc] = { evaluation_context_->Global(), text, full }; | 604 v8::Local<v8::Context> evaluation_context = |
| 605 v8::Local<v8::Context>::New(isolate, evaluation_context_); |
| 606 Handle<Value> argv[kArgc] = { evaluation_context->Global(), text, full }; |
| 604 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); | 607 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); |
| 605 return handle_scope.Close(Handle<Array>::Cast(val)); | 608 return handle_scope.Close(Handle<Array>::Cast(val)); |
| 606 } | 609 } |
| 607 | 610 |
| 608 | 611 |
| 609 #ifdef ENABLE_DEBUGGER_SUPPORT | 612 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 610 Handle<Object> Shell::DebugMessageDetails(Isolate* isolate, | 613 Handle<Object> Shell::DebugMessageDetails(Isolate* isolate, |
| 611 Handle<String> message) { | 614 Handle<String> message) { |
| 612 HandleScope handle_scope(isolate); | 615 HandleScope handle_scope(isolate); |
| 613 v8::Local<v8::Context> context = | 616 v8::Local<v8::Context> context = |
| 614 v8::Local<v8::Context>::New(isolate, utility_context_); | 617 v8::Local<v8::Context>::New(isolate, utility_context_); |
| 615 v8::Context::Scope context_scope(context); | 618 v8::Context::Scope context_scope(context); |
| 616 Handle<Object> global = utility_context_->Global(); | 619 Handle<Object> global = context->Global(); |
| 617 Handle<Value> fun = global->Get(String::New("DebugMessageDetails")); | 620 Handle<Value> fun = global->Get(String::New("DebugMessageDetails")); |
| 618 static const int kArgc = 1; | 621 static const int kArgc = 1; |
| 619 Handle<Value> argv[kArgc] = { message }; | 622 Handle<Value> argv[kArgc] = { message }; |
| 620 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); | 623 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); |
| 621 return Handle<Object>::Cast(val); | 624 return Handle<Object>::Cast(val); |
| 622 } | 625 } |
| 623 | 626 |
| 624 | 627 |
| 625 Handle<Value> Shell::DebugCommandToJSONRequest(Isolate* isolate, | 628 Handle<Value> Shell::DebugCommandToJSONRequest(Isolate* isolate, |
| 626 Handle<String> command) { | 629 Handle<String> command) { |
| 627 HandleScope handle_scope(isolate); | 630 HandleScope handle_scope(isolate); |
| 628 v8::Local<v8::Context> context = | 631 v8::Local<v8::Context> context = |
| 629 v8::Local<v8::Context>::New(isolate, utility_context_); | 632 v8::Local<v8::Context>::New(isolate, utility_context_); |
| 630 v8::Context::Scope context_scope(context); | 633 v8::Context::Scope context_scope(context); |
| 631 Handle<Object> global = utility_context_->Global(); | 634 Handle<Object> global = context->Global(); |
| 632 Handle<Value> fun = global->Get(String::New("DebugCommandToJSONRequest")); | 635 Handle<Value> fun = global->Get(String::New("DebugCommandToJSONRequest")); |
| 633 static const int kArgc = 1; | 636 static const int kArgc = 1; |
| 634 Handle<Value> argv[kArgc] = { command }; | 637 Handle<Value> argv[kArgc] = { command }; |
| 635 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); | 638 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); |
| 636 return val; | 639 return val; |
| 637 } | 640 } |
| 638 | 641 |
| 639 | 642 |
| 640 void Shell::DispatchDebugMessages() { | 643 void Shell::DispatchDebugMessages() { |
| 641 Isolate* isolate = v8::Isolate::GetCurrent(); | 644 Isolate* isolate = v8::Isolate::GetCurrent(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 Counter* counter = reinterpret_cast<Counter*>(histogram); | 749 Counter* counter = reinterpret_cast<Counter*>(histogram); |
| 747 counter->AddSample(sample); | 750 counter->AddSample(sample); |
| 748 } | 751 } |
| 749 | 752 |
| 750 | 753 |
| 751 void Shell::InstallUtilityScript(Isolate* isolate) { | 754 void Shell::InstallUtilityScript(Isolate* isolate) { |
| 752 Locker lock(isolate); | 755 Locker lock(isolate); |
| 753 HandleScope scope(isolate); | 756 HandleScope scope(isolate); |
| 754 // If we use the utility context, we have to set the security tokens so that | 757 // If we use the utility context, we have to set the security tokens so that |
| 755 // utility, evaluation and debug context can all access each other. | 758 // utility, evaluation and debug context can all access each other. |
| 756 utility_context_->SetSecurityToken(Undefined(isolate)); | 759 v8::Local<v8::Context> utility_context = |
| 757 evaluation_context_->SetSecurityToken(Undefined(isolate)); | |
| 758 v8::Local<v8::Context> context = | |
| 759 v8::Local<v8::Context>::New(isolate, utility_context_); | 760 v8::Local<v8::Context>::New(isolate, utility_context_); |
| 760 v8::Context::Scope context_scope(context); | 761 v8::Local<v8::Context> evaluation_context = |
| 762 v8::Local<v8::Context>::New(isolate, evaluation_context_); |
| 763 utility_context->SetSecurityToken(Undefined(isolate)); |
| 764 evaluation_context->SetSecurityToken(Undefined(isolate)); |
| 765 v8::Context::Scope context_scope(utility_context); |
| 761 | 766 |
| 762 #ifdef ENABLE_DEBUGGER_SUPPORT | 767 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 763 if (i::FLAG_debugger) printf("JavaScript debugger enabled\n"); | 768 if (i::FLAG_debugger) printf("JavaScript debugger enabled\n"); |
| 764 // Install the debugger object in the utility scope | 769 // Install the debugger object in the utility scope |
| 765 i::Debug* debug = i::Isolate::Current()->debug(); | 770 i::Debug* debug = i::Isolate::Current()->debug(); |
| 766 debug->Load(); | 771 debug->Load(); |
| 767 i::Handle<i::JSObject> js_debug | 772 i::Handle<i::JSObject> js_debug |
| 768 = i::Handle<i::JSObject>(debug->debug_context()->global_object()); | 773 = i::Handle<i::JSObject>(debug->debug_context()->global_object()); |
| 769 utility_context_->Global()->Set(String::New("$debug"), | 774 utility_context->Global()->Set(String::New("$debug"), |
| 770 Utils::ToLocal(js_debug)); | 775 Utils::ToLocal(js_debug)); |
| 771 debug->debug_context()->set_security_token(HEAP->undefined_value()); | 776 debug->debug_context()->set_security_token(HEAP->undefined_value()); |
| 772 #endif // ENABLE_DEBUGGER_SUPPORT | 777 #endif // ENABLE_DEBUGGER_SUPPORT |
| 773 | 778 |
| 774 // Run the d8 shell utility script in the utility context | 779 // Run the d8 shell utility script in the utility context |
| 775 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); | 780 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); |
| 776 i::Vector<const char> shell_source = | 781 i::Vector<const char> shell_source = |
| 777 i::NativesCollection<i::D8>::GetRawScriptSource(source_index); | 782 i::NativesCollection<i::D8>::GetRawScriptSource(source_index); |
| 778 i::Vector<const char> shell_source_name = | 783 i::Vector<const char> shell_source_name = |
| 779 i::NativesCollection<i::D8>::GetScriptName(source_index); | 784 i::NativesCollection<i::D8>::GetScriptName(source_index); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 return Throw("Error loading file"); | 1084 return Throw("Error loading file"); |
| 1080 } | 1085 } |
| 1081 | 1086 |
| 1082 Isolate* isolate = args.GetIsolate(); | 1087 Isolate* isolate = args.GetIsolate(); |
| 1083 uint8_t* data = reinterpret_cast<uint8_t*>( | 1088 uint8_t* data = reinterpret_cast<uint8_t*>( |
| 1084 ReadChars(args.GetIsolate(), *filename, &length)); | 1089 ReadChars(args.GetIsolate(), *filename, &length)); |
| 1085 if (data == NULL) { | 1090 if (data == NULL) { |
| 1086 return Throw("Error reading file"); | 1091 return Throw("Error reading file"); |
| 1087 } | 1092 } |
| 1088 Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(data, length); | 1093 Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(data, length); |
| 1089 v8::Persistent<v8::Value> weak_handle = | 1094 v8::Persistent<v8::Value> weak_handle(isolate, buffer); |
| 1090 v8::Persistent<v8::Value>::New(isolate, buffer); | |
| 1091 weak_handle.MakeWeak(isolate, data, ReadBufferWeakCallback); | 1095 weak_handle.MakeWeak(isolate, data, ReadBufferWeakCallback); |
| 1092 weak_handle.MarkIndependent(); | 1096 weak_handle.MarkIndependent(); |
| 1093 isolate->AdjustAmountOfExternalAllocatedMemory(length); | 1097 isolate->AdjustAmountOfExternalAllocatedMemory(length); |
| 1094 | 1098 |
| 1095 return buffer; | 1099 return buffer; |
| 1096 } | 1100 } |
| 1097 | 1101 |
| 1098 | 1102 |
| 1099 #ifndef V8_SHARED | 1103 #ifndef V8_SHARED |
| 1100 static char* ReadToken(char* data, char token) { | 1104 static char* ReadToken(char* data, char token) { |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 } | 1635 } |
| 1632 | 1636 |
| 1633 } // namespace v8 | 1637 } // namespace v8 |
| 1634 | 1638 |
| 1635 | 1639 |
| 1636 #ifndef GOOGLE3 | 1640 #ifndef GOOGLE3 |
| 1637 int main(int argc, char* argv[]) { | 1641 int main(int argc, char* argv[]) { |
| 1638 return v8::Shell::Main(argc, argv); | 1642 return v8::Shell::Main(argc, argv); |
| 1639 } | 1643 } |
| 1640 #endif | 1644 #endif |
| OLD | NEW |