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 |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 return v8::ThrowException( | 497 return v8::ThrowException( |
498 v8::String::New("Array constructor needs one parameter.")); | 498 v8::String::New("Array constructor needs one parameter.")); |
499 } | 499 } |
500 int length = args[0]->Int32Value(); | 500 int length = args[0]->Int32Value(); |
501 void* data = malloc(length * element_size); | 501 void* data = malloc(length * element_size); |
502 memset(data, 0, length * element_size); | 502 memset(data, 0, length * element_size); |
503 v8::Handle<v8::Object> array = v8::Object::New(); | 503 v8::Handle<v8::Object> array = v8::Object::New(); |
504 v8::Persistent<v8::Object> persistent_array = | 504 v8::Persistent<v8::Object> persistent_array = |
505 v8::Persistent<v8::Object>::New(array); | 505 v8::Persistent<v8::Object>::New(array); |
506 persistent_array.MakeWeak(data, ExternalArrayWeakCallback); | 506 persistent_array.MakeWeak(data, ExternalArrayWeakCallback); |
| 507 persistent_array.MarkIndependent(); |
507 array->SetIndexedPropertiesToExternalArrayData(data, type, length); | 508 array->SetIndexedPropertiesToExternalArrayData(data, type, length); |
508 array->Set(v8::String::New("length"), v8::Int32::New(length), | 509 array->Set(v8::String::New("length"), v8::Int32::New(length), |
509 v8::ReadOnly); | 510 v8::ReadOnly); |
510 array->Set(v8::String::New("BYTES_PER_ELEMENT"), | 511 array->Set(v8::String::New("BYTES_PER_ELEMENT"), |
511 v8::Int32::New(element_size)); | 512 v8::Int32::New(element_size)); |
512 return array; | 513 return array; |
513 } | 514 } |
514 | 515 |
515 | 516 |
516 v8::Handle<v8::Value> Int8Array(const v8::Arguments& args) { | 517 v8::Handle<v8::Value> Int8Array(const v8::Arguments& args) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 printf("^"); | 671 printf("^"); |
671 } | 672 } |
672 printf("\n"); | 673 printf("\n"); |
673 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); | 674 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); |
674 if (stack_trace.length() > 0) { | 675 if (stack_trace.length() > 0) { |
675 const char* stack_trace_string = ToCString(stack_trace); | 676 const char* stack_trace_string = ToCString(stack_trace); |
676 printf("%s\n", stack_trace_string); | 677 printf("%s\n", stack_trace_string); |
677 } | 678 } |
678 } | 679 } |
679 } | 680 } |
OLD | NEW |