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 + FlagDependentPortOffset();
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)
SocketListenerThread(int port, int data_size)
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL