Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Side by Side Diff: src/d8.cc

Issue 98993002: Remove internal uses of deprecated MakeWeak. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. More stuff. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 #include <sys/stat.h> 41 #include <sys/stat.h>
42 42
43 #ifdef V8_SHARED 43 #ifdef V8_SHARED
44 #include <assert.h> 44 #include <assert.h>
45 #endif // V8_SHARED 45 #endif // V8_SHARED
46 46
47 #ifndef V8_SHARED 47 #ifndef V8_SHARED
48 #include <algorithm> 48 #include <algorithm>
49 #endif // !V8_SHARED 49 #endif // !V8_SHARED
50 50
51 #include <utility>
Michael Starzinger 2013/12/02 15:34:10 nit: Can we move this up to the other system inclu
Sven Panne 2013/12/02 17:30:53 Nope, the presubmit check insists on this order: C
52
51 #ifdef V8_SHARED 53 #ifdef V8_SHARED
52 #include "../include/v8-testing.h" 54 #include "../include/v8-testing.h"
53 #endif // V8_SHARED 55 #endif // V8_SHARED
54 56
55 #ifdef ENABLE_VTUNE_JIT_INTERFACE 57 #ifdef ENABLE_VTUNE_JIT_INTERFACE
56 #include "third_party/vtune/v8-vtune.h" 58 #include "third_party/vtune/v8-vtune.h"
57 #endif 59 #endif
58 60
59 #include "d8.h" 61 #include "d8.h"
60 62
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 chars[size] = '\0'; 1092 chars[size] = '\0';
1091 for (int i = 0; i < size;) { 1093 for (int i = 0; i < size;) {
1092 int read = static_cast<int>(fread(&chars[i], 1, size - i, file)); 1094 int read = static_cast<int>(fread(&chars[i], 1, size - i, file));
1093 i += read; 1095 i += read;
1094 } 1096 }
1095 fclose(file); 1097 fclose(file);
1096 *size_out = size; 1098 *size_out = size;
1097 return chars; 1099 return chars;
1098 } 1100 }
1099 1101
1100 static void ReadBufferWeakCallback(v8::Isolate* isolate, 1102 static void ReadBufferWeakCallback(
1101 Persistent<ArrayBuffer>* array_buffer, 1103 const WeakCallbackData<v8::ArrayBuffer,
1102 uint8_t* data) { 1104 std::pair<v8::Persistent<v8::ArrayBuffer>*,
1103 size_t byte_length = 1105 uint8_t*> >& data) {
1104 Local<ArrayBuffer>::New(isolate, *array_buffer)->ByteLength(); 1106 data.GetIsolate()->AdjustAmountOfExternalAllocatedMemory(
1105 isolate->AdjustAmountOfExternalAllocatedMemory( 1107 -data.GetValue()->ByteLength());
Michael Starzinger 2013/12/02 15:34:10 I guess there will be some casting problem between
Sven Panne 2013/12/02 17:30:53 To be honest, I would prefer to see a compiler war
1106 -static_cast<intptr_t>(byte_length)); 1108 delete[] data.GetParameter()->second;
1107 1109 data.GetParameter()->first->Reset();
1108 delete[] data;
1109 array_buffer->Reset();
1110 } 1110 }
1111 1111
1112 1112
1113 void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) { 1113 void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) {
1114 ASSERT(sizeof(char) == sizeof(uint8_t)); // NOLINT 1114 ASSERT(sizeof(char) == sizeof(uint8_t)); // NOLINT
1115 String::Utf8Value filename(args[0]); 1115 String::Utf8Value filename(args[0]);
1116 int length; 1116 int length;
1117 if (*filename == NULL) { 1117 if (*filename == NULL) {
1118 Throw(args.GetIsolate(), "Error loading file"); 1118 Throw(args.GetIsolate(), "Error loading file");
1119 return; 1119 return;
1120 } 1120 }
1121 1121
1122 Isolate* isolate = args.GetIsolate(); 1122 Isolate* isolate = args.GetIsolate();
1123 uint8_t* data = reinterpret_cast<uint8_t*>( 1123 uint8_t* data = reinterpret_cast<uint8_t*>(
1124 ReadChars(args.GetIsolate(), *filename, &length)); 1124 ReadChars(args.GetIsolate(), *filename, &length));
1125 if (data == NULL) { 1125 if (data == NULL) {
1126 Throw(args.GetIsolate(), "Error reading file"); 1126 Throw(args.GetIsolate(), "Error reading file");
1127 return; 1127 return;
1128 } 1128 }
1129 Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(isolate, data, length); 1129 Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(isolate, data, length);
1130 v8::Persistent<v8::ArrayBuffer> weak_handle(isolate, buffer); 1130 v8::Persistent<v8::ArrayBuffer> weak_handle(isolate, buffer);
1131 weak_handle.MakeWeak(data, ReadBufferWeakCallback); 1131 std::pair<v8::Persistent<v8::ArrayBuffer>*, uint8_t*> pair(&weak_handle,
1132 data);
1133 weak_handle.SetWeak(&pair, ReadBufferWeakCallback);
1132 weak_handle.MarkIndependent(); 1134 weak_handle.MarkIndependent();
1133 isolate->AdjustAmountOfExternalAllocatedMemory(length); 1135 isolate->AdjustAmountOfExternalAllocatedMemory(length);
1134 1136
1135 args.GetReturnValue().Set(buffer); 1137 args.GetReturnValue().Set(buffer);
1136 } 1138 }
1137 1139
1138 1140
1139 #ifndef V8_SHARED 1141 #ifndef V8_SHARED
1140 static char* ReadToken(char* data, char token) { 1142 static char* ReadToken(char* data, char token) {
1141 char* next = i::OS::StrChr(data, token); 1143 char* next = i::OS::StrChr(data, token);
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 } 1757 }
1756 1758
1757 } // namespace v8 1759 } // namespace v8
1758 1760
1759 1761
1760 #ifndef GOOGLE3 1762 #ifndef GOOGLE3
1761 int main(int argc, char* argv[]) { 1763 int main(int argc, char* argv[]) {
1762 return v8::Shell::Main(argc, argv); 1764 return v8::Shell::Main(argc, argv);
1763 } 1765 }
1764 #endif 1766 #endif
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698