8 using namespace ::v8::internal;
14 : Thread(
"SocketListenerThread"),
16 data_size_(data_size),
19 listening_(OS::CreateSemaphore(0)) {
20 data_ =
new char[data_size_];
32 char*
data() {
return data_; }
40 Semaphore* listening_;
48 server_ = OS::CreateSocket();
49 server_->SetReuseAddress(
true);
51 ok = server_->Bind(port_);
55 ok = server_->Listen(1);
60 client_ = server_->Accept();
65 while (bytes_read < data_size_) {
66 bytes_read += client_->Receive(data_ + bytes_read, data_size_ - bytes_read);
71 static bool SendAll(Socket* socket,
const char* data,
int len) {
73 while (sent_len < len) {
74 int status = socket->Send(data, len);
84 static void SendAndReceive(
int port,
char *data,
int len) {
85 static const char* kLocalhost =
"localhost";
90 const int kPortBuferLen = 6;
91 char port_str[kPortBuferLen];
92 OS::SNPrintF(Vector<char>(port_str, kPortBuferLen),
"%d", port);
100 Socket* client = OS::CreateSocket();
102 ok = client->Connect(kLocalhost, port_str);
106 ok = SendAll(client, data, len);
113 for (
int i = 0; i < len; i++) {
127 static const int kPort = 5859;
132 ok = Socket::SetUp();
136 static const int kBufferSizeSmall = 20;
137 char small_data[kBufferSizeSmall + 1] =
"1234567890abcdefghij";
138 SendAndReceive(kPort, small_data, kBufferSizeSmall);
141 static const int kBufferSizeMedium = 10000;
142 char* medium_data =
new char[kBufferSizeMedium];
143 for (
int i = 0; i < kBufferSizeMedium; i++) {
144 medium_data[i] = i % 256;
146 SendAndReceive(kPort, medium_data, kBufferSizeMedium);
147 delete[] medium_data;
150 static const int kBufferSizeLarge = 1000000;
151 char* large_data =
new char[kBufferSizeLarge];
152 for (
int i = 0; i < kBufferSizeLarge; i++) {
153 large_data[i] = i % 256;
155 SendAndReceive(kPort, large_data, kBufferSizeLarge);
162 CHECK_EQ(x, Socket::NToH(Socket::HToN(x)));
164 uint32_t y = 12345678;
165 CHECK(y == Socket::NToH(Socket::HToN(y)));
#define CHECK_EQ(expected, value)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
SocketListenerThread(int port, int data_size)