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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 280 |
281 int PerIsolateData::RealmFind(Handle<Context> context) { | 281 int PerIsolateData::RealmFind(Handle<Context> context) { |
282 for (int i = 0; i < realm_count_; ++i) { | 282 for (int i = 0; i < realm_count_; ++i) { |
283 if (realms_[i] == context) return i; | 283 if (realms_[i] == context) return i; |
284 } | 284 } |
285 return -1; | 285 return -1; |
286 } | 286 } |
287 | 287 |
288 | 288 |
289 // Realm.current() returns the index of the currently active realm. | 289 // Realm.current() returns the index of the currently active realm. |
290 Handle<Value> Shell::RealmCurrent(const Arguments& args) { | 290 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { |
291 Isolate* isolate = args.GetIsolate(); | 291 Isolate* isolate = args.GetIsolate(); |
292 PerIsolateData* data = PerIsolateData::Get(isolate); | 292 PerIsolateData* data = PerIsolateData::Get(isolate); |
293 int index = data->RealmFind(Context::GetEntered()); | 293 int index = data->RealmFind(Context::GetEntered()); |
294 if (index == -1) return Undefined(isolate); | 294 if (index == -1) return; |
295 return Number::New(index); | 295 args.GetReturnValue().Set(index); |
296 } | 296 } |
297 | 297 |
298 | 298 |
299 // Realm.owner(o) returns the index of the realm that created o. | 299 // Realm.owner(o) returns the index of the realm that created o. |
300 Handle<Value> Shell::RealmOwner(const Arguments& args) { | 300 void Shell::RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args) { |
301 Isolate* isolate = args.GetIsolate(); | 301 Isolate* isolate = args.GetIsolate(); |
302 PerIsolateData* data = PerIsolateData::Get(isolate); | 302 PerIsolateData* data = PerIsolateData::Get(isolate); |
303 if (args.Length() < 1 || !args[0]->IsObject()) { | 303 if (args.Length() < 1 || !args[0]->IsObject()) { |
304 return Throw("Invalid argument"); | 304 Throw("Invalid argument"); |
| 305 return; |
305 } | 306 } |
306 int index = data->RealmFind(args[0]->ToObject()->CreationContext()); | 307 int index = data->RealmFind(args[0]->ToObject()->CreationContext()); |
307 if (index == -1) return Undefined(isolate); | 308 if (index == -1) return; |
308 return Number::New(index); | 309 args.GetReturnValue().Set(index); |
309 } | 310 } |
310 | 311 |
311 | 312 |
312 // Realm.global(i) returns the global object of realm i. | 313 // Realm.global(i) returns the global object of realm i. |
313 // (Note that properties of global objects cannot be read/written cross-realm.) | 314 // (Note that properties of global objects cannot be read/written cross-realm.) |
314 Handle<Value> Shell::RealmGlobal(const Arguments& args) { | 315 void Shell::RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) { |
315 PerIsolateData* data = PerIsolateData::Get(args.GetIsolate()); | 316 PerIsolateData* data = PerIsolateData::Get(args.GetIsolate()); |
316 if (args.Length() < 1 || !args[0]->IsNumber()) { | 317 if (args.Length() < 1 || !args[0]->IsNumber()) { |
317 return Throw("Invalid argument"); | 318 Throw("Invalid argument"); |
| 319 return; |
318 } | 320 } |
319 int index = args[0]->Uint32Value(); | 321 int index = args[0]->Uint32Value(); |
320 if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) { | 322 if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) { |
321 return Throw("Invalid realm index"); | 323 Throw("Invalid realm index"); |
| 324 return; |
322 } | 325 } |
323 return | 326 args.GetReturnValue().Set( |
324 Local<Context>::New(args.GetIsolate(), data->realms_[index])->Global(); | 327 Local<Context>::New(args.GetIsolate(), data->realms_[index])->Global()); |
325 } | 328 } |
326 | 329 |
327 | 330 |
328 // Realm.create() creates a new realm and returns its index. | 331 // Realm.create() creates a new realm and returns its index. |
329 Handle<Value> Shell::RealmCreate(const Arguments& args) { | 332 void Shell::RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args) { |
330 Isolate* isolate = args.GetIsolate(); | 333 Isolate* isolate = args.GetIsolate(); |
331 PerIsolateData* data = PerIsolateData::Get(isolate); | 334 PerIsolateData* data = PerIsolateData::Get(isolate); |
332 Persistent<Context>* old_realms = data->realms_; | 335 Persistent<Context>* old_realms = data->realms_; |
333 int index = data->realm_count_; | 336 int index = data->realm_count_; |
334 data->realms_ = new Persistent<Context>[++data->realm_count_]; | 337 data->realms_ = new Persistent<Context>[++data->realm_count_]; |
335 for (int i = 0; i < index; ++i) { | 338 for (int i = 0; i < index; ++i) { |
336 data->realms_[i].Reset(isolate, old_realms[i]); | 339 data->realms_[i].Reset(isolate, old_realms[i]); |
337 } | 340 } |
338 delete[] old_realms; | 341 delete[] old_realms; |
339 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); | 342 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); |
340 data->realms_[index].Reset( | 343 data->realms_[index].Reset( |
341 isolate, Context::New(isolate, NULL, global_template)); | 344 isolate, Context::New(isolate, NULL, global_template)); |
342 return Number::New(index); | 345 args.GetReturnValue().Set(index); |
343 } | 346 } |
344 | 347 |
345 | 348 |
346 // Realm.dispose(i) disposes the reference to the realm i. | 349 // Realm.dispose(i) disposes the reference to the realm i. |
347 Handle<Value> Shell::RealmDispose(const Arguments& args) { | 350 void Shell::RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args) { |
348 Isolate* isolate = args.GetIsolate(); | 351 Isolate* isolate = args.GetIsolate(); |
349 PerIsolateData* data = PerIsolateData::Get(isolate); | 352 PerIsolateData* data = PerIsolateData::Get(isolate); |
350 if (args.Length() < 1 || !args[0]->IsNumber()) { | 353 if (args.Length() < 1 || !args[0]->IsNumber()) { |
351 return Throw("Invalid argument"); | 354 Throw("Invalid argument"); |
| 355 return; |
352 } | 356 } |
353 int index = args[0]->Uint32Value(); | 357 int index = args[0]->Uint32Value(); |
354 if (index >= data->realm_count_ || data->realms_[index].IsEmpty() || | 358 if (index >= data->realm_count_ || data->realms_[index].IsEmpty() || |
355 index == 0 || | 359 index == 0 || |
356 index == data->realm_current_ || index == data->realm_switch_) { | 360 index == data->realm_current_ || index == data->realm_switch_) { |
357 return Throw("Invalid realm index"); | 361 Throw("Invalid realm index"); |
| 362 return; |
358 } | 363 } |
359 data->realms_[index].Dispose(isolate); | 364 data->realms_[index].Dispose(isolate); |
360 data->realms_[index].Clear(); | 365 data->realms_[index].Clear(); |
361 return Undefined(isolate); | |
362 } | 366 } |
363 | 367 |
364 | 368 |
365 // Realm.switch(i) switches to the realm i for consecutive interactive inputs. | 369 // Realm.switch(i) switches to the realm i for consecutive interactive inputs. |
366 Handle<Value> Shell::RealmSwitch(const Arguments& args) { | 370 void Shell::RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args) { |
367 Isolate* isolate = args.GetIsolate(); | 371 Isolate* isolate = args.GetIsolate(); |
368 PerIsolateData* data = PerIsolateData::Get(isolate); | 372 PerIsolateData* data = PerIsolateData::Get(isolate); |
369 if (args.Length() < 1 || !args[0]->IsNumber()) { | 373 if (args.Length() < 1 || !args[0]->IsNumber()) { |
370 return Throw("Invalid argument"); | 374 Throw("Invalid argument"); |
| 375 return; |
371 } | 376 } |
372 int index = args[0]->Uint32Value(); | 377 int index = args[0]->Uint32Value(); |
373 if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) { | 378 if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) { |
374 return Throw("Invalid realm index"); | 379 Throw("Invalid realm index"); |
| 380 return; |
375 } | 381 } |
376 data->realm_switch_ = index; | 382 data->realm_switch_ = index; |
377 return Undefined(isolate); | |
378 } | 383 } |
379 | 384 |
380 | 385 |
381 // Realm.eval(i, s) evaluates s in realm i and returns the result. | 386 // Realm.eval(i, s) evaluates s in realm i and returns the result. |
382 Handle<Value> Shell::RealmEval(const Arguments& args) { | 387 void Shell::RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args) { |
383 Isolate* isolate = args.GetIsolate(); | 388 Isolate* isolate = args.GetIsolate(); |
384 PerIsolateData* data = PerIsolateData::Get(isolate); | 389 PerIsolateData* data = PerIsolateData::Get(isolate); |
385 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsString()) { | 390 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsString()) { |
386 return Throw("Invalid argument"); | 391 Throw("Invalid argument"); |
| 392 return; |
387 } | 393 } |
388 int index = args[0]->Uint32Value(); | 394 int index = args[0]->Uint32Value(); |
389 if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) { | 395 if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) { |
390 return Throw("Invalid realm index"); | 396 Throw("Invalid realm index"); |
| 397 return; |
391 } | 398 } |
392 Handle<Script> script = Script::New(args[1]->ToString()); | 399 Handle<Script> script = Script::New(args[1]->ToString()); |
393 if (script.IsEmpty()) return Undefined(isolate); | 400 if (script.IsEmpty()) return; |
394 Local<Context> realm = Local<Context>::New(isolate, data->realms_[index]); | 401 Local<Context> realm = Local<Context>::New(isolate, data->realms_[index]); |
395 realm->Enter(); | 402 realm->Enter(); |
396 Handle<Value> result = script->Run(); | 403 Handle<Value> result = script->Run(); |
397 realm->Exit(); | 404 realm->Exit(); |
398 return result; | 405 args.GetReturnValue().Set(result); |
399 } | 406 } |
400 | 407 |
401 | 408 |
402 // Realm.shared is an accessor for a single shared value across realms. | 409 // Realm.shared is an accessor for a single shared value across realms. |
403 Handle<Value> Shell::RealmSharedGet(Local<String> property, | 410 void Shell::RealmSharedGet(Local<String> property, |
404 const AccessorInfo& info) { | 411 const PropertyCallbackInfo<Value>& info) { |
405 Isolate* isolate = info.GetIsolate(); | 412 Isolate* isolate = info.GetIsolate(); |
406 PerIsolateData* data = PerIsolateData::Get(isolate); | 413 PerIsolateData* data = PerIsolateData::Get(isolate); |
407 if (data->realm_shared_.IsEmpty()) return Undefined(isolate); | 414 if (data->realm_shared_.IsEmpty()) return; |
408 return Local<Value>::New(isolate, data->realm_shared_); | 415 info.GetReturnValue().Set(data->realm_shared_); |
409 } | 416 } |
410 | 417 |
411 void Shell::RealmSharedSet(Local<String> property, | 418 void Shell::RealmSharedSet(Local<String> property, |
412 Local<Value> value, | 419 Local<Value> value, |
413 const AccessorInfo& info) { | 420 const PropertyCallbackInfo<void>& info) { |
414 Isolate* isolate = info.GetIsolate(); | 421 Isolate* isolate = info.GetIsolate(); |
415 PerIsolateData* data = PerIsolateData::Get(isolate); | 422 PerIsolateData* data = PerIsolateData::Get(isolate); |
416 if (!data->realm_shared_.IsEmpty()) data->realm_shared_.Dispose(isolate); | 423 if (!data->realm_shared_.IsEmpty()) data->realm_shared_.Dispose(isolate); |
417 data->realm_shared_.Reset(isolate, value); | 424 data->realm_shared_.Reset(isolate, value); |
418 } | 425 } |
419 | 426 |
420 | 427 |
421 Handle<Value> Shell::Print(const Arguments& args) { | 428 void Shell::Print(const v8::FunctionCallbackInfo<v8::Value>& args) { |
422 Handle<Value> val = Write(args); | 429 Write(args); |
423 printf("\n"); | 430 printf("\n"); |
424 fflush(stdout); | 431 fflush(stdout); |
425 return val; | |
426 } | 432 } |
427 | 433 |
428 | 434 |
429 Handle<Value> Shell::Write(const Arguments& args) { | 435 void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) { |
430 for (int i = 0; i < args.Length(); i++) { | 436 for (int i = 0; i < args.Length(); i++) { |
431 HandleScope handle_scope(args.GetIsolate()); | 437 HandleScope handle_scope(args.GetIsolate()); |
432 if (i != 0) { | 438 if (i != 0) { |
433 printf(" "); | 439 printf(" "); |
434 } | 440 } |
435 | 441 |
436 // Explicitly catch potential exceptions in toString(). | 442 // Explicitly catch potential exceptions in toString(). |
437 v8::TryCatch try_catch; | 443 v8::TryCatch try_catch; |
438 Handle<String> str_obj = args[i]->ToString(); | 444 Handle<String> str_obj = args[i]->ToString(); |
439 if (try_catch.HasCaught()) return try_catch.ReThrow(); | 445 if (try_catch.HasCaught()) { |
| 446 try_catch.ReThrow(); |
| 447 return; |
| 448 } |
440 | 449 |
441 v8::String::Utf8Value str(str_obj); | 450 v8::String::Utf8Value str(str_obj); |
442 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); | 451 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); |
443 if (n != str.length()) { | 452 if (n != str.length()) { |
444 printf("Error in fwrite\n"); | 453 printf("Error in fwrite\n"); |
445 Exit(1); | 454 Exit(1); |
446 } | 455 } |
447 } | 456 } |
448 return Undefined(args.GetIsolate()); | |
449 } | 457 } |
450 | 458 |
451 | 459 |
452 Handle<Value> Shell::EnableProfiler(const Arguments& args) { | 460 void Shell::EnableProfiler(const v8::FunctionCallbackInfo<v8::Value>& args) { |
453 V8::ResumeProfiler(); | 461 V8::ResumeProfiler(); |
454 return Undefined(args.GetIsolate()); | |
455 } | 462 } |
456 | 463 |
457 | 464 |
458 Handle<Value> Shell::DisableProfiler(const Arguments& args) { | 465 void Shell::DisableProfiler(const v8::FunctionCallbackInfo<v8::Value>& args) { |
459 V8::PauseProfiler(); | 466 V8::PauseProfiler(); |
460 return Undefined(args.GetIsolate()); | |
461 } | 467 } |
462 | 468 |
463 | 469 |
464 Handle<Value> Shell::Read(const Arguments& args) { | 470 void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) { |
465 String::Utf8Value file(args[0]); | 471 String::Utf8Value file(args[0]); |
466 if (*file == NULL) { | 472 if (*file == NULL) { |
467 return Throw("Error loading file"); | 473 Throw("Error loading file"); |
| 474 return; |
468 } | 475 } |
469 Handle<String> source = ReadFile(args.GetIsolate(), *file); | 476 Handle<String> source = ReadFile(args.GetIsolate(), *file); |
470 if (source.IsEmpty()) { | 477 if (source.IsEmpty()) { |
471 return Throw("Error loading file"); | 478 Throw("Error loading file"); |
| 479 return; |
472 } | 480 } |
473 return source; | 481 args.GetReturnValue().Set(source); |
474 } | 482 } |
475 | 483 |
476 | 484 |
477 Handle<String> Shell::ReadFromStdin(Isolate* isolate) { | 485 Handle<String> Shell::ReadFromStdin(Isolate* isolate) { |
478 static const int kBufferSize = 256; | 486 static const int kBufferSize = 256; |
479 char buffer[kBufferSize]; | 487 char buffer[kBufferSize]; |
480 Handle<String> accumulator = String::New(""); | 488 Handle<String> accumulator = String::New(""); |
481 int length; | 489 int length; |
482 while (true) { | 490 while (true) { |
483 // Continue reading if the line ends with an escape '\\' or the line has | 491 // Continue reading if the line ends with an escape '\\' or the line has |
(...skipping 13 matching lines...) Expand all Loading... |
497 } else if (length > 1 && buffer[length-2] == '\\') { | 505 } else if (length > 1 && buffer[length-2] == '\\') { |
498 buffer[length-2] = '\n'; | 506 buffer[length-2] = '\n'; |
499 accumulator = String::Concat(accumulator, String::New(buffer, length-1)); | 507 accumulator = String::Concat(accumulator, String::New(buffer, length-1)); |
500 } else { | 508 } else { |
501 return String::Concat(accumulator, String::New(buffer, length-1)); | 509 return String::Concat(accumulator, String::New(buffer, length-1)); |
502 } | 510 } |
503 } | 511 } |
504 } | 512 } |
505 | 513 |
506 | 514 |
507 Handle<Value> Shell::Load(const Arguments& args) { | 515 void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) { |
508 for (int i = 0; i < args.Length(); i++) { | 516 for (int i = 0; i < args.Length(); i++) { |
509 HandleScope handle_scope(args.GetIsolate()); | 517 HandleScope handle_scope(args.GetIsolate()); |
510 String::Utf8Value file(args[i]); | 518 String::Utf8Value file(args[i]); |
511 if (*file == NULL) { | 519 if (*file == NULL) { |
512 return Throw("Error loading file"); | 520 Throw("Error loading file"); |
| 521 return; |
513 } | 522 } |
514 Handle<String> source = ReadFile(args.GetIsolate(), *file); | 523 Handle<String> source = ReadFile(args.GetIsolate(), *file); |
515 if (source.IsEmpty()) { | 524 if (source.IsEmpty()) { |
516 return Throw("Error loading file"); | 525 Throw("Error loading file"); |
| 526 return; |
517 } | 527 } |
518 if (!ExecuteString(args.GetIsolate(), | 528 if (!ExecuteString(args.GetIsolate(), |
519 source, | 529 source, |
520 String::New(*file), | 530 String::New(*file), |
521 false, | 531 false, |
522 true)) { | 532 true)) { |
523 return Throw("Error executing file"); | 533 Throw("Error executing file"); |
| 534 return; |
524 } | 535 } |
525 } | 536 } |
526 return Undefined(args.GetIsolate()); | |
527 } | 537 } |
528 | 538 |
529 | 539 |
530 Handle<Value> Shell::Quit(const Arguments& args) { | 540 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { |
531 int exit_code = args[0]->Int32Value(); | 541 int exit_code = args[0]->Int32Value(); |
532 OnExit(); | 542 OnExit(); |
533 exit(exit_code); | 543 exit(exit_code); |
534 return Undefined(args.GetIsolate()); | |
535 } | 544 } |
536 | 545 |
537 | 546 |
538 Handle<Value> Shell::Version(const Arguments& args) { | 547 void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) { |
539 return String::New(V8::GetVersion()); | 548 args.GetReturnValue().Set(String::New(V8::GetVersion())); |
540 } | 549 } |
541 | 550 |
542 | 551 |
543 void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) { | 552 void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) { |
544 HandleScope handle_scope(isolate); | 553 HandleScope handle_scope(isolate); |
545 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) | 554 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) |
546 Handle<Context> utility_context; | 555 Handle<Context> utility_context; |
547 bool enter_context = !Context::InContext(); | 556 bool enter_context = !Context::InContext(); |
548 if (enter_context) { | 557 if (enter_context) { |
549 utility_context = Local<Context>::New(isolate, utility_context_); | 558 utility_context = Local<Context>::New(isolate, utility_context_); |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 Persistent<Value>* object, | 1079 Persistent<Value>* object, |
1071 uint8_t* data) { | 1080 uint8_t* data) { |
1072 size_t byte_length = ArrayBuffer::Cast(**object)->ByteLength(); | 1081 size_t byte_length = ArrayBuffer::Cast(**object)->ByteLength(); |
1073 isolate->AdjustAmountOfExternalAllocatedMemory( | 1082 isolate->AdjustAmountOfExternalAllocatedMemory( |
1074 -static_cast<intptr_t>(byte_length)); | 1083 -static_cast<intptr_t>(byte_length)); |
1075 | 1084 |
1076 delete[] data; | 1085 delete[] data; |
1077 object->Dispose(isolate); | 1086 object->Dispose(isolate); |
1078 } | 1087 } |
1079 | 1088 |
1080 Handle<Value> Shell::ReadBuffer(const Arguments& args) { | 1089 void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) { |
1081 ASSERT(sizeof(char) == sizeof(uint8_t)); // NOLINT | 1090 ASSERT(sizeof(char) == sizeof(uint8_t)); // NOLINT |
1082 String::Utf8Value filename(args[0]); | 1091 String::Utf8Value filename(args[0]); |
1083 int length; | 1092 int length; |
1084 if (*filename == NULL) { | 1093 if (*filename == NULL) { |
1085 return Throw("Error loading file"); | 1094 Throw("Error loading file"); |
| 1095 return; |
1086 } | 1096 } |
1087 | 1097 |
1088 Isolate* isolate = args.GetIsolate(); | 1098 Isolate* isolate = args.GetIsolate(); |
1089 uint8_t* data = reinterpret_cast<uint8_t*>( | 1099 uint8_t* data = reinterpret_cast<uint8_t*>( |
1090 ReadChars(args.GetIsolate(), *filename, &length)); | 1100 ReadChars(args.GetIsolate(), *filename, &length)); |
1091 if (data == NULL) { | 1101 if (data == NULL) { |
1092 return Throw("Error reading file"); | 1102 Throw("Error reading file"); |
| 1103 return; |
1093 } | 1104 } |
1094 Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(data, length); | 1105 Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(data, length); |
1095 v8::Persistent<v8::Value> weak_handle(isolate, buffer); | 1106 v8::Persistent<v8::Value> weak_handle(isolate, buffer); |
1096 weak_handle.MakeWeak(isolate, data, ReadBufferWeakCallback); | 1107 weak_handle.MakeWeak(isolate, data, ReadBufferWeakCallback); |
1097 weak_handle.MarkIndependent(); | 1108 weak_handle.MarkIndependent(); |
1098 isolate->AdjustAmountOfExternalAllocatedMemory(length); | 1109 isolate->AdjustAmountOfExternalAllocatedMemory(length); |
1099 | 1110 |
1100 return buffer; | 1111 args.GetReturnValue().Set(buffer); |
1101 } | 1112 } |
1102 | 1113 |
1103 | 1114 |
1104 #ifndef V8_SHARED | 1115 #ifndef V8_SHARED |
1105 static char* ReadToken(char* data, char token) { | 1116 static char* ReadToken(char* data, char token) { |
1106 char* next = i::OS::StrChr(data, token); | 1117 char* next = i::OS::StrChr(data, token); |
1107 if (next != NULL) { | 1118 if (next != NULL) { |
1108 *next = '\0'; | 1119 *next = '\0'; |
1109 return (next + 1); | 1120 return (next + 1); |
1110 } | 1121 } |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 } | 1647 } |
1637 | 1648 |
1638 } // namespace v8 | 1649 } // namespace v8 |
1639 | 1650 |
1640 | 1651 |
1641 #ifndef GOOGLE3 | 1652 #ifndef GOOGLE3 |
1642 int main(int argc, char* argv[]) { | 1653 int main(int argc, char* argv[]) { |
1643 return v8::Shell::Main(argc, argv); | 1654 return v8::Shell::Main(argc, argv); |
1644 } | 1655 } |
1645 #endif | 1656 #endif |
OLD | NEW |