diff --git a/ChangeLog b/ChangeLog index 4b4b7a218a..eb82394b75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,46 @@ -2011.02.19, Version 0.4.1 (stable) +2011.03.02, Version 0.4.2 (stable) + +* Improve docs. + +* Fix process.on edge case with signal event (Alexis Sellier) + +* Pragma HTTP header comma separation + +* In addition to 'aborted' emit 'close' from incoming requests + (Felix Geisendörfer) + +* Fix memleak in vm.runInNewContext + +* Do not cache modules that throw exceptions (Felix Geisendörfer) + +* Build system changes for libnode (Aria Stewart) + +* Read up the prototype of the 'env' object. (Nathan Rajlich) + +* Add 'close' and 'aborted' events to Agent responses + +* http: fix missing 'drain' events (Russell Haering) + +* Fix process.stdout.end() throws ENOTSOCK error. (Koichi Kobayashi) + +* REPL bug fixes (isaacs) + +* node_modules folders should be highest priority (isaacs) + +* URL parse more safely (isaacs) + +* Expose errno with a string for dns/cares (Felix Geisendörfer) + +* Fix tty.setWindowSize + +* spawn: setuid after chdir (isaacs) + +* SIGUSR1 should break the VM without delay + +* Upgrade V8 to 3.1.8. + + +2011.02.19, Version 0.4.1 (stable), e8aef84191bc2c1ba2bcaa54f30aabde7f03769b * Fixed field merging with progressive fields on writeHead() (TJ Holowaychuk) diff --git a/LICENSE b/LICENSE index 6437f04da6..3d1e95ccf6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,49 +1,8 @@ -This license applies to all parts of Node that are not externally -maintained libraries. The externally maintained libraries used by Node -are: - - - v8, located under deps/v8, which is copyrighted by the Google, Inc. - v8 has a BSD license. - - - libev, located under deps/libev, and libeio, located at deps/libeio. - This code is copyrighted by Marc Alexander Lehmann. Both are dually - licensed under MIT and GPL2. - - - WAF build system, located at tools/waf. Copyrighted Thomas Nagy. - Released under an MIT license. - - - The SCONS build system, located at tools/scons. Copyrighted by the SCONS - Foundation. Released under an MIT license. - - - C-Ares, an asynchronous DNS client, located at deps/c-ares. Copyright by - the Massachusetts Institute of Technology; authored by Greg Hudson, - Daniel Stenberg and others. Released under an MIT license. - - - Node, optionally, dynmaically links to OpenSSL, cryptographic software - written by Eric Young (eay@cryptsoft.com) to provide SSL/TLS encryption. - OpenSSL is copyrighted by The OpenSSL Project. OpenSSL has a simple - Apache-style license. OpenSSL is not included in the Node distribution. - See http://openssl.org/ for more information. - - - tools/doctool/markdown.js is Released under MIT license and - Copyright 2009-2010 Dominic Baggott and Ash Berli - - - HTTP Parser, located at deps/http_parser, is a small C library - copyrighted by Ryan Lienhart Dahl and has a MIT license. - - - src/platform_darwin_proctitle.cc, has code taken from the Chromium - project copyright Google Inc. and released with the BSD license. - - - tools/closure_linter is copyrighted by The Closure Linter Authors and - Google Inc and is released under the Apache license. - - - tools/cpplint.py is copyrighted by Google Inc and is released under the - BSD license. - - Node's license follows: -Copyright 2009, 2010 Ryan Lienhart Dahl. All rights reserved. +==== + +Copyright Joyent, Inc. and other Node contributors. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the @@ -60,4 +19,50 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. +IN THE SOFTWARE. + +==== + +This license applies to all parts of Node that are not externally +maintained libraries. + +The externally maintained libraries used by Node are: + + - v8, located at deps/v8. v8 is copyright Google, Inc, and released + under a BSD license. + + - libev, located at deps/libev, and libeio, located at deps/libeio. libev + and libeio are copyright Marc Alexander Lehmann, and dual-licensed + under the MIT license and GPL2. + + - WAF build system, located at tools/waf. WAF is copyright Thomas Nagy, + and released under the MIT license. + + - The SCONS build system, located at tools/scons. SCONS is copyright + the SCONS Foundation and released under the MIT license. + + - C-Ares, an asynchronous DNS client, located at deps/c-ares. C-Ares is + copyright the Massachusetts Institute of Technology, authored by + Greg Hudson, Daniel Stenberg and others, and released under the MIT + license. + + - Node, optionally, dynamically links to OpenSSL, cryptographic software + written by Eric Young (eay@cryptsoft.com) to provide SSL/TLS encryption. + OpenSSL is copyright The OpenSSL Project and released under the OpenSSL + license. OpenSSL is not included in the Node distribution. + See http://openssl.org/ for more information. + + - tools/doctool/markdown.js is copyright 2009-2010 Dominic Baggott and Ash + Berli and released under the MIT license. + + - HTTP Parser, located at deps/http_parser, is a small C library + copyright Ryan Lienhart Dahl and released under the MIT license. + + - src/platform_darwin_proctitle.cc, has code taken from the Chromium + project copyright Google Inc. and released under a BSD license. + + - tools/closure_linter is copyright The Closure Linter Authors and + Google Inc. and released under the Apache License, version 2.0. + + - tools/cpplint.py is copyright Google Inc. and released under a + BSD license. diff --git a/cmake/configure.cmake b/cmake/configure.cmake index 66907b83eb..f0cb245995 100644 --- a/cmake/configure.cmake +++ b/cmake/configure.cmake @@ -62,6 +62,8 @@ endif() if(${node_platform} MATCHES darwin) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Carbon") + # explicitly set this so that we don't check again when building libeio + set(HAVE_FDATASYNC 0) else() # OSX fdatasync() check wrong: http://public.kitware.com/Bug/view.php?id=10044 check_function_exists(fdatasync HAVE_FDATASYNC) diff --git a/cmake/node_build.cmake b/cmake/node_build.cmake index 295bb3e632..9d89432f00 100644 --- a/cmake/node_build.cmake +++ b/cmake/node_build.cmake @@ -62,6 +62,7 @@ set(node_sources src/node_script.cc src/node_os.cc src/node_dtrace.cc + src/node_string.cc src/node_natives.h ${node_extra_src}) diff --git a/deps/v8/ChangeLog b/deps/v8/ChangeLog index 1d91fcded1..7936058e26 100644 --- a/deps/v8/ChangeLog +++ b/deps/v8/ChangeLog @@ -1,3 +1,30 @@ +2011-03-02: Version 3.1.8 + + Fixed a number of crash bugs. + + Improved Crankshaft for x64 and ARM. + + Implemented more of EcmaScript 5 strict mode. + + Fixed issue with unaligned reads and writes on ARM. + + Improved heap profiler support. + + +2011-02-28: Version 3.1.7 + + Fixed a number of crash bugs. + + Improved Crankshaft for x64 and ARM. + + Fixed implementation of indexOf/lastIndexOf for sparse + arrays (http://crbug.com/73940). + + Fixed bug in map space compaction (http://crbug.com/59688). + + Added support for direct getter accessors calls on ARM. + + 2011-02-24: Version 3.1.6 Fixed a number of crash bugs. diff --git a/deps/v8/SConstruct b/deps/v8/SConstruct index 6b155e4593..436581a9ba 100644 --- a/deps/v8/SConstruct +++ b/deps/v8/SConstruct @@ -306,7 +306,6 @@ V8_EXTRA_FLAGS = { 'gcc': { 'all': { 'WARNINGFLAGS': ['-Wall', - '-Werror', '-W', '-Wno-unused-parameter', '-Wnon-virtual-dtor'] diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index d718c8875b..b77e450cff 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -2286,7 +2286,8 @@ bool v8::Object::Set(v8::Handle key, v8::Handle value, self, key_obj, value_obj, - static_cast(attribs)); + static_cast(attribs), + i::kNonStrictMode); has_pending_exception = obj.is_null(); EXCEPTION_BAILOUT_CHECK(false); return true; @@ -2711,7 +2712,8 @@ bool v8::Object::SetHiddenValue(v8::Handle key, hidden_props, key_obj, value_obj, - static_cast(None)); + static_cast(None), + i::kNonStrictMode); has_pending_exception = obj.is_null(); EXCEPTION_BAILOUT_CHECK(false); return true; diff --git a/deps/v8/src/arm/assembler-arm.h b/deps/v8/src/arm/assembler-arm.h index 954b9cff33..f5eb5075f6 100644 --- a/deps/v8/src/arm/assembler-arm.h +++ b/deps/v8/src/arm/assembler-arm.h @@ -284,6 +284,7 @@ const SwVfpRegister s29 = { 29 }; const SwVfpRegister s30 = { 30 }; const SwVfpRegister s31 = { 31 }; +const DwVfpRegister no_dreg = { -1 }; const DwVfpRegister d0 = { 0 }; const DwVfpRegister d1 = { 1 }; const DwVfpRegister d2 = { 2 }; diff --git a/deps/v8/src/arm/code-stubs-arm.cc b/deps/v8/src/arm/code-stubs-arm.cc index 87fa87df0c..62eb3e6b8e 100644 --- a/deps/v8/src/arm/code-stubs-arm.cc +++ b/deps/v8/src/arm/code-stubs-arm.cc @@ -398,8 +398,11 @@ class FloatingPointHelper : public AllStatic { Label* not_number); // Loads the number from object into dst as a 32-bit integer if possible. If - // the object is not a 32-bit integer control continues at the label - // not_int32. If VFP is supported double_scratch is used but not scratch2. + // the object cannot be converted to a 32-bit integer control continues at + // the label not_int32. If VFP is supported double_scratch is used + // but not scratch2. + // Floating point value in the 32-bit integer range will be rounded + // to an integer. static void LoadNumberAsInteger(MacroAssembler* masm, Register object, Register dst, @@ -409,6 +412,76 @@ class FloatingPointHelper : public AllStatic { DwVfpRegister double_scratch, Label* not_int32); + // Load the number from object into double_dst in the double format. + // Control will jump to not_int32 if the value cannot be exactly represented + // by a 32-bit integer. + // Floating point value in the 32-bit integer range that are not exact integer + // won't be loaded. + static void LoadNumberAsInt32Double(MacroAssembler* masm, + Register object, + Destination destination, + DwVfpRegister double_dst, + Register dst1, + Register dst2, + Register heap_number_map, + Register scratch1, + Register scratch2, + SwVfpRegister single_scratch, + Label* not_int32); + + // Loads the number from object into dst as a 32-bit integer. + // Control will jump to not_int32 if the object cannot be exactly represented + // by a 32-bit integer. + // Floating point value in the 32-bit integer range that are not exact integer + // won't be converted. + // scratch3 is not used when VFP3 is supported. + static void LoadNumberAsInt32(MacroAssembler* masm, + Register object, + Register dst, + Register heap_number_map, + Register scratch1, + Register scratch2, + Register scratch3, + DwVfpRegister double_scratch, + Label* not_int32); + + // Generate non VFP3 code to check if a double can be exactly represented by a + // 32-bit integer. This does not check for 0 or -0, which need + // to be checked for separately. + // Control jumps to not_int32 if the value is not a 32-bit integer, and falls + // through otherwise. + // src1 and src2 will be cloberred. + // + // Expected input: + // - src1: higher (exponent) part of the double value. + // - src2: lower (mantissa) part of the double value. + // Output status: + // - dst: 32 higher bits of the mantissa. (mantissa[51:20]) + // - src2: contains 1. + // - other registers are clobbered. + static void DoubleIs32BitInteger(MacroAssembler* masm, + Register src1, + Register src2, + Register dst, + Register scratch, + Label* not_int32); + + // Generates code to call a C function to do a double operation using core + // registers. (Used when VFP3 is not supported.) + // This code never falls through, but returns with a heap number containing + // the result in r0. + // Register heapnumber_result must be a heap number in which the + // result of the operation will be stored. + // Requires the following layout on entry: + // r0: Left value (least significant part of mantissa). + // r1: Left value (sign, exponent, top of mantissa). + // r2: Right value (least significant part of mantissa). + // r3: Right value (sign, exponent, top of mantissa). + static void CallCCodeForDoubleOperation(MacroAssembler* masm, + Token::Value op, + Register heap_number_result, + Register scratch); + private: static void LoadNumber(MacroAssembler* masm, FloatingPointHelper::Destination destination, @@ -560,6 +633,319 @@ void FloatingPointHelper::LoadNumberAsInteger(MacroAssembler* masm, } +void FloatingPointHelper::LoadNumberAsInt32Double(MacroAssembler* masm, + Register object, + Destination destination, + DwVfpRegister double_dst, + Register dst1, + Register dst2, + Register heap_number_map, + Register scratch1, + Register scratch2, + SwVfpRegister single_scratch, + Label* not_int32) { + ASSERT(!scratch1.is(object) && !scratch2.is(object)); + ASSERT(!scratch1.is(scratch2)); + ASSERT(!heap_number_map.is(object) && + !heap_number_map.is(scratch1) && + !heap_number_map.is(scratch2)); + + Label done, obj_is_not_smi; + + __ JumpIfNotSmi(object, &obj_is_not_smi); + __ SmiUntag(scratch1, object); + if (CpuFeatures::IsSupported(VFP3)) { + CpuFeatures::Scope scope(VFP3); + __ vmov(single_scratch, scratch1); + __ vcvt_f64_s32(double_dst, single_scratch); + if (destination == kCoreRegisters) { + __ vmov(dst1, dst2, double_dst); + } + } else { + Label fewer_than_20_useful_bits; + // Expected output: + // | dst1 | dst2 | + // | s | exp | mantissa | + + // Check for zero. + __ cmp(scratch1, Operand(0)); + __ mov(dst1, scratch1); + __ mov(dst2, scratch1); + __ b(eq, &done); + + // Preload the sign of the value. + __ and_(dst1, scratch1, Operand(HeapNumber::kSignMask), SetCC); + // Get the absolute value of the object (as an unsigned integer). + __ rsb(scratch1, scratch1, Operand(0), SetCC, mi); + + // Get mantisssa[51:20]. + + // Get the position of the first set bit. + __ CountLeadingZeros(dst2, scratch1, scratch2); + __ rsb(dst2, dst2, Operand(31)); + + // Set the exponent. + __ add(scratch2, dst2, Operand(HeapNumber::kExponentBias)); + __ Bfi(dst1, scratch2, scratch2, + HeapNumber::kExponentShift, HeapNumber::kExponentBits); + + // Clear the first non null bit. + __ mov(scratch2, Operand(1)); + __ bic(scratch1, scratch1, Operand(scratch2, LSL, dst2)); + + __ cmp(dst2, Operand(HeapNumber::kMantissaBitsInTopWord)); + // Get the number of bits to set in the lower part of the mantissa. + __ sub(scratch2, dst2, Operand(HeapNumber::kMantissaBitsInTopWord), SetCC); + __ b(mi, &fewer_than_20_useful_bits); + // Set the higher 20 bits of the mantissa. + __ orr(dst1, dst1, Operand(scratch1, LSR, scratch2)); + __ rsb(scratch2, scratch2, Operand(32)); + __ mov(dst2, Operand(scratch1, LSL, scratch2)); + __ b(&done); + + __ bind(&fewer_than_20_useful_bits); + __ rsb(scratch2, dst2, Operand(HeapNumber::kMantissaBitsInTopWord)); + __ mov(scratch2, Operand(scratch1, LSL, scratch2)); + __ orr(dst1, dst1, scratch2); + // Set dst2 to 0. + __ mov(dst2, Operand(0)); + } + + __ b(&done); + + __ bind(&obj_is_not_smi); + if (FLAG_debug_code) { + __ AbortIfNotRootValue(heap_number_map, + Heap::kHeapNumberMapRootIndex, + "HeapNumberMap register clobbered."); + } + __ JumpIfNotHeapNumber(object, heap_number_map, scratch1, not_int32); + + // Load the number. + if (CpuFeatures::IsSupported(VFP3)) { + CpuFeatures::Scope scope(VFP3); + // Load the double value. + __ sub(scratch1, object, Operand(kHeapObjectTag)); + __ vldr(double_dst, scratch1, HeapNumber::kValueOffset); + + __ EmitVFPTruncate(kRoundToZero, + single_scratch, + double_dst, + scratch1, + scratch2, + kCheckForInexactConversion); + + // Jump to not_int32 if the operation did not succeed. + __ b(ne, not_int32); + + if (destination == kCoreRegisters) { + __ vmov(dst1, dst2, double_dst); + } + + } else { + ASSERT(!scratch1.is(object) && !scratch2.is(object)); + // Load the double value in the destination registers.. + __ Ldrd(dst1, dst2, FieldMemOperand(object, HeapNumber::kValueOffset)); + + // Check for 0 and -0. + __ bic(scratch1, dst1, Operand(HeapNumber::kSignMask)); + __ orr(scratch1, scratch1, Operand(dst2)); + __ cmp(scratch1, Operand(0)); + __ b(eq, &done); + + // Check that the value can be exactly represented by a 32-bit integer. + // Jump to not_int32 if that's not the case. + DoubleIs32BitInteger(masm, dst1, dst2, scratch1, scratch2, not_int32); + + // dst1 and dst2 were trashed. Reload the double value. + __ Ldrd(dst1, dst2, FieldMemOperand(object, HeapNumber::kValueOffset)); + } + + __ bind(&done); +} + + +void FloatingPointHelper::LoadNumberAsInt32(MacroAssembler* masm, + Register object, + Register dst, + Register heap_number_map, + Register scratch1, + Register scratch2, + Register scratch3, + DwVfpRegister double_scratch, + Label* not_int32) { + ASSERT(!dst.is(object)); + ASSERT(!scratch1.is(object) && !scratch2.is(object) && !scratch3.is(object)); + ASSERT(!scratch1.is(scratch2) && + !scratch1.is(scratch3) && + !scratch2.is(scratch3)); + + Label done; + + // Untag the object into the destination register. + __ SmiUntag(dst, object); + // Just return if the object is a smi. + __ JumpIfSmi(object, &done); + + if (FLAG_debug_code) { + __ AbortIfNotRootValue(heap_number_map, + Heap::kHeapNumberMapRootIndex, + "HeapNumberMap register clobbered."); + } + __ JumpIfNotHeapNumber(object, heap_number_map, scratch1, not_int32); + + // Object is a heap number. + // Convert the floating point value to a 32-bit integer. + if (CpuFeatures::IsSupported(VFP3)) { + CpuFeatures::Scope scope(VFP3); + SwVfpRegister single_scratch = double_scratch.low(); + // Load the double value. + __ sub(scratch1, object, Operand(kHeapObjectTag)); + __ vldr(double_scratch, scratch1, HeapNumber::kValueOffset); + + __ EmitVFPTruncate(kRoundToZero, + single_scratch, + double_scratch, + scratch1, + scratch2, + kCheckForInexactConversion); + + // Jump to not_int32 if the operation did not succeed. + __ b(ne, not_int32); + // Get the result in the destination register. + __ vmov(dst, single_scratch); + + } else { + // Load the double value in the destination registers. + __ ldr(scratch1, FieldMemOperand(object, HeapNumber::kExponentOffset)); + __ ldr(scratch2, FieldMemOperand(object, HeapNumber::kMantissaOffset)); + + // Check for 0 and -0. + __ bic(dst, scratch1, Operand(HeapNumber::kSignMask)); + __ orr(dst, scratch2, Operand(dst)); + __ cmp(dst, Operand(0)); + __ b(eq, &done); + + DoubleIs32BitInteger(masm, scratch1, scratch2, dst, scratch3, not_int32); + + // Registers state after DoubleIs32BitInteger. + // dst: mantissa[51:20]. + // scratch2: 1 + + // Shift back the higher bits of the mantissa. + __ mov(dst, Operand(dst, LSR, scratch3)); + // Set the implicit first bit. + __ rsb(scratch3, scratch3, Operand(32)); + __ orr(dst, dst, Operand(scratch2, LSL, scratch3)); + // Set the sign. + __ ldr(scratch1, FieldMemOperand(object, HeapNumber::kExponentOffset)); + __ tst(scratch1, Operand(HeapNumber::kSignMask)); + __ rsb(dst, dst, Operand(0), LeaveCC, mi); + } + + __ bind(&done); +} + + +void FloatingPointHelper::DoubleIs32BitInteger(MacroAssembler* masm, + Register src1, + Register src2, + Register dst, + Register scratch, + Label* not_int32) { + // Get exponent alone in scratch. + __ Ubfx(scratch, + src1, + HeapNumber::kExponentShift, + HeapNumber::kExponentBits); + + // Substract the bias from the exponent. + __ sub(scratch, scratch, Operand(HeapNumber::kExponentBias), SetCC); + + // src1: higher (exponent) part of the double value. + // src2: lower (mantissa) part of the double value. + // scratch: unbiased exponent. + + // Fast cases. Check for obvious non 32-bit integer values. + // Negative exponent cannot yield 32-bit integers. + __ b(mi, not_int32); + // Exponent greater than 31 cannot yield 32-bit integers. + // Also, a positive value with an exponent equal to 31 is outside of the + // signed 32-bit integer range. + __ tst(src1, Operand(HeapNumber::kSignMask)); + __ cmp(scratch, Operand(30), eq); // Executed for positive. If exponent is 30 + // the gt condition will be "correct" and + // the next instruction will be skipped. + __ cmp(scratch, Operand(31), ne); // Executed for negative and positive where + // exponent is not 30. + __ b(gt, not_int32); + // - Bits [21:0] in the mantissa are not null. + __ tst(src2, Operand(0x3fffff)); + __ b(ne, not_int32); + + // Otherwise the exponent needs to be big enough to shift left all the + // non zero bits left. So we need the (30 - exponent) last bits of the + // 31 higher bits of the mantissa to be null. + // Because bits [21:0] are null, we can check instead that the + // (32 - exponent) last bits of the 32 higher bits of the mantisssa are null. + + // Get the 32 higher bits of the mantissa in dst. + __ Ubfx(dst, + src2, + HeapNumber::kMantissaBitsInTopWord, + 32 - HeapNumber::kMantissaBitsInTopWord); + __ orr(dst, + dst, + Operand(src1, LSL, HeapNumber::kNonMantissaBitsInTopWord)); + + // Create the mask and test the lower bits (of the higher bits). + __ rsb(scratch, scratch, Operand(32)); + __ mov(src2, Operand(1)); + __ mov(src1, Operand(src2, LSL, scratch)); + __ sub(src1, src1, Operand(1)); + __ tst(dst, src1); + __ b(ne, not_int32); +} + + +void FloatingPointHelper::CallCCodeForDoubleOperation( + MacroAssembler* masm, + Token::Value op, + Register heap_number_result, + Register scratch) { + // Using core registers: + // r0: Left value (least significant part of mantissa). + // r1: Left value (sign, exponent, top of mantissa). + // r2: Right value (least significant part of mantissa). + // r3: Right value (sign, exponent, top of mantissa). + + // Assert that heap_number_result is callee-saved. + // We currently always use r5 to pass it. + ASSERT(heap_number_result.is(r5)); + + // Push the current return address before the C call. Return will be + // through pop(pc) below. + __ push(lr); + __ PrepareCallCFunction(4, scratch); // Two doubles are 4 arguments. + // Call C routine that may not cause GC or other trouble. + __ CallCFunction(ExternalReference::double_fp_operation(op), 4); + // Store answer in the overwritable heap number. +#if !defined(USE_ARM_EABI) + // Double returned in fp coprocessor register 0 and 1, encoded as + // register cr8. Offsets must be divisible by 4 for coprocessor so we + // need to substract the tag from heap_number_result. + __ sub(scratch, heap_number_result, Operand(kHeapObjectTag)); + __ stc(p1, cr8, MemOperand(scratch, HeapNumber::kValueOffset)); +#else + // Double returned in registers 0 and 1. + __ Strd(r0, r1, FieldMemOperand(heap_number_result, + HeapNumber::kValueOffset)); +#endif + // Place heap_number_result in r0 and return to the pushed return address. + __ mov(r0, Operand(heap_number_result)); + __ pop(pc); +} + // See comment for class. void WriteInt32ToHeapNumberStub::Generate(MacroAssembler* masm) { @@ -1296,6 +1682,9 @@ void CompareStub::Generate(MacroAssembler* masm) { // This stub does not handle the inlined cases (Smis, Booleans, undefined). // The stub returns zero for false, and a non-zero value for true. void ToBooleanStub::Generate(MacroAssembler* masm) { + // This stub uses VFP3 instructions. + ASSERT(CpuFeatures::IsEnabled(VFP3)); + Label false_result; Label not_heap_number; Register scratch = r9.is(tos_) ? r7 : r9; @@ -2704,33 +3093,11 @@ void TypeRecordingBinaryOpStub::GenerateFPOperation(MacroAssembler* masm, __ add(r0, r0, Operand(kHeapObjectTag)); __ Ret(); } else { - // Using core registers: - // r0: Left value (least significant part of mantissa). - // r1: Left value (sign, exponent, top of mantissa). - // r2: Right value (least significant part of mantissa). - // r3: Right value (sign, exponent, top of mantissa). - - // Push the current return address before the C call. Return will be - // through pop(pc) below. - __ push(lr); - __ PrepareCallCFunction(4, scratch1); // Two doubles are 4 arguments. - // Call C routine that may not cause GC or other trouble. r5 is callee - // save. - __ CallCFunction(ExternalReference::double_fp_operation(op_), 4); - // Store answer in the overwritable heap number. -#if !defined(USE_ARM_EABI) - // Double returned in fp coprocessor register 0 and 1, encoded as - // register cr8. Offsets must be divisible by 4 for coprocessor so we - // need to substract the tag from r5. - __ sub(scratch1, result, Operand(kHeapObjectTag)); - __ stc(p1, cr8, MemOperand(scratch1, HeapNumber::kValueOffset)); -#else - // Double returned in registers 0 and 1. - __ Strd(r0, r1, FieldMemOperand(result, HeapNumber::kValueOffset)); -#endif - // Plase result in r0 and return to the pushed return address. - __ mov(r0, Operand(result)); - __ pop(pc); + // Call the C function to handle the double operation. + FloatingPointHelper::CallCCodeForDoubleOperation(masm, + op_, + result, + scratch1); } break; } @@ -2776,7 +3143,6 @@ void TypeRecordingBinaryOpStub::GenerateFPOperation(MacroAssembler* masm, break; case Token::SAR: // Use only the 5 least significant bits of the shift count. - __ and_(r2, r2, Operand(0x1f)); __ GetLeastBitsFromInt32(r2, r2, 5); __ mov(r2, Operand(r3, ASR, r2)); break; @@ -2921,7 +3287,288 @@ void TypeRecordingBinaryOpStub::GenerateStringStub(MacroAssembler* masm) { void TypeRecordingBinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) { ASSERT(operands_type_ == TRBinaryOpIC::INT32); - GenerateTypeTransition(masm); + Register left = r1; + Register right = r0; + Register scratch1 = r7; + Register scratch2 = r9; + DwVfpRegister double_scratch = d0; + SwVfpRegister single_scratch = s3; + + Register heap_number_result = no_reg; + Register heap_number_map = r6; + __ LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); + + Label call_runtime; + // Labels for type transition, used for wrong input or output types. + // Both label are currently actually bound to the same position. We use two + // different label to differentiate the cause leading to type transition. + Label transition; + + // Smi-smi fast case. + Label skip; + __ orr(scratch1, left, right); + __ JumpIfNotSmi(scratch1, &skip); + GenerateSmiSmiOperation(masm); + // Fall through if the result is not a smi. + __ bind(&skip); + + switch (op_) { + case Token::ADD: + case Token::SUB: + case Token::MUL: + case Token::DIV: + case Token::MOD: { + // Load both operands and check that they are 32-bit integer. + // Jump to type transition if they are not. The registers r0 and r1 (right + // and left) are preserved for the runtime call. + FloatingPointHelper::Destination destination = + CpuFeatures::IsSupported(VFP3) && op_ != Token::MOD ? + FloatingPointHelper::kVFPRegisters : + FloatingPointHelper::kCoreRegisters; + + FloatingPointHelper::LoadNumberAsInt32Double(masm, + right, + destination, + d7, + r2, + r3, + heap_number_map, + scratch1, + scratch2, + s0, + &transition); + FloatingPointHelper::LoadNumberAsInt32Double(masm, + left, + destination, + d6, + r4, + r5, + heap_number_map, + scratch1, + scratch2, + s0, + &transition); + + if (destination == FloatingPointHelper::kVFPRegisters) { + CpuFeatures::Scope scope(VFP3); + Label return_heap_number; + switch (op_) { + case Token::ADD: + __ vadd(d5, d6, d7); + break; + case Token::SUB: + __ vsub(d5, d6, d7); + break; + case Token::MUL: + __ vmul(d5, d6, d7); + break; + case Token::DIV: + __ vdiv(d5, d6, d7); + break; + default: + UNREACHABLE(); + } + + if (op_ != Token::DIV) { + // These operations produce an integer result. + // Try to return a smi if we can. + // Otherwise return a heap number if allowed, or jump to type + // transition. + + __ EmitVFPTruncate(kRoundToZero, + single_scratch, + d5, + scratch1, + scratch2); + + if (result_type_ <= TRBinaryOpIC::INT32) { + // If the ne condition is set, result does + // not fit in a 32-bit integer. + __ b(ne, &transition); + } + + // Check if the result fits in a smi. + __ vmov(scratch1, single_scratch); + __ add(scratch2, scratch1, Operand(0x40000000), SetCC); + // If not try to return a heap number. + __ b(mi, &return_heap_number); + // Tag the result and return. + __ SmiTag(r0, scratch1); + __ Ret(); + } + + if (result_type_ >= (op_ == Token::DIV) ? TRBinaryOpIC::HEAP_NUMBER + : TRBinaryOpIC::INT32) { + __ bind(&return_heap_number); + // We are using vfp registers so r5 is available. + heap_number_result = r5; + GenerateHeapResultAllocation(masm, + heap_number_result, + heap_number_map, + scratch1, + scratch2, + &call_runtime); + __ sub(r0, heap_number_result, Operand(kHeapObjectTag)); + __ vstr(d5, r0, HeapNumber::kValueOffset); + __ mov(r0, heap_number_result); + __ Ret(); + } + + // A DIV operation expecting an integer result falls through + // to type transition. + + } else { + // We preserved r0 and r1 to be able to call runtime. + // Save the left value on the stack. + __ Push(r5, r4); + + // Allocate a heap number to store the result. + heap_number_result = r5; + GenerateHeapResultAllocation(masm, + heap_number_result, + heap_number_map, + scratch1, + scratch2, + &call_runtime); + + // Load the left value from the value saved on the stack. + __ Pop(r1, r0); + + // Call the C function to handle the double operation. + FloatingPointHelper::CallCCodeForDoubleOperation( + masm, op_, heap_number_result, scratch1); + } + + break; + } + + case Token::BIT_OR: + case Token::BIT_XOR: + case Token::BIT_AND: + case Token::SAR: + case Token::SHR: + case Token::SHL: { + Label return_heap_number; + Register scratch3 = r5; + // Convert operands to 32-bit integers. Right in r2 and left in r3. The + // registers r0 and r1 (right and left) are preserved for the runtime + // call. + FloatingPointHelper::LoadNumberAsInt32(masm, + left, + r3, + heap_number_map, + scratch1, + scratch2, + scratch3, + d0, + &transition); + FloatingPointHelper::LoadNumberAsInt32(masm, + right, + r2, + heap_number_map, + scratch1, + scratch2, + scratch3, + d0, + &transition); + + // The ECMA-262 standard specifies that, for shift operations, only the + // 5 least significant bits of the shift value should be used. + switch (op_) { + case Token::BIT_OR: + __ orr(r2, r3, Operand(r2)); + break; + case Token::BIT_XOR: + __ eor(r2, r3, Operand(r2)); + break; + case Token::BIT_AND: + __ and_(r2, r3, Operand(r2)); + break; + case Token::SAR: + __ and_(r2, r2, Operand(0x1f)); + __ mov(r2, Operand(r3, ASR, r2)); + break; + case Token::SHR: + __ and_(r2, r2, Operand(0x1f)); + __ mov(r2, Operand(r3, LSR, r2), SetCC); + // SHR is special because it is required to produce a positive answer. + // We only get a negative result if the shift value (r2) is 0. + // This result cannot be respresented as a signed 32-bit integer, try + // to return a heap number if we can. + // The non vfp3 code does not support this special case, so jump to + // runtime if we don't support it. + if (CpuFeatures::IsSupported(VFP3)) { + __ b(mi, + (result_type_ <= TRBinaryOpIC::INT32) ? &transition + : &return_heap_number); + } else { + __ b(mi, (result_type_ <= TRBinaryOpIC::INT32) ? &transition + : &call_runtime); + } + break; + case Token::SHL: + __ and_(r2, r2, Operand(0x1f)); + __ mov(r2, Operand(r3, LSL, r2)); + break; + default: + UNREACHABLE(); + } + + // Check if the result fits in a smi. + __ add(scratch1, r2, Operand(0x40000000), SetCC); + // If not try to return a heap number. (We know the result is an int32.) + __ b(mi, &return_heap_number); + // Tag the result and return. + __ SmiTag(r0, r2); + __ Ret(); + + __ bind(&return_heap_number); + if (CpuFeatures::IsSupported(VFP3)) { + CpuFeatures::Scope scope(VFP3); + heap_number_result = r5; + GenerateHeapResultAllocation(masm, + heap_number_result, + heap_number_map, + scratch1, + scratch2, + &call_runtime); + + if (op_ != Token::SHR) { + // Convert the result to a floating point value. + __ vmov(double_scratch.low(), r2); + __ vcvt_f64_s32(double_scratch, double_scratch.low()); + } else { + // The result must be interpreted as an unsigned 32-bit integer. + __ vmov(double_scratch.low(), r2); + __ vcvt_f64_u32(double_scratch, double_scratch.low()); + } + + // Store the result. + __ sub(r0, heap_number_result, Operand(kHeapObjectTag)); + __ vstr(double_scratch, r0, HeapNumber::kValueOffset); + __ mov(r0, heap_number_result); + __ Ret(); + } else { + // Tail call that writes the int32 in r2 to the heap number in r0, using + // r3 as scratch. r0 is preserved and returned. + WriteInt32ToHeapNumberStub stub(r2, r0, r3); + __ TailCallStub(&stub); + } + + break; + } + + default: + UNREACHABLE(); + } + + if (transition.is_linked()) { + __ bind(&transition); + GenerateTypeTransition(masm); + } + + __ bind(&call_runtime); + GenerateCallRuntime(masm); } @@ -5957,11 +6604,10 @@ void DirectCEntryStub::Generate(MacroAssembler* masm) { void DirectCEntryStub::GenerateCall(MacroAssembler* masm, - ApiFunction *function) { + ExternalReference function) { __ mov(lr, Operand(reinterpret_cast(GetCode().location()), RelocInfo::CODE_TARGET)); - __ mov(r2, - Operand(ExternalReference(function, ExternalReference::DIRECT_CALL))); + __ mov(r2, Operand(function)); // Push return address (accessible to GC through exit frame pc). __ str(pc, MemOperand(sp, 0)); __ Jump(r2); // Call the api function. diff --git a/deps/v8/src/arm/code-stubs-arm.h b/deps/v8/src/arm/code-stubs-arm.h index 475fbd70e8..0e707f41c8 100644 --- a/deps/v8/src/arm/code-stubs-arm.h +++ b/deps/v8/src/arm/code-stubs-arm.h @@ -592,7 +592,7 @@ class DirectCEntryStub: public CodeStub { public: DirectCEntryStub() {} void Generate(MacroAssembler* masm); - void GenerateCall(MacroAssembler* masm, ApiFunction *function); + void GenerateCall(MacroAssembler* masm, ExternalReference function); void GenerateCall(MacroAssembler* masm, Register target); private: diff --git a/deps/v8/src/arm/codegen-arm.cc b/deps/v8/src/arm/codegen-arm.cc index 3e125a33fc..8bb576ded7 100644 --- a/deps/v8/src/arm/codegen-arm.cc +++ b/deps/v8/src/arm/codegen-arm.cc @@ -1938,8 +1938,9 @@ void CodeGenerator::DeclareGlobals(Handle pairs) { frame_->EmitPush(cp); frame_->EmitPush(Operand(pairs)); frame_->EmitPush(Operand(Smi::FromInt(is_eval() ? 1 : 0))); + frame_->EmitPush(Operand(Smi::FromInt(strict_mode_flag()))); - frame_->CallRuntime(Runtime::kDeclareGlobals, 3); + frame_->CallRuntime(Runtime::kDeclareGlobals, 4); // The result is discarded. } @@ -3287,7 +3288,8 @@ void CodeGenerator::StoreToSlot(Slot* slot, InitState init_state) { // context slot followed by initialization. frame_->CallRuntime(Runtime::kInitializeConstContextSlot, 3); } else { - frame_->CallRuntime(Runtime::kStoreContextSlot, 3); + frame_->EmitPush(Operand(Smi::FromInt(strict_mode_flag()))); + frame_->CallRuntime(Runtime::kStoreContextSlot, 4); } // Storing a variable must keep the (new) value on the expression // stack. This is necessary for compiling assignment expressions. @@ -3637,7 +3639,8 @@ void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { Load(key); Load(value); if (property->emit_store()) { - frame_->CallRuntime(Runtime::kSetProperty, 3); + frame_->EmitPush(Operand(Smi::FromInt(NONE))); // PropertyAttributes + frame_->CallRuntime(Runtime::kSetProperty, 4); } else { frame_->Drop(3); } @@ -5170,11 +5173,11 @@ class DeferredIsStringWrapperSafeForDefaultValueOf : public DeferredCode { // Set the bit in the map to indicate that it has been checked safe for // default valueOf and set true result. - __ ldr(scratch1_, FieldMemOperand(map_result_, Map::kBitField2Offset)); + __ ldrb(scratch1_, FieldMemOperand(map_result_, Map::kBitField2Offset)); __ orr(scratch1_, scratch1_, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf)); - __ str(scratch1_, FieldMemOperand(map_result_, Map::kBitField2Offset)); + __ strb(scratch1_, FieldMemOperand(map_result_, Map::kBitField2Offset)); __ mov(map_result_, Operand(1)); __ jmp(exit_label()); __ bind(&false_result); @@ -6674,8 +6677,12 @@ class DeferredReferenceSetKeyedValue: public DeferredCode { public: DeferredReferenceSetKeyedValue(Register value, Register key, - Register receiver) - : value_(value), key_(key), receiver_(receiver) { + Register receiver, + StrictModeFlag strict_mode) + : value_(value), + key_(key), + receiver_(receiver), + strict_mode_(strict_mode) { set_comment("[ DeferredReferenceSetKeyedValue"); } @@ -6685,6 +6692,7 @@ class DeferredReferenceSetKeyedValue: public DeferredCode { Register value_; Register key_; Register receiver_; + StrictModeFlag strict_mode_; }; @@ -6706,7 +6714,9 @@ void DeferredReferenceSetKeyedValue::Generate() { { Assembler::BlockConstPoolScope block_const_pool(masm_); // Call keyed store IC. It has the arguments value, key and receiver in r0, // r1 and r2. - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + (strict_mode_ == kStrictMode) ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); __ Call(ic, RelocInfo::CODE_TARGET); // The call must be followed by a nop instruction to indicate that the // keyed store has been inlined. @@ -6724,8 +6734,12 @@ class DeferredReferenceSetNamedValue: public DeferredCode { public: DeferredReferenceSetNamedValue(Register value, Register receiver, - Handle name) - : value_(value), receiver_(receiver), name_(name) { + Handle name, + StrictModeFlag strict_mode) + : value_(value), + receiver_(receiver), + name_(name), + strict_mode_(strict_mode) { set_comment("[ DeferredReferenceSetNamedValue"); } @@ -6735,6 +6749,7 @@ class DeferredReferenceSetNamedValue: public DeferredCode { Register value_; Register receiver_; Handle name_; + StrictModeFlag strict_mode_; }; @@ -6754,7 +6769,9 @@ void DeferredReferenceSetNamedValue::Generate() { { Assembler::BlockConstPoolScope block_const_pool(masm_); // Call keyed store IC. It has the arguments value, key and receiver in r0, // r1 and r2. - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + (strict_mode_ == kStrictMode) ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); __ Call(ic, RelocInfo::CODE_TARGET); // The call must be followed by a nop instruction to indicate that the // named store has been inlined. @@ -6943,7 +6960,8 @@ void CodeGenerator::EmitNamedStore(Handle name, bool is_contextual) { Register receiver = r1; DeferredReferenceSetNamedValue* deferred = - new DeferredReferenceSetNamedValue(value, receiver, name); + new DeferredReferenceSetNamedValue( + value, receiver, name, strict_mode_flag()); // Check that the receiver is a heap object. __ tst(receiver, Operand(kSmiTagMask)); @@ -7129,7 +7147,8 @@ void CodeGenerator::EmitKeyedStore(StaticType* key_type, // The deferred code expects value, key and receiver in registers. DeferredReferenceSetKeyedValue* deferred = - new DeferredReferenceSetKeyedValue(value, key, receiver); + new DeferredReferenceSetKeyedValue( + value, key, receiver, strict_mode_flag()); // Check that the value is a smi. As this inlined code does not set the // write barrier it is only possible to store smi values. @@ -7214,7 +7233,7 @@ void CodeGenerator::EmitKeyedStore(StaticType* key_type, deferred->BindExit(); } else { - frame()->CallKeyedStoreIC(); + frame()->CallKeyedStoreIC(strict_mode_flag()); } } diff --git a/deps/v8/src/arm/constants-arm.h b/deps/v8/src/arm/constants-arm.h index 7ac38ed3ea..e6033a8977 100644 --- a/deps/v8/src/arm/constants-arm.h +++ b/deps/v8/src/arm/constants-arm.h @@ -385,7 +385,10 @@ enum VFPConversionMode { kDefaultRoundToZero = 1 }; +// This mask does not include the "inexact" or "input denormal" cumulative +// exceptions flags, because we usually don't want to check for it. static const uint32_t kVFPExceptionMask = 0xf; +static const uint32_t kVFPInexactExceptionBit = 1 << 4; static const uint32_t kVFPFlushToZeroMask = 1 << 24; static const uint32_t kVFPInvalidExceptionBit = 1; @@ -411,6 +414,11 @@ enum VFPRoundingMode { static const uint32_t kVFPRoundingModeMask = 3 << 22; +enum CheckForInexactConversion { + kCheckForInexactConversion, + kDontCheckForInexactConversion +}; + // ----------------------------------------------------------------------------- // Hints. diff --git a/deps/v8/src/arm/full-codegen-arm.cc b/deps/v8/src/arm/full-codegen-arm.cc index fea9a8cfb7..7a47644781 100644 --- a/deps/v8/src/arm/full-codegen-arm.cc +++ b/deps/v8/src/arm/full-codegen-arm.cc @@ -339,23 +339,6 @@ void FullCodeGenerator::EmitReturnSequence() { } -FullCodeGenerator::ConstantOperand FullCodeGenerator::GetConstantOperand( - Token::Value op, Expression* left, Expression* right) { - ASSERT(ShouldInlineSmiCase(op)); - if (op == Token::DIV || op == Token::MOD || op == Token::MUL) { - // We never generate inlined constant smi operations for these. - return kNoConstants; - } else if (right->IsSmiLiteral()) { - return kRightConstant; - } else if (left->IsSmiLiteral() && !Token::IsShiftOp(op)) { - // Don't inline shifts with constant left hand side. - return kLeftConstant; - } else { - return kNoConstants; - } -} - - void FullCodeGenerator::EffectContext::Plug(Slot* slot) const { } @@ -574,13 +557,38 @@ void FullCodeGenerator::TestContext::Plug(bool flag) const { void FullCodeGenerator::DoTest(Label* if_true, Label* if_false, Label* fall_through) { - // Call the runtime to find the boolean value of the source and then - // translate it into control flow to the pair of labels. - __ push(result_register()); - __ CallRuntime(Runtime::kToBool, 1); - __ LoadRoot(ip, Heap::kTrueValueRootIndex); - __ cmp(r0, ip); - Split(eq, if_true, if_false, fall_through); + if (CpuFeatures::IsSupported(VFP3)) { + CpuFeatures::Scope scope(VFP3); + // Emit the inlined tests assumed by the stub. + __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); + __ cmp(result_register(), ip); + __ b(eq, if_false); + __ LoadRoot(ip, Heap::kTrueValueRootIndex); + __ cmp(result_register(), ip); + __ b(eq, if_true); + __ LoadRoot(ip, Heap::kFalseValueRootIndex); + __ cmp(result_register(), ip); + __ b(eq, if_false); + STATIC_ASSERT(kSmiTag == 0); + __ tst(result_register(), result_register()); + __ b(eq, if_false); + __ JumpIfSmi(result_register(), if_true); + + // Call the ToBoolean stub for all other cases. + ToBooleanStub stub(result_register()); + __ CallStub(&stub); + __ tst(result_register(), result_register()); + } else { + // Call the runtime to find the boolean value of the source and then + // translate it into control flow to the pair of labels. + __ push(result_register()); + __ CallRuntime(Runtime::kToBool, 1); + __ LoadRoot(ip, Heap::kFalseValueRootIndex); + __ cmp(r0, ip); + } + + // The stub returns nonzero for true. + Split(ne, if_true, if_false, fall_through); } @@ -768,7 +776,9 @@ void FullCodeGenerator::EmitDeclaration(Variable* variable, prop->key()->AsLiteral()->handle()->IsSmi()); __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin(is_strict() + ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); // Value in r0 is ignored (declarations are statements). } @@ -784,10 +794,11 @@ void FullCodeGenerator::VisitDeclaration(Declaration* decl) { void FullCodeGenerator::DeclareGlobals(Handle pairs) { // Call the runtime to declare the globals. // The context is the first argument. - __ mov(r1, Operand(pairs)); - __ mov(r0, Operand(Smi::FromInt(is_eval() ? 1 : 0))); - __ Push(cp, r1, r0); - __ CallRuntime(Runtime::kDeclareGlobals, 3); + __ mov(r2, Operand(pairs)); + __ mov(r1, Operand(Smi::FromInt(is_eval() ? 1 : 0))); + __ mov(r0, Operand(Smi::FromInt(strict_mode_flag()))); + __ Push(cp, r2, r1, r0); + __ CallRuntime(Runtime::kDeclareGlobals, 4); // Return value is ignored. } @@ -796,9 +807,9 @@ void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { Comment cmnt(masm_, "[ SwitchStatement"); Breakable nested_statement(this, stmt); SetStatementPosition(stmt); + // Keep the switch value on the stack until a case matches. VisitForStackValue(stmt->tag()); - PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); ZoneList* clauses = stmt->cases(); @@ -887,8 +898,9 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); __ cmp(r0, ip); __ b(eq, &exit); - __ LoadRoot(ip, Heap::kNullValueRootIndex); - __ cmp(r0, ip); + Register null_value = r5; + __ LoadRoot(null_value, Heap::kNullValueRootIndex); + __ cmp(r0, null_value); __ b(eq, &exit); // Convert the object to a JS object. @@ -902,12 +914,62 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { __ bind(&done_convert); __ push(r0); - // BUG(867): Check cache validity in generated code. This is a fast - // case for the JSObject::IsSimpleEnum cache validity checks. If we - // cannot guarantee cache validity, call the runtime system to check - // cache validity or get the property names in a fixed array. + // Check cache validity in generated code. This is a fast case for + // the JSObject::IsSimpleEnum cache validity checks. If we cannot + // guarantee cache validity, call the runtime system to check cache + // validity or get the property names in a fixed array. + Label next, call_runtime; + // Preload a couple of values used in the loop. + Register empty_fixed_array_value = r6; + __ LoadRoot(empty_fixed_array_value, Heap::kEmptyFixedArrayRootIndex); + Register empty_descriptor_array_value = r7; + __ LoadRoot(empty_descriptor_array_value, + Heap::kEmptyDescriptorArrayRootIndex); + __ mov(r1, r0); + __ bind(&next); + + // Check that there are no elements. Register r1 contains the + // current JS object we've reached through the prototype chain. + __ ldr(r2, FieldMemOperand(r1, JSObject::kElementsOffset)); + __ cmp(r2, empty_fixed_array_value); + __ b(ne, &call_runtime); + + // Check that instance descriptors are not empty so that we can + // check for an enum cache. Leave the map in r2 for the subsequent + // prototype load. + __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); + __ ldr(r3, FieldMemOperand(r2, Map::kInstanceDescriptorsOffset)); + __ cmp(r3, empty_descriptor_array_value); + __ b(eq, &call_runtime); + + // Check that there is an enum cache in the non-empty instance + // descriptors (r3). This is the case if the next enumeration + // index field does not contain a smi. + __ ldr(r3, FieldMemOperand(r3, DescriptorArray::kEnumerationIndexOffset)); + __ JumpIfSmi(r3, &call_runtime); + + // For all objects but the receiver, check that the cache is empty. + Label check_prototype; + __ cmp(r1, r0); + __ b(eq, &check_prototype); + __ ldr(r3, FieldMemOperand(r3, DescriptorArray::kEnumCacheBridgeCacheOffset)); + __ cmp(r3, empty_fixed_array_value); + __ b(ne, &call_runtime); + + // Load the prototype from the map and loop if non-null. + __ bind(&check_prototype); + __ ldr(r1, FieldMemOperand(r2, Map::kPrototypeOffset)); + __ cmp(r1, null_value); + __ b(ne, &next); + + // The enum cache is valid. Load the map of the object being + // iterated over and use the cache for the iteration. + Label use_cache; + __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); + __ b(&use_cache); // Get the set of properties to enumerate. + __ bind(&call_runtime); __ push(r0); // Duplicate the enumerable object on the stack. __ CallRuntime(Runtime::kGetPropertyNamesFast, 1); @@ -922,6 +984,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { __ b(ne, &fixed_array); // We got a map in register r0. Get the enumeration cache from it. + __ bind(&use_cache); __ ldr(r1, FieldMemOperand(r0, Map::kInstanceDescriptorsOffset)); __ ldr(r1, FieldMemOperand(r1, DescriptorArray::kEnumerationIndexOffset)); __ ldr(r2, FieldMemOperand(r1, DescriptorArray::kEnumCacheBridgeCacheOffset)); @@ -1010,8 +1073,14 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { void FullCodeGenerator::EmitNewClosure(Handle info, bool pretenure) { // Use the fast case closure allocation code that allocates in new - // space for nested functions that don't need literals cloning. - if (scope()->is_function_scope() && + // space for nested functions that don't need literals cloning. If + // we're running with the --always-opt or the --prepare-always-opt + // flag, we need to use the runtime function so that the new function + // we are creating here gets a chance to have its code optimized and + // doesn't just get a copy of the existing unoptimized code. + if (!FLAG_always_opt && + !FLAG_prepare_always_opt && + scope()->is_function_scope() && info->num_literals() == 0 && !pretenure) { FastNewClosureStub stub; @@ -1265,18 +1334,19 @@ void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { Comment cmnt(masm_, "[ RegExpLiteral"); Label materialized; // Registers will be used as follows: + // r5 = materialized value (RegExp literal) // r4 = JS function, literals array // r3 = literal index // r2 = RegExp pattern // r1 = RegExp flags - // r0 = temp + materialized value (RegExp literal) + // r0 = RegExp literal clone __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); __ ldr(r4, FieldMemOperand(r0, JSFunction::kLiteralsOffset)); int literal_offset = FixedArray::kHeaderSize + expr->literal_index() * kPointerSize; - __ ldr(r0, FieldMemOperand(r4, literal_offset)); + __ ldr(r5, FieldMemOperand(r4, literal_offset)); __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); - __ cmp(r0, ip); + __ cmp(r5, ip); __ b(ne, &materialized); // Create regexp literal using runtime function. @@ -1286,20 +1356,27 @@ void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { __ mov(r1, Operand(expr->flags())); __ Push(r4, r3, r2, r1); __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); + __ mov(r5, r0); __ bind(&materialized); int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; - __ push(r0); + Label allocated, runtime_allocate; + __ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT); + __ jmp(&allocated); + + __ bind(&runtime_allocate); + __ push(r5); __ mov(r0, Operand(Smi::FromInt(size))); __ push(r0); __ CallRuntime(Runtime::kAllocateInNewSpace, 1); + __ pop(r5); + __ bind(&allocated); // After this, registers are used as follows: // r0: Newly allocated regexp. - // r1: Materialized regexp. + // r5: Materialized regexp. // r2: temp. - __ pop(r1); - __ CopyFields(r0, r1, r2.bit(), size / kPointerSize); + __ CopyFields(r0, r5, r2.bit(), size / kPointerSize); context()->Plug(r0); } @@ -1365,7 +1442,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(key); VisitForStackValue(value); if (property->emit_store()) { - __ CallRuntime(Runtime::kSetProperty, 3); + __ mov(r0, Operand(Smi::FromInt(NONE))); // PropertyAttributes + __ push(r0); + __ CallRuntime(Runtime::kSetProperty, 4); } else { __ Drop(3); } @@ -1543,14 +1622,8 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { } Token::Value op = expr->binary_op(); - ConstantOperand constant = ShouldInlineSmiCase(op) - ? GetConstantOperand(op, expr->target(), expr->value()) - : kNoConstants; - ASSERT(constant == kRightConstant || constant == kNoConstants); - if (constant == kNoConstants) { - __ push(r0); // Left operand goes on the stack. - VisitForAccumulatorValue(expr->value()); - } + __ push(r0); // Left operand goes on the stack. + VisitForAccumulatorValue(expr->value()); OverwriteMode mode = expr->value()->ResultOverwriteAllowed() ? OVERWRITE_RIGHT @@ -1562,8 +1635,7 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { op, mode, expr->target(), - expr->value(), - constant); + expr->value()); } else { EmitBinaryOp(op, mode); } @@ -1613,217 +1685,11 @@ void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { } -void FullCodeGenerator::EmitConstantSmiAdd(Expression* expr, - OverwriteMode mode, - bool left_is_constant_smi, - Smi* value) { - Label call_stub, done; - // Optimistically add smi value with unknown object. If result overflows or is - // not a smi then we had either a smi overflow or added a smi with a tagged - // pointer. - __ mov(r1, Operand(value)); - __ add(r2, r0, r1, SetCC); - __ b(vs, &call_stub); - JumpPatchSite patch_site(masm_); - patch_site.EmitJumpIfNotSmi(r2, &call_stub); - __ mov(r0, r2); - __ b(&done); - - // Call the shared stub. - __ bind(&call_stub); - if (!left_is_constant_smi) { - __ Swap(r0, r1, r2); - } - TypeRecordingBinaryOpStub stub(Token::ADD, mode); - EmitCallIC(stub.GetCode(), &patch_site); - - __ bind(&done); - context()->Plug(r0); -} - - -void FullCodeGenerator::EmitConstantSmiSub(Expression* expr, - OverwriteMode mode, - bool left_is_constant_smi, - Smi* value) { - Label call_stub, done; - // Optimistically subtract smi value and unknown object. If result overflows - // or is not a smi then we had either a smi overflow or subtraction between a - // smi and a tagged pointer. - __ mov(r1, Operand(value)); - if (left_is_constant_smi) { - __ sub(r2, r1, r0, SetCC); - } else { - __ sub(r2, r0, r1, SetCC); - } - __ b(vs, &call_stub); - JumpPatchSite patch_site(masm_); - patch_site.EmitJumpIfNotSmi(r2, &call_stub); - __ mov(r0, r2); - __ b(&done); - - // Call the shared stub. - __ bind(&call_stub); - if (!left_is_constant_smi) { - __ Swap(r0, r1, r2); - } - TypeRecordingBinaryOpStub stub(Token::SUB, mode); - EmitCallIC(stub.GetCode(), &patch_site); - - __ bind(&done); - context()->Plug(r0); -} - - -void FullCodeGenerator::EmitConstantSmiShiftOp(Expression* expr, - Token::Value op, - OverwriteMode mode, - Smi* value) { - Label call_stub, smi_case, done; - int shift_value = value->value() & 0x1f; - - JumpPatchSite patch_site(masm_); - patch_site.EmitJumpIfSmi(r0, &smi_case); - - // Call stub. - __ bind(&call_stub); - __ mov(r1, r0); - __ mov(r0, Operand(value)); - TypeRecordingBinaryOpStub stub(op, mode); - EmitCallIC(stub.GetCode(), &patch_site); - __ b(&done); - - // Smi case. - __ bind(&smi_case); - switch (op) { - case Token::SHL: - if (shift_value != 0) { - __ mov(r1, r0); - if (shift_value > 1) { - __ mov(r1, Operand(r1, LSL, shift_value - 1)); - } - // Convert int result to smi, checking that it is in int range. - __ SmiTag(r1, SetCC); - __ b(vs, &call_stub); - __ mov(r0, r1); // Put result back into r0. - } - break; - case Token::SAR: - if (shift_value != 0) { - __ mov(r0, Operand(r0, ASR, shift_value)); - __ bic(r0, r0, Operand(kSmiTagMask)); - } - break; - case Token::SHR: - // SHR must return a positive value. When shifting by 0 or 1 we need to - // check that smi tagging the result will not create a negative value. - if (shift_value < 2) { - __ mov(r2, Operand(shift_value)); - __ SmiUntag(r1, r0); - if (shift_value != 0) { - __ mov(r1, Operand(r1, LSR, shift_value)); - } - __ tst(r1, Operand(0xc0000000)); - __ b(ne, &call_stub); - __ SmiTag(r0, r1); // result in r0. - } else { - __ SmiUntag(r0); - __ mov(r0, Operand(r0, LSR, shift_value)); - __ SmiTag(r0); - } - break; - default: - UNREACHABLE(); - } - - __ bind(&done); - context()->Plug(r0); -} - - -void FullCodeGenerator::EmitConstantSmiBitOp(Expression* expr, - Token::Value op, - OverwriteMode mode, - Smi* value) { - Label smi_case, done; - - JumpPatchSite patch_site(masm_); - patch_site.EmitJumpIfSmi(r0, &smi_case); - - // The order of the arguments does not matter for bit-ops with a - // constant operand. - __ mov(r1, Operand(value)); - TypeRecordingBinaryOpStub stub(op, mode); - EmitCallIC(stub.GetCode(), &patch_site); - __ jmp(&done); - - // Smi case. - __ bind(&smi_case); - __ mov(r1, Operand(value)); - switch (op) { - case Token::BIT_OR: - __ orr(r0, r0, Operand(r1)); - break; - case Token::BIT_XOR: - __ eor(r0, r0, Operand(r1)); - break; - case Token::BIT_AND: - __ and_(r0, r0, Operand(r1)); - break; - default: - UNREACHABLE(); - } - - __ bind(&done); - context()->Plug(r0); -} - - -void FullCodeGenerator::EmitConstantSmiBinaryOp(Expression* expr, - Token::Value op, - OverwriteMode mode, - bool left_is_constant_smi, - Smi* value) { - switch (op) { - case Token::BIT_OR: - case Token::BIT_XOR: - case Token::BIT_AND: - EmitConstantSmiBitOp(expr, op, mode, value); - break; - case Token::SHL: - case Token::SAR: - case Token::SHR: - ASSERT(!left_is_constant_smi); - EmitConstantSmiShiftOp(expr, op, mode, value); - break; - case Token::ADD: - EmitConstantSmiAdd(expr, mode, left_is_constant_smi, value); - break; - case Token::SUB: - EmitConstantSmiSub(expr, mode, left_is_constant_smi, value); - break; - default: - UNREACHABLE(); - } -} - - void FullCodeGenerator::EmitInlineSmiBinaryOp(Expression* expr, Token::Value op, OverwriteMode mode, Expression* left_expr, - Expression* right_expr, - ConstantOperand constant) { - if (constant == kRightConstant) { - Smi* value = Smi::cast(*right_expr->AsLiteral()->handle()); - EmitConstantSmiBinaryOp(expr, op, mode, false, value); - return; - } else if (constant == kLeftConstant) { - Smi* value = Smi::cast(*left_expr->AsLiteral()->handle()); - EmitConstantSmiBinaryOp(expr, op, mode, true, value); - return; - } - + Expression* right_expr) { Label done, smi_case, stub_call; Register scratch1 = r2; @@ -1959,7 +1825,9 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) { __ mov(r1, r0); __ pop(r0); // Restore value. __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); break; } @@ -1980,7 +1848,9 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) { __ pop(r2); } __ pop(r0); // Restore value. - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); break; } @@ -2004,9 +1874,9 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, // r2, and the global object in r1. __ mov(r2, Operand(var->name())); __ ldr(r1, GlobalObjectOperand()); - Handle ic(Builtins::builtin(is_strict() - ? Builtins::StoreIC_Initialize_Strict - : Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); } else if (op == Token::INIT_CONST) { @@ -2075,9 +1945,10 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, case Slot::LOOKUP: // Call the runtime for the assignment. __ push(r0); // Value. - __ mov(r0, Operand(slot->var()->name())); - __ Push(cp, r0); // Context and name. - __ CallRuntime(Runtime::kStoreContextSlot, 3); + __ mov(r1, Operand(slot->var()->name())); + __ mov(r0, Operand(Smi::FromInt(strict_mode_flag()))); + __ Push(cp, r1, r0); // Context, name, strict mode. + __ CallRuntime(Runtime::kStoreContextSlot, 4); break; } } @@ -2112,7 +1983,9 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { __ pop(r1); } - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); // If the assignment ends an initialization block, revert to fast case. @@ -2156,7 +2029,9 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { __ pop(r2); } - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); // If the assignment ends an initialization block, revert to fast case. @@ -2271,6 +2146,29 @@ void FullCodeGenerator::EmitCallWithStub(Call* expr) { } +void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, + int arg_count) { + // Push copy of the first argument or undefined if it doesn't exist. + if (arg_count > 0) { + __ ldr(r1, MemOperand(sp, arg_count * kPointerSize)); + } else { + __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); + } + __ push(r1); + + // Push the receiver of the enclosing function and do runtime call. + __ ldr(r1, MemOperand(fp, (2 + scope()->num_parameters()) * kPointerSize)); + __ push(r1); + // Push the strict mode flag. + __ mov(r1, Operand(Smi::FromInt(strict_mode_flag()))); + __ push(r1); + + __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP + ? Runtime::kResolvePossiblyDirectEvalNoLookup + : Runtime::kResolvePossiblyDirectEval, 4); +} + + void FullCodeGenerator::VisitCall(Call* expr) { #ifdef DEBUG // We want to verify that RecordJSReturnSite gets called on all paths @@ -2300,26 +2198,31 @@ void FullCodeGenerator::VisitCall(Call* expr) { VisitForStackValue(args->at(i)); } - // Push copy of the function - found below the arguments. - __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); - __ push(r1); - - // Push copy of the first argument or undefined if it doesn't exist. - if (arg_count > 0) { - __ ldr(r1, MemOperand(sp, arg_count * kPointerSize)); - __ push(r1); - } else { - __ push(r2); + // If we know that eval can only be shadowed by eval-introduced + // variables we attempt to load the global eval function directly + // in generated code. If we succeed, there is no need to perform a + // context lookup in the runtime system. + Label done; + if (var->AsSlot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) { + Label slow; + EmitLoadGlobalSlotCheckExtensions(var->AsSlot(), + NOT_INSIDE_TYPEOF, + &slow); + // Push the function and resolve eval. + __ push(r0); + EmitResolvePossiblyDirectEval(SKIP_CONTEXT_LOOKUP, arg_count); + __ jmp(&done); + __ bind(&slow); } - // Push the receiver of the enclosing function and do runtime call. - __ ldr(r1, - MemOperand(fp, (2 + scope()->num_parameters()) * kPointerSize)); - __ push(r1); - // Push the strict mode flag. - __ mov(r1, Operand(Smi::FromInt(strict_mode_flag()))); + // Push copy of the function (found below the arguments) and + // resolve eval. + __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); __ push(r1); - __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4); + EmitResolvePossiblyDirectEval(PERFORM_CONTEXT_LOOKUP, arg_count); + if (done.is_linked()) { + __ bind(&done); + } // The runtime call returns a pair of values in r0 (function) and // r1 (receiver). Touch up the stack with the right values. @@ -3134,37 +3037,40 @@ void FullCodeGenerator::EmitStringCompare(ZoneList* args) { void FullCodeGenerator::EmitMathSin(ZoneList* args) { - // Load the argument on the stack and call the runtime. + // Load the argument on the stack and call the stub. + TranscendentalCacheStub stub(TranscendentalCache::SIN); ASSERT(args->length() == 1); VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_sin, 1); + __ CallStub(&stub); context()->Plug(r0); } void FullCodeGenerator::EmitMathCos(ZoneList* args) { - // Load the argument on the stack and call the runtime. + // Load the argument on the stack and call the stub. + TranscendentalCacheStub stub(TranscendentalCache::COS); ASSERT(args->length() == 1); VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_cos, 1); + __ CallStub(&stub); context()->Plug(r0); } -void FullCodeGenerator::EmitMathSqrt(ZoneList* args) { - // Load the argument on the stack and call the runtime function. +void FullCodeGenerator::EmitMathLog(ZoneList* args) { + // Load the argument on the stack and call the stub. + TranscendentalCacheStub stub(TranscendentalCache::LOG); ASSERT(args->length() == 1); VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_sqrt, 1); + __ CallStub(&stub); context()->Plug(r0); } -void FullCodeGenerator::EmitMathLog(ZoneList* args) { +void FullCodeGenerator::EmitMathSqrt(ZoneList* args) { // Load the argument on the stack and call the runtime function. ASSERT(args->length() == 1); VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_log, 1); + __ CallRuntime(Runtime::kMath_sqrt, 1); context()->Plug(r0); } @@ -3323,16 +3229,248 @@ void FullCodeGenerator::EmitHasCachedArrayIndex(ZoneList* args) { void FullCodeGenerator::EmitGetCachedArrayIndex(ZoneList* args) { ASSERT(args->length() == 1); VisitForAccumulatorValue(args->at(0)); + + if (FLAG_debug_code) { + __ AbortIfNotString(r0); + } + __ ldr(r0, FieldMemOperand(r0, String::kHashFieldOffset)); __ IndexFromHash(r0, r0); + context()->Plug(r0); } void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { + Label bailout, done, one_char_separator, long_separator, + non_trivial_array, not_size_one_array, loop, + empty_separator_loop, one_char_separator_loop, + one_char_separator_loop_entry, long_separator_loop; + + ASSERT(args->length() == 2); + VisitForStackValue(args->at(1)); + VisitForAccumulatorValue(args->at(0)); + + // All aliases of the same register have disjoint lifetimes. + Register array = r0; + Register elements = no_reg; // Will be r0. + Register result = no_reg; // Will be r0. + Register separator = r1; + Register array_length = r2; + Register result_pos = no_reg; // Will be r2 + Register string_length = r3; + Register string = r4; + Register element = r5; + Register elements_end = r6; + Register scratch1 = r7; + Register scratch2 = r9; + + // Separator operand is on the stack. + __ pop(separator); + + // Check that the array is a JSArray. + __ JumpIfSmi(array, &bailout); + __ CompareObjectType(array, scratch1, scratch2, JS_ARRAY_TYPE); + __ b(ne, &bailout); + + // Check that the array has fast elements. + __ ldrb(scratch2, FieldMemOperand(scratch1, Map::kBitField2Offset)); + __ tst(scratch2, Operand(1 << Map::kHasFastElements)); + __ b(eq, &bailout); + + // If the array has length zero, return the empty string. + __ ldr(array_length, FieldMemOperand(array, JSArray::kLengthOffset)); + __ SmiUntag(array_length, SetCC); + __ b(ne, &non_trivial_array); + __ LoadRoot(r0, Heap::kEmptyStringRootIndex); + __ b(&done); + + __ bind(&non_trivial_array); + + // Get the FixedArray containing array's elements. + elements = array; + __ ldr(elements, FieldMemOperand(array, JSArray::kElementsOffset)); + array = no_reg; // End of array's live range. + + // Check that all array elements are sequential ASCII strings, and + // accumulate the sum of their lengths, as a smi-encoded value. + __ mov(string_length, Operand(0)); + __ add(element, + elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); + __ add(elements_end, element, Operand(array_length, LSL, kPointerSizeLog2)); + // Loop condition: while (element < elements_end). + // Live values in registers: + // elements: Fixed array of strings. + // array_length: Length of the fixed array of strings (not smi) + // separator: Separator string + // string_length: Accumulated sum of string lengths (smi). + // element: Current array element. + // elements_end: Array end. + if (FLAG_debug_code) { + __ cmp(array_length, Operand(0)); + __ Assert(gt, "No empty arrays here in EmitFastAsciiArrayJoin"); + } + __ bind(&loop); + __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); + __ JumpIfSmi(string, &bailout); + __ ldr(scratch1, FieldMemOperand(string, HeapObject::kMapOffset)); + __ ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); + __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); + __ ldr(scratch1, FieldMemOperand(string, SeqAsciiString::kLengthOffset)); + __ add(string_length, string_length, Operand(scratch1)); + __ b(vs, &bailout); + __ cmp(element, elements_end); + __ b(lt, &loop); + + // If array_length is 1, return elements[0], a string. + __ cmp(array_length, Operand(1)); + __ b(ne, ¬_size_one_array); + __ ldr(r0, FieldMemOperand(elements, FixedArray::kHeaderSize)); + __ b(&done); + + __ bind(¬_size_one_array); + + // Live values in registers: + // separator: Separator string + // array_length: Length of the array. + // string_length: Sum of string lengths (smi). + // elements: FixedArray of strings. + + // Check that the separator is a flat ASCII string. + __ JumpIfSmi(separator, &bailout); + __ ldr(scratch1, FieldMemOperand(separator, HeapObject::kMapOffset)); + __ ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); + __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); + + // Add (separator length times array_length) - separator length to the + // string_length to get the length of the result string. array_length is not + // smi but the other values are, so the result is a smi + __ ldr(scratch1, FieldMemOperand(separator, SeqAsciiString::kLengthOffset)); + __ sub(string_length, string_length, Operand(scratch1)); + __ smull(scratch2, ip, array_length, scratch1); + // Check for smi overflow. No overflow if higher 33 bits of 64-bit result are + // zero. + __ cmp(ip, Operand(0)); + __ b(ne, &bailout); + __ tst(scratch2, Operand(0x80000000)); + __ b(ne, &bailout); + __ add(string_length, string_length, Operand(scratch2)); + __ b(vs, &bailout); + __ SmiUntag(string_length); + + // Get first element in the array to free up the elements register to be used + // for the result. + __ add(element, + elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); + result = elements; // End of live range for elements. + elements = no_reg; + // Live values in registers: + // element: First array element + // separator: Separator string + // string_length: Length of result string (not smi) + // array_length: Length of the array. + __ AllocateAsciiString(result, + string_length, + scratch1, + scratch2, + elements_end, + &bailout); + // Prepare for looping. Set up elements_end to end of the array. Set + // result_pos to the position of the result where to write the first + // character. + __ add(elements_end, element, Operand(array_length, LSL, kPointerSizeLog2)); + result_pos = array_length; // End of live range for array_length. + array_length = no_reg; + __ add(result_pos, + result, + Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); + + // Check the length of the separator. + __ ldr(scratch1, FieldMemOperand(separator, SeqAsciiString::kLengthOffset)); + __ cmp(scratch1, Operand(Smi::FromInt(1))); + __ b(eq, &one_char_separator); + __ b(gt, &long_separator); + + // Empty separator case + __ bind(&empty_separator_loop); + // Live values in registers: + // result_pos: the position to which we are currently copying characters. + // element: Current array element. + // elements_end: Array end. + + // Copy next array element to the result. + __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); + __ ldr(string_length, FieldMemOperand(string, String::kLengthOffset)); + __ SmiUntag(string_length); + __ add(string, string, Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); + __ CopyBytes(string, result_pos, string_length, scratch1); + __ cmp(element, elements_end); + __ b(lt, &empty_separator_loop); // End while (element < elements_end). + ASSERT(result.is(r0)); + __ b(&done); + + // One-character separator case + __ bind(&one_char_separator); + // Replace separator with its ascii character value. + __ ldrb(separator, FieldMemOperand(separator, SeqAsciiString::kHeaderSize)); + // Jump into the loop after the code that copies the separator, so the first + // element is not preceded by a separator + __ jmp(&one_char_separator_loop_entry); + + __ bind(&one_char_separator_loop); + // Live values in registers: + // result_pos: the position to which we are currently copying characters. + // element: Current array element. + // elements_end: Array end. + // separator: Single separator ascii char (in lower byte). + + // Copy the separator character to the result. + __ strb(separator, MemOperand(result_pos, 1, PostIndex)); + + // Copy next array element to the result. + __ bind(&one_char_separator_loop_entry); + __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); + __ ldr(string_length, FieldMemOperand(string, String::kLengthOffset)); + __ SmiUntag(string_length); + __ add(string, string, Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); + __ CopyBytes(string, result_pos, string_length, scratch1); + __ cmp(element, elements_end); + __ b(lt, &one_char_separator_loop); // End while (element < elements_end). + ASSERT(result.is(r0)); + __ b(&done); + + // Long separator case (separator is more than one character). Entry is at the + // label long_separator below. + __ bind(&long_separator_loop); + // Live values in registers: + // result_pos: the position to which we are currently copying characters. + // element: Current array element. + // elements_end: Array end. + // separator: Separator string. + + // Copy the separator to the result. + __ ldr(string_length, FieldMemOperand(separator, String::kLengthOffset)); + __ SmiUntag(string_length); + __ add(string, + separator, + Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); + __ CopyBytes(string, result_pos, string_length, scratch1); + + __ bind(&long_separator); + __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); + __ ldr(string_length, FieldMemOperand(string, String::kLengthOffset)); + __ SmiUntag(string_length); + __ add(string, string, Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); + __ CopyBytes(string, result_pos, string_length, scratch1); + __ cmp(element, elements_end); + __ b(lt, &long_separator_loop); // End while (element < elements_end). + ASSERT(result.is(r0)); + __ b(&done); + + __ bind(&bailout); __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); + __ bind(&done); context()->Plug(r0); - return; } @@ -3486,9 +3624,7 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); UnaryOverwriteMode overwrite = can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; - GenericUnaryOpStub stub(Token::SUB, - overwrite, - NO_UNARY_FLAGS); + GenericUnaryOpStub stub(Token::SUB, overwrite, NO_UNARY_FLAGS); // GenericUnaryOpStub expects the argument to be in the // accumulator register r0. VisitForAccumulatorValue(expr->expression()); @@ -3669,7 +3805,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case NAMED_PROPERTY: { __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); __ pop(r1); - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); if (expr->is_postfix()) { @@ -3684,7 +3822,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case KEYED_PROPERTY: { __ pop(r1); // Key. __ pop(r2); // Receiver. - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); if (expr->is_postfix()) { @@ -3998,11 +4138,43 @@ Register FullCodeGenerator::context_register() { void FullCodeGenerator::EmitCallIC(Handle ic, RelocInfo::Mode mode) { ASSERT(mode == RelocInfo::CODE_TARGET || mode == RelocInfo::CODE_TARGET_CONTEXT); + switch (ic->kind()) { + case Code::LOAD_IC: + __ IncrementCounter(&Counters::named_load_full, 1, r1, r2); + break; + case Code::KEYED_LOAD_IC: + __ IncrementCounter(&Counters::keyed_load_full, 1, r1, r2); + break; + case Code::STORE_IC: + __ IncrementCounter(&Counters::named_store_full, 1, r1, r2); + break; + case Code::KEYED_STORE_IC: + __ IncrementCounter(&Counters::keyed_store_full, 1, r1, r2); + default: + break; + } + __ Call(ic, mode); } void FullCodeGenerator::EmitCallIC(Handle ic, JumpPatchSite* patch_site) { + switch (ic->kind()) { + case Code::LOAD_IC: + __ IncrementCounter(&Counters::named_load_full, 1, r1, r2); + break; + case Code::KEYED_LOAD_IC: + __ IncrementCounter(&Counters::keyed_load_full, 1, r1, r2); + break; + case Code::STORE_IC: + __ IncrementCounter(&Counters::named_store_full, 1, r1, r2); + break; + case Code::KEYED_STORE_IC: + __ IncrementCounter(&Counters::keyed_store_full, 1, r1, r2); + default: + break; + } + __ Call(ic, RelocInfo::CODE_TARGET); if (patch_site != NULL && patch_site->is_bound()) { patch_site->EmitPatchInfo(); diff --git a/deps/v8/src/arm/ic-arm.cc b/deps/v8/src/arm/ic-arm.cc index 6c7aa0643a..0fc6818703 100644 --- a/deps/v8/src/arm/ic-arm.cc +++ b/deps/v8/src/arm/ic-arm.cc @@ -1400,7 +1400,8 @@ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { } -void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm) { +void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, + StrictModeFlag strict_mode) { // ---------- S t a t e -------------- // -- r0 : value // -- r1 : key @@ -1411,11 +1412,16 @@ void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm) { // Push receiver, key and value for runtime call. __ Push(r2, r1, r0); - __ TailCallRuntime(Runtime::kSetProperty, 3, 1); + __ mov(r1, Operand(Smi::FromInt(NONE))); // PropertyAttributes + __ mov(r0, Operand(Smi::FromInt(strict_mode))); // Strict mode. + __ Push(r1, r0); + + __ TailCallRuntime(Runtime::kSetProperty, 5, 1); } -void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { +void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, + StrictModeFlag strict_mode) { // ---------- S t a t e -------------- // -- r0 : value // -- r1 : key @@ -1470,7 +1476,7 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { // r0: value. // r1: key. // r2: receiver. - GenerateRuntimeSetProperty(masm); + GenerateRuntimeSetProperty(masm, strict_mode); // Check whether the elements is a pixel array. // r4: elements map. @@ -1540,7 +1546,7 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { void StoreIC::GenerateMegamorphic(MacroAssembler* masm, - Code::ExtraICState extra_ic_state) { + StrictModeFlag strict_mode) { // ----------- S t a t e ------------- // -- r0 : value // -- r1 : receiver @@ -1552,7 +1558,7 @@ void StoreIC::GenerateMegamorphic(MacroAssembler* masm, Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, NOT_IN_LOOP, MONOMORPHIC, - extra_ic_state); + strict_mode); StubCache::GenerateProbe(masm, flags, r1, r2, r3, r4, r5); // Cache miss: Jump to runtime. @@ -1646,7 +1652,8 @@ void StoreIC::GenerateNormal(MacroAssembler* masm) { } -void StoreIC::GenerateGlobalProxy(MacroAssembler* masm) { +void StoreIC::GenerateGlobalProxy(MacroAssembler* masm, + StrictModeFlag strict_mode) { // ----------- S t a t e ------------- // -- r0 : value // -- r1 : receiver @@ -1656,8 +1663,12 @@ void StoreIC::GenerateGlobalProxy(MacroAssembler* masm) { __ Push(r1, r2, r0); + __ mov(r1, Operand(Smi::FromInt(NONE))); // PropertyAttributes + __ mov(r0, Operand(Smi::FromInt(strict_mode))); + __ Push(r1, r0); + // Do tail-call to runtime routine. - __ TailCallRuntime(Runtime::kSetProperty, 3, 1); + __ TailCallRuntime(Runtime::kSetProperty, 5, 1); } diff --git a/deps/v8/src/arm/lithium-arm.cc b/deps/v8/src/arm/lithium-arm.cc index d3c9fee8e3..54ed4bace3 100644 --- a/deps/v8/src/arm/lithium-arm.cc +++ b/deps/v8/src/arm/lithium-arm.cc @@ -1154,8 +1154,7 @@ LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal( HInstanceOfKnownGlobal* instr) { LInstanceOfKnownGlobal* result = new LInstanceOfKnownGlobal(UseFixed(instr->value(), r0), FixedTemp(r4)); - MarkAsSaveDoubles(result); - return AssignEnvironment(AssignPointerMap(DefineFixed(result, r0))); + return MarkAsCall(DefineFixed(result, r0), instr); } diff --git a/deps/v8/src/arm/lithium-codegen-arm.cc b/deps/v8/src/arm/lithium-codegen-arm.cc index ca64442270..c5e9271760 100644 --- a/deps/v8/src/arm/lithium-codegen-arm.cc +++ b/deps/v8/src/arm/lithium-codegen-arm.cc @@ -573,7 +573,8 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { Handle data = Factory::NewDeoptimizationInputData(length, TENURED); - data->SetTranslationByteArray(*translations_.CreateByteArray()); + Handle translations = translations_.CreateByteArray(); + data->SetTranslationByteArray(*translations); data->SetInlinedFunctionCount(Smi::FromInt(inlined_function_count_)); Handle literals = @@ -1985,11 +1986,7 @@ void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, __ BlockConstPoolFor(kAdditionalDelta); __ mov(temp, Operand(delta * kPointerSize)); __ StoreToSafepointRegisterSlot(temp, temp); - __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); - ASSERT_EQ(kAdditionalDelta, - masm_->InstructionsGeneratedSince(&before_push_delta)); - RecordSafepointWithRegisters( - instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); + CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); // Put the result value into the result register slot and // restore all registers. __ StoreToSafepointRegisterSlot(result, result); @@ -2586,41 +2583,6 @@ void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { } -// Truncates a double using a specific rounding mode. -// Clears the z flag (ne condition) if an overflow occurs. -void LCodeGen::EmitVFPTruncate(VFPRoundingMode rounding_mode, - SwVfpRegister result, - DwVfpRegister double_input, - Register scratch1, - Register scratch2) { - Register prev_fpscr = scratch1; - Register scratch = scratch2; - - // Set custom FPCSR: - // - Set rounding mode. - // - Clear vfp cumulative exception flags. - // - Make sure Flush-to-zero mode control bit is unset. - __ vmrs(prev_fpscr); - __ bic(scratch, prev_fpscr, Operand(kVFPExceptionMask | - kVFPRoundingModeMask | - kVFPFlushToZeroMask)); - __ orr(scratch, scratch, Operand(rounding_mode)); - __ vmsr(scratch); - - // Convert the argument to an integer. - __ vcvt_s32_f64(result, - double_input, - kFPSCRRounding); - - // Retrieve FPSCR. - __ vmrs(scratch); - // Restore FPSCR. - __ vmsr(prev_fpscr); - // Check for vfp exceptions. - __ tst(scratch, Operand(kVFPExceptionMask)); -} - - void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); Register result = ToRegister(instr->result()); @@ -2628,11 +2590,11 @@ void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { Register scratch1 = scratch0(); Register scratch2 = ToRegister(instr->TempAt(0)); - EmitVFPTruncate(kRoundToMinusInf, - single_scratch, - input, - scratch1, - scratch2); + __ EmitVFPTruncate(kRoundToMinusInf, + single_scratch, + input, + scratch1, + scratch2); DeoptimizeIf(ne, instr->environment()); // Move the result back to general purpose register r0. @@ -2654,11 +2616,11 @@ void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { Register result = ToRegister(instr->result()); Register scratch1 = scratch0(); Register scratch2 = result; - EmitVFPTruncate(kRoundToNearest, - double_scratch0().low(), - input, - scratch1, - scratch2); + __ EmitVFPTruncate(kRoundToNearest, + double_scratch0().low(), + input, + scratch1, + scratch2); DeoptimizeIf(ne, instr->environment()); __ vmov(result, double_scratch0().low()); @@ -2863,9 +2825,9 @@ void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { // Name is always in r2. __ mov(r2, Operand(instr->name())); - Handle ic(Builtins::builtin(info_->is_strict() - ? Builtins::StoreIC_Initialize_Strict - : Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + info_->is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -2907,7 +2869,9 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { ASSERT(ToRegister(instr->key()).is(r1)); ASSERT(ToRegister(instr->value()).is(r0)); - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + info_->is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -3371,30 +3335,36 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) { Register scratch1 = scratch0(); Register scratch2 = ToRegister(instr->TempAt(0)); - VFPRoundingMode rounding_mode = instr->truncating() ? kRoundToMinusInf - : kRoundToNearest; + __ EmitVFPTruncate(kRoundToZero, + single_scratch, + double_input, + scratch1, + scratch2); - EmitVFPTruncate(rounding_mode, - single_scratch, - double_input, - scratch1, - scratch2); // Deoptimize if we had a vfp invalid exception. DeoptimizeIf(ne, instr->environment()); + // Retrieve the result. __ vmov(result_reg, single_scratch); - if (instr->truncating() && - instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { - Label done; - __ cmp(result_reg, Operand(0)); - __ b(ne, &done); - // Check for -0. - __ vmov(scratch1, double_input.high()); - __ tst(scratch1, Operand(HeapNumber::kSignMask)); + if (!instr->truncating()) { + // Convert result back to double and compare with input + // to check if the conversion was exact. + __ vmov(single_scratch, result_reg); + __ vcvt_f64_s32(double_scratch0(), single_scratch); + __ VFPCompareAndSetFlags(double_scratch0(), double_input); DeoptimizeIf(ne, instr->environment()); + if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { + Label done; + __ cmp(result_reg, Operand(0)); + __ b(ne, &done); + // Check for -0. + __ vmov(scratch1, double_input.high()); + __ tst(scratch1, Operand(HeapNumber::kSignMask)); + DeoptimizeIf(ne, instr->environment()); - __ bind(&done); + __ bind(&done); + } } } diff --git a/deps/v8/src/arm/lithium-codegen-arm.h b/deps/v8/src/arm/lithium-codegen-arm.h index 2d9c6edcb6..a26f6311e2 100644 --- a/deps/v8/src/arm/lithium-codegen-arm.h +++ b/deps/v8/src/arm/lithium-codegen-arm.h @@ -206,11 +206,6 @@ class LCodeGen BASE_EMBEDDED { // Specific math operations - used from DoUnaryMathOperation. void EmitIntegerMathAbs(LUnaryMathOperation* instr); void DoMathAbs(LUnaryMathOperation* instr); - void EmitVFPTruncate(VFPRoundingMode rounding_mode, - SwVfpRegister result, - DwVfpRegister double_input, - Register scratch1, - Register scratch2); void DoMathFloor(LUnaryMathOperation* instr); void DoMathRound(LUnaryMathOperation* instr); void DoMathSqrt(LUnaryMathOperation* instr); diff --git a/deps/v8/src/arm/macro-assembler-arm.cc b/deps/v8/src/arm/macro-assembler-arm.cc index 65c92f9e13..9340b61dd8 100644 --- a/deps/v8/src/arm/macro-assembler-arm.cc +++ b/deps/v8/src/arm/macro-assembler-arm.cc @@ -271,6 +271,29 @@ void MacroAssembler::Sbfx(Register dst, Register src1, int lsb, int width, } +void MacroAssembler::Bfi(Register dst, + Register src, + Register scratch, + int lsb, + int width, + Condition cond) { + ASSERT(0 <= lsb && lsb < 32); + ASSERT(0 <= width && width < 32); + ASSERT(lsb + width < 32); + ASSERT(!scratch.is(dst)); + if (width == 0) return; + if (!CpuFeatures::IsSupported(ARMv7)) { + int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1); + bic(dst, dst, Operand(mask)); + and_(scratch, src, Operand((1 << width) - 1)); + mov(scratch, Operand(scratch, LSL, lsb)); + orr(dst, dst, scratch); + } else { + bfi(dst, src, lsb, width, cond); + } +} + + void MacroAssembler::Bfc(Register dst, int lsb, int width, Condition cond) { ASSERT(lsb < 32); if (!CpuFeatures::IsSupported(ARMv7)) { @@ -1618,7 +1641,7 @@ static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn( - ApiFunction* function, int stack_space) { + ExternalReference function, int stack_space) { ExternalReference next_address = ExternalReference::handle_scope_next_address(); const int kNextOffset = 0; @@ -1818,9 +1841,9 @@ void MacroAssembler::ConvertToInt32(Register source, ldr(scratch, FieldMemOperand(source, HeapNumber::kExponentOffset)); // Get exponent alone in scratch2. Ubfx(scratch2, - scratch, - HeapNumber::kExponentShift, - HeapNumber::kExponentBits); + scratch, + HeapNumber::kExponentShift, + HeapNumber::kExponentBits); // Load dest with zero. We use this either for the final shift or // for the answer. mov(dest, Operand(0, RelocInfo::NONE)); @@ -1883,6 +1906,52 @@ void MacroAssembler::ConvertToInt32(Register source, } +void MacroAssembler::EmitVFPTruncate(VFPRoundingMode rounding_mode, + SwVfpRegister result, + DwVfpRegister double_input, + Register scratch1, + Register scratch2, + CheckForInexactConversion check_inexact) { + ASSERT(CpuFeatures::IsSupported(VFP3)); + CpuFeatures::Scope scope(VFP3); + Register prev_fpscr = scratch1; + Register scratch = scratch2; + + int32_t check_inexact_conversion = + (check_inexact == kCheckForInexactConversion) ? kVFPInexactExceptionBit : 0; + + // Set custom FPCSR: + // - Set rounding mode. + // - Clear vfp cumulative exception flags. + // - Make sure Flush-to-zero mode control bit is unset. + vmrs(prev_fpscr); + bic(scratch, + prev_fpscr, + Operand(kVFPExceptionMask | + check_inexact_conversion | + kVFPRoundingModeMask | + kVFPFlushToZeroMask)); + // 'Round To Nearest' is encoded by 0b00 so no bits need to be set. + if (rounding_mode != kRoundToNearest) { + orr(scratch, scratch, Operand(rounding_mode)); + } + vmsr(scratch); + + // Convert the argument to an integer. + vcvt_s32_f64(result, + double_input, + (rounding_mode == kRoundToZero) ? kDefaultRoundToZero + : kFPSCRRounding); + + // Retrieve FPSCR. + vmrs(scratch); + // Restore FPSCR. + vmsr(prev_fpscr); + // Check for vfp exceptions. + tst(scratch, Operand(kVFPExceptionMask | check_inexact_conversion)); +} + + void MacroAssembler::GetLeastBitsFromSmi(Register dst, Register src, int num_least_bits) { @@ -2389,6 +2458,60 @@ void MacroAssembler::CopyFields(Register dst, } +void MacroAssembler::CopyBytes(Register src, + Register dst, + Register length, + Register scratch) { + Label align_loop, align_loop_1, word_loop, byte_loop, byte_loop_1, done; + + // Align src before copying in word size chunks. + bind(&align_loop); + cmp(length, Operand(0)); + b(eq, &done); + bind(&align_loop_1); + tst(src, Operand(kPointerSize - 1)); + b(eq, &word_loop); + ldrb(scratch, MemOperand(src, 1, PostIndex)); + strb(scratch, MemOperand(dst, 1, PostIndex)); + sub(length, length, Operand(1), SetCC); + b(ne, &byte_loop_1); + + // Copy bytes in word size chunks. + bind(&word_loop); + if (FLAG_debug_code) { + tst(src, Operand(kPointerSize - 1)); + Assert(eq, "Expecting alignment for CopyBytes"); + } + cmp(length, Operand(kPointerSize)); + b(lt, &byte_loop); + ldr(scratch, MemOperand(src, kPointerSize, PostIndex)); +#if CAN_USE_UNALIGNED_ACCESSES + str(scratch, MemOperand(dst, kPointerSize, PostIndex)); +#else + strb(scratch, MemOperand(dst, 1, PostIndex)); + mov(scratch, Operand(scratch, LSR, 8)); + strb(scratch, MemOperand(dst, 1, PostIndex)); + mov(scratch, Operand(scratch, LSR, 8)); + strb(scratch, MemOperand(dst, 1, PostIndex)); + mov(scratch, Operand(scratch, LSR, 8)); + strb(scratch, MemOperand(dst, 1, PostIndex)); +#endif + sub(length, length, Operand(kPointerSize)); + b(&word_loop); + + // Copy the last bytes if any left. + bind(&byte_loop); + cmp(length, Operand(0)); + b(eq, &done); + bind(&byte_loop_1); + ldrb(scratch, MemOperand(src, 1, PostIndex)); + strb(scratch, MemOperand(dst, 1, PostIndex)); + sub(length, length, Operand(1), SetCC); + b(ne, &byte_loop_1); + bind(&done); +} + + void MacroAssembler::CountLeadingZeros(Register zeros, // Answer. Register source, // Input. Register scratch) { diff --git a/deps/v8/src/arm/macro-assembler-arm.h b/deps/v8/src/arm/macro-assembler-arm.h index 83c59a6f65..acd1d79b7c 100644 --- a/deps/v8/src/arm/macro-assembler-arm.h +++ b/deps/v8/src/arm/macro-assembler-arm.h @@ -121,6 +121,15 @@ class MacroAssembler: public Assembler { Condition cond = al); void Sbfx(Register dst, Register src, int lsb, int width, Condition cond = al); + // The scratch register is not used for ARMv7. + // scratch can be the same register as src (in which case it is trashed), but + // not the same as dst. + void Bfi(Register dst, + Register src, + Register scratch, + int lsb, + int width, + Condition cond = al); void Bfc(Register dst, int lsb, int width, Condition cond = al); void Usat(Register dst, int satpos, const Operand& src, Condition cond = al); @@ -234,6 +243,17 @@ class MacroAssembler: public Assembler { } } + // Pop two registers. Pops rightmost register first (from lower address). + void Pop(Register src1, Register src2, Condition cond = al) { + ASSERT(!src1.is(src2)); + if (src1.code() > src2.code()) { + ldm(ia_w, sp, src1.bit() | src2.bit(), cond); + } else { + ldr(src2, MemOperand(sp, 4, PostIndex), cond); + ldr(src1, MemOperand(sp, 4, PostIndex), cond); + } + } + // Push and pop the registers that can hold pointers, as defined by the // RegList constant kSafepointSavedRegisters. void PushSafepointRegisters(); @@ -497,6 +517,14 @@ class MacroAssembler: public Assembler { // Copies a fixed number of fields of heap objects from src to dst. void CopyFields(Register dst, Register src, RegList temps, int field_count); + // Copies a number of bytes from src to dst. All registers are clobbered. On + // exit src and dst will point to the place just after where the last byte was + // read or written and length will be zero. + void CopyBytes(Register src, + Register dst, + Register length, + Register scratch); + // --------------------------------------------------------------------------- // Support functions. @@ -613,6 +641,19 @@ class MacroAssembler: public Assembler { DwVfpRegister double_scratch, Label *not_int32); +// Truncates a double using a specific rounding mode. +// Clears the z flag (ne condition) if an overflow occurs. +// If exact_conversion is true, the z flag is also cleared if the conversion +// was inexact, ie. if the double value could not be converted exactly +// to a 32bit integer. + void EmitVFPTruncate(VFPRoundingMode rounding_mode, + SwVfpRegister result, + DwVfpRegister double_input, + Register scratch1, + Register scratch2, + CheckForInexactConversion check + = kDontCheckForInexactConversion); + // Count leading zeros in a 32 bit word. On ARM5 and later it uses the clz // instruction. On pre-ARM5 hardware this routine gives the wrong answer // for 0 (31 instead of 32). Source and scratch can be the same in which case @@ -690,7 +731,7 @@ class MacroAssembler: public Assembler { // from handle and propagates exceptions. Restores context. // stack_space - space to be unwound on exit (includes the call js // arguments space and the additional space allocated for the fast call). - MaybeObject* TryCallApiFunctionAndReturn(ApiFunction* function, + MaybeObject* TryCallApiFunctionAndReturn(ExternalReference function, int stack_space); // Jump to a runtime routine. @@ -777,11 +818,11 @@ class MacroAssembler: public Assembler { mov(reg, scratch); } - void SmiUntag(Register reg) { - mov(reg, Operand(reg, ASR, kSmiTagSize)); + void SmiUntag(Register reg, SBit s = LeaveCC) { + mov(reg, Operand(reg, ASR, kSmiTagSize), s); } - void SmiUntag(Register dst, Register src) { - mov(dst, Operand(src, ASR, kSmiTagSize)); + void SmiUntag(Register dst, Register src, SBit s = LeaveCC) { + mov(dst, Operand(src, ASR, kSmiTagSize), s); } // Jump the register contains a smi. diff --git a/deps/v8/src/arm/simulator-arm.cc b/deps/v8/src/arm/simulator-arm.cc index 8104747f14..f475a18b09 100644 --- a/deps/v8/src/arm/simulator-arm.cc +++ b/deps/v8/src/arm/simulator-arm.cc @@ -1005,7 +1005,9 @@ int Simulator::ReadW(int32_t addr, Instruction* instr) { intptr_t* ptr = reinterpret_cast(addr); return *ptr; } - PrintF("Unaligned read at 0x%08x, pc=%p\n", addr, instr); + PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", + addr, + reinterpret_cast(instr)); UNIMPLEMENTED(); return 0; #endif @@ -1023,7 +1025,9 @@ void Simulator::WriteW(int32_t addr, int value, Instruction* instr) { *ptr = value; return; } - PrintF("Unaligned write at 0x%08x, pc=%p\n", addr, instr); + PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", + addr, + reinterpret_cast(instr)); UNIMPLEMENTED(); #endif } @@ -1038,7 +1042,9 @@ uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) { uint16_t* ptr = reinterpret_cast(addr); return *ptr; } - PrintF("Unaligned unsigned halfword read at 0x%08x, pc=%p\n", addr, instr); + PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", + addr, + reinterpret_cast(instr)); UNIMPLEMENTED(); return 0; #endif @@ -1072,7 +1078,9 @@ void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) { *ptr = value; return; } - PrintF("Unaligned unsigned halfword write at 0x%08x, pc=%p\n", addr, instr); + PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", + addr, + reinterpret_cast(instr)); UNIMPLEMENTED(); #endif } @@ -1089,7 +1097,9 @@ void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) { *ptr = value; return; } - PrintF("Unaligned halfword write at 0x%08x, pc=%p\n", addr, instr); + PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", + addr, + reinterpret_cast(instr)); UNIMPLEMENTED(); #endif } @@ -1531,7 +1541,11 @@ typedef double (*SimulatorRuntimeFPCall)(int32_t arg0, // This signature supports direct call in to API function native callback // (refer to InvocationCallback in v8.h). -typedef v8::Handle (*SimulatorRuntimeApiCall)(int32_t arg0); +typedef v8::Handle (*SimulatorRuntimeDirectApiCall)(int32_t arg0); + +// This signature supports direct call to accessor getter callback. +typedef v8::Handle (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, + int32_t arg1); // Software interrupt instructions are used by the simulator to call into the // C-based V8 runtime. @@ -1572,14 +1586,12 @@ void Simulator::SoftwareInterrupt(Instruction* instr) { CHECK(stack_aligned); double result = target(arg0, arg1, arg2, arg3); SetFpResult(result); - } else if (redirection->type() == ExternalReference::DIRECT_CALL) { - SimulatorRuntimeApiCall target = - reinterpret_cast(external); + } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { + SimulatorRuntimeDirectApiCall target = + reinterpret_cast(external); if (::v8::internal::FLAG_trace_sim || !stack_aligned) { - PrintF( - "Call to host function at %p args %08x", - FUNCTION_ADDR(target), - arg0); + PrintF("Call to host function at %p args %08x", + FUNCTION_ADDR(target), arg0); if (!stack_aligned) { PrintF(" with unaligned stack %08x\n", get_register(sp)); } @@ -1591,6 +1603,23 @@ void Simulator::SoftwareInterrupt(Instruction* instr) { PrintF("Returned %p\n", reinterpret_cast(*result)); } set_register(r0, (int32_t) *result); + } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { + SimulatorRuntimeDirectGetterCall target = + reinterpret_cast(external); + if (::v8::internal::FLAG_trace_sim || !stack_aligned) { + PrintF("Call to host function at %p args %08x %08x", + FUNCTION_ADDR(target), arg0, arg1); + if (!stack_aligned) { + PrintF(" with unaligned stack %08x\n", get_register(sp)); + } + PrintF("\n"); + } + CHECK(stack_aligned); + v8::Handle result = target(arg0, arg1); + if (::v8::internal::FLAG_trace_sim) { + PrintF("Returned %p\n", reinterpret_cast(*result)); + } + set_register(r0, (int32_t) *result); } else { // builtin call. ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); @@ -2535,6 +2564,7 @@ void Simulator::DecodeTypeVFP(Instruction* instr) { double dn_value = get_double_from_d_register(vn); double dm_value = get_double_from_d_register(vm); double dd_value = dn_value / dm_value; + div_zero_vfp_flag_ = (dm_value == 0); set_d_register_from_double(vd, dd_value); } else { UNIMPLEMENTED(); // Not used by V8. @@ -2769,14 +2799,17 @@ void Simulator::DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr) { inv_op_vfp_flag_ = get_inv_op_vfp_flag(mode, val, unsigned_integer); + double abs_diff = + unsigned_integer ? fabs(val - static_cast(temp)) + : fabs(val - temp); + + inexact_vfp_flag_ = (abs_diff != 0); + if (inv_op_vfp_flag_) { temp = VFPConversionSaturate(val, unsigned_integer); } else { switch (mode) { case RN: { - double abs_diff = - unsigned_integer ? fabs(val - static_cast(temp)) - : fabs(val - temp); int val_sign = (val > 0) ? 1 : -1; if (abs_diff > 0.5) { temp += val_sign; diff --git a/deps/v8/src/arm/stub-cache-arm.cc b/deps/v8/src/arm/stub-cache-arm.cc index e623ea1914..60a11f3ced 100644 --- a/deps/v8/src/arm/stub-cache-arm.cc +++ b/deps/v8/src/arm/stub-cache-arm.cc @@ -655,12 +655,10 @@ static MaybeObject* GenerateFastApiDirectCall(MacroAssembler* masm, // already generated). Do not allow the assembler to perform a // garbage collection but instead return the allocation failure // object. - MaybeObject* result = masm->TryCallApiFunctionAndReturn( - &fun, argc + kFastApiCallArguments + 1); - if (result->IsFailure()) { - return result; - } - return Heap::undefined_value(); + const int kStackUnwindSpace = argc + kFastApiCallArguments + 1; + ExternalReference ref = + ExternalReference(&fun, ExternalReference::DIRECT_API_CALL); + return masm->TryCallApiFunctionAndReturn(ref, kStackUnwindSpace); } class CallInterceptorCompiler BASE_EMBEDDED { @@ -1245,18 +1243,38 @@ MaybeObject* StubCompiler::GenerateLoadCallback(JSObject* object, CheckPrototypes(object, receiver, holder, scratch1, scratch2, scratch3, name, miss); - // Push the arguments on the JS stack of the caller. - __ push(receiver); // Receiver. - __ mov(scratch3, Operand(Handle(callback))); // callback data - __ ldr(ip, FieldMemOperand(scratch3, AccessorInfo::kDataOffset)); - __ Push(reg, ip, scratch3, name_reg); + // Build AccessorInfo::args_ list on the stack and push property name below + // the exit frame to make GC aware of them and store pointers to them. + __ push(receiver); + __ mov(scratch2, sp); // scratch2 = AccessorInfo::args_ + Handle callback_handle(callback); + if (Heap::InNewSpace(callback_handle->data())) { + __ Move(scratch3, callback_handle); + __ ldr(scratch3, FieldMemOperand(scratch3, AccessorInfo::kDataOffset)); + } else { + __ Move(scratch3, Handle(callback_handle->data())); + } + __ Push(reg, scratch3, name_reg); + __ mov(r0, sp); // r0 = Handle - // Do tail-call to the runtime system. - ExternalReference load_callback_property = - ExternalReference(IC_Utility(IC::kLoadCallbackProperty)); - __ TailCallExternalReference(load_callback_property, 5, 1); + Address getter_address = v8::ToCData
(callback->getter()); + ApiFunction fun(getter_address); - return Heap::undefined_value(); // Success. + const int kApiStackSpace = 1; + __ EnterExitFrame(false, kApiStackSpace); + // Create AccessorInfo instance on the stack above the exit frame with + // scratch2 (internal::Object **args_) as the data. + __ str(scratch2, MemOperand(sp, 1 * kPointerSize)); + __ add(r1, sp, Operand(1 * kPointerSize)); // r1 = AccessorInfo& + + // Emitting a stub call may try to allocate (if the code is not + // already generated). Do not allow the assembler to perform a + // garbage collection but instead return the allocation failure + // object. + const int kStackUnwindSpace = 4; + ExternalReference ref = + ExternalReference(&fun, ExternalReference::DIRECT_GETTER_CALL); + return masm()->TryCallApiFunctionAndReturn(ref, kStackUnwindSpace); } @@ -2653,10 +2671,13 @@ MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, __ Push(r1, r2, r0); // Receiver, name, value. + __ mov(r0, Operand(Smi::FromInt(strict_mode_))); + __ push(r0); // strict mode + // Do tail-call to the runtime system. ExternalReference store_ic_property = ExternalReference(IC_Utility(IC::kStoreInterceptorProperty)); - __ TailCallExternalReference(store_ic_property, 3, 1); + __ TailCallExternalReference(store_ic_property, 4, 1); // Handle store cache miss. __ bind(&miss); @@ -4038,7 +4059,12 @@ MaybeObject* ExternalArrayStubCompiler::CompileKeyedStoreStub( // Push receiver, key and value for runtime call. __ Push(r2, r1, r0); - __ TailCallRuntime(Runtime::kSetProperty, 3, 1); + __ mov(r1, Operand(Smi::FromInt(NONE))); // PropertyAttributes + __ mov(r0, Operand(Smi::FromInt( + Code::ExtractExtraICStateFromFlags(flags) & kStrictMode))); + __ Push(r1, r0); + + __ TailCallRuntime(Runtime::kSetProperty, 5, 1); return GetCode(flags); } diff --git a/deps/v8/src/arm/virtual-frame-arm.cc b/deps/v8/src/arm/virtual-frame-arm.cc index b4b518cff6..544e405dbb 100644 --- a/deps/v8/src/arm/virtual-frame-arm.cc +++ b/deps/v8/src/arm/virtual-frame-arm.cc @@ -332,9 +332,9 @@ void VirtualFrame::CallLoadIC(Handle name, RelocInfo::Mode mode) { void VirtualFrame::CallStoreIC(Handle name, bool is_contextual, StrictModeFlag strict_mode) { - Handle ic(Builtins::builtin(strict_mode == kStrictMode - ? Builtins::StoreIC_Initialize_Strict - : Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + (strict_mode == kStrictMode) ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); PopToR0(); RelocInfo::Mode mode; if (is_contextual) { @@ -359,8 +359,10 @@ void VirtualFrame::CallKeyedLoadIC() { } -void VirtualFrame::CallKeyedStoreIC() { - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); +void VirtualFrame::CallKeyedStoreIC(StrictModeFlag strict_mode) { + Handle ic(Builtins::builtin( + (strict_mode == kStrictMode) ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); PopToR1R0(); SpillAll(); EmitPop(r2); diff --git a/deps/v8/src/arm/virtual-frame-arm.h b/deps/v8/src/arm/virtual-frame-arm.h index b6e794a5c0..76470bdc53 100644 --- a/deps/v8/src/arm/virtual-frame-arm.h +++ b/deps/v8/src/arm/virtual-frame-arm.h @@ -303,7 +303,7 @@ class VirtualFrame : public ZoneObject { // Call keyed store IC. Value, key and receiver are on the stack. All three // are consumed. Result is returned in r0. - void CallKeyedStoreIC(); + void CallKeyedStoreIC(StrictModeFlag strict_mode); // Call into an IC stub given the number of arguments it removes // from the stack. Register arguments to the IC stub are implicit, diff --git a/deps/v8/src/array.js b/deps/v8/src/array.js index ef82674d78..0753f1e2ab 100644 --- a/deps/v8/src/array.js +++ b/deps/v8/src/array.js @@ -418,7 +418,6 @@ function ArrayPush() { function ArrayConcat(arg1) { // length == 1 - // TODO: can we just use arguments? var arg_count = %_ArgumentsLength(); var arrays = new $Array(1 + arg_count); arrays[0] = this; @@ -1018,13 +1017,13 @@ function ArrayIndexOf(element, index) { } var min = index; var max = length; - if (UseSparseVariant(this, length, true)) { + if (UseSparseVariant(this, length, IS_ARRAY(this))) { var intervals = %GetArrayKeys(this, length); if (intervals.length == 2 && intervals[0] < 0) { // A single interval. var intervalMin = -(intervals[0] + 1); var intervalMax = intervalMin + intervals[1]; - min = MAX(min, intervalMin); + if (min < intervalMin) min = intervalMin; max = intervalMax; // Capped by length already. // Fall through to loop below. } else { @@ -1074,13 +1073,13 @@ function ArrayLastIndexOf(element, index) { } var min = 0; var max = index; - if (UseSparseVariant(this, length, true)) { + if (UseSparseVariant(this, length, IS_ARRAY(this))) { var intervals = %GetArrayKeys(this, index + 1); if (intervals.length == 2 && intervals[0] < 0) { // A single interval. var intervalMin = -(intervals[0] + 1); var intervalMax = intervalMin + intervals[1]; - min = MAX(min, intervalMin); + if (min < intervalMin) min = intervalMin; max = intervalMax; // Capped by index already. // Fall through to loop below. } else { diff --git a/deps/v8/src/assembler.cc b/deps/v8/src/assembler.cc index a323ecaa44..030d15c514 100644 --- a/deps/v8/src/assembler.cc +++ b/deps/v8/src/assembler.cc @@ -252,7 +252,7 @@ void RelocInfoWriter::Write(const RelocInfo* rinfo) { WriteExtraTaggedPC(pc_delta, kPCJumpTag); WriteExtraTaggedData(rinfo->data() - last_data_, kCommentTag); last_data_ = rinfo->data(); - ASSERT(begin_pos - pos_ == RelocInfo::kRelocCommentSize); + ASSERT(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize); } else { // For all other modes we simply use the mode as the extra tag. // None of these modes need a data component. diff --git a/deps/v8/src/assembler.h b/deps/v8/src/assembler.h index 095859840e..9e6aa087aa 100644 --- a/deps/v8/src/assembler.h +++ b/deps/v8/src/assembler.h @@ -184,10 +184,10 @@ class RelocInfo BASE_EMBEDDED { // we do not normally record relocation info. static const char* kFillerCommentString; - // The size of a comment is equal to tree bytes for the extra tagged pc + - // the tag for the data, and kPointerSize for the actual pointer to the + // The minimum size of a comment is equal to three bytes for the extra tagged + // pc + the tag for the data, and kPointerSize for the actual pointer to the // comment. - static const int kRelocCommentSize = 3 + kPointerSize; + static const int kMinRelocCommentSize = 3 + kPointerSize; // The maximum size for a call instruction including pc-jump. static const int kMaxCallSize = 6; @@ -481,21 +481,22 @@ class Debug_Address; class ExternalReference BASE_EMBEDDED { public: // Used in the simulator to support different native api calls. - // - // BUILTIN_CALL - builtin call. - // MaybeObject* f(v8::internal::Arguments). - // - // FP_RETURN_CALL - builtin call that returns floating point. - // double f(double, double). - // - // DIRECT_CALL - direct call to API function native callback - // from generated code. - // Handle f(v8::Arguments&) - // enum Type { + // Builtin call. + // MaybeObject* f(v8::internal::Arguments). BUILTIN_CALL, // default + + // Builtin call that returns floating point. + // double f(double, double). FP_RETURN_CALL, - DIRECT_CALL + + // Direct call to API function callback. + // Handle f(v8::Arguments&) + DIRECT_API_CALL, + + // Direct call to accessor getter callback. + // Handle f(Local property, AccessorInfo& info) + DIRECT_GETTER_CALL }; typedef void* ExternalReferenceRedirector(void* original, Type type); diff --git a/deps/v8/src/builtins.cc b/deps/v8/src/builtins.cc index 8fdc1b1382..01e8deb4e1 100644 --- a/deps/v8/src/builtins.cc +++ b/deps/v8/src/builtins.cc @@ -1328,12 +1328,12 @@ static void Generate_StoreIC_Normal_Strict(MacroAssembler* masm) { static void Generate_StoreIC_Megamorphic(MacroAssembler* masm) { - StoreIC::GenerateMegamorphic(masm, StoreIC::kStoreICNonStrict); + StoreIC::GenerateMegamorphic(masm, kNonStrictMode); } static void Generate_StoreIC_Megamorphic_Strict(MacroAssembler* masm) { - StoreIC::GenerateMegamorphic(masm, StoreIC::kStoreICStrict); + StoreIC::GenerateMegamorphic(masm, kStrictMode); } @@ -1348,17 +1348,22 @@ static void Generate_StoreIC_ArrayLength_Strict(MacroAssembler* masm) { static void Generate_StoreIC_GlobalProxy(MacroAssembler* masm) { - StoreIC::GenerateGlobalProxy(masm); + StoreIC::GenerateGlobalProxy(masm, kNonStrictMode); } static void Generate_StoreIC_GlobalProxy_Strict(MacroAssembler* masm) { - StoreIC::GenerateGlobalProxy(masm); + StoreIC::GenerateGlobalProxy(masm, kStrictMode); } static void Generate_KeyedStoreIC_Generic(MacroAssembler* masm) { - KeyedStoreIC::GenerateGeneric(masm); + KeyedStoreIC::GenerateGeneric(masm, kNonStrictMode); +} + + +static void Generate_KeyedStoreIC_Generic_Strict(MacroAssembler* masm) { + KeyedStoreIC::GenerateGeneric(masm, kStrictMode); } @@ -1372,6 +1377,11 @@ static void Generate_KeyedStoreIC_Initialize(MacroAssembler* masm) { } +static void Generate_KeyedStoreIC_Initialize_Strict(MacroAssembler* masm) { + KeyedStoreIC::GenerateInitialize(masm); +} + + #ifdef ENABLE_DEBUGGER_SUPPORT static void Generate_LoadIC_DebugBreak(MacroAssembler* masm) { Debug::GenerateLoadICDebugBreak(masm); diff --git a/deps/v8/src/builtins.h b/deps/v8/src/builtins.h index 2733410ea9..5ea466513f 100644 --- a/deps/v8/src/builtins.h +++ b/deps/v8/src/builtins.h @@ -62,111 +62,116 @@ enum BuiltinExtraArguments { // Define list of builtins implemented in assembly. -#define BUILTIN_LIST_A(V) \ - V(ArgumentsAdaptorTrampoline, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(JSConstructCall, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(JSConstructStubCountdown, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(JSConstructStubGeneric, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(JSConstructStubApi, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(JSEntryTrampoline, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(LazyCompile, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(LazyRecompile, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(NotifyDeoptimized, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(NotifyLazyDeoptimized, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(NotifyOSR, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - \ - V(LoadIC_Miss, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(KeyedLoadIC_Miss, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(StoreIC_Miss, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(KeyedStoreIC_Miss, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - \ - V(LoadIC_Initialize, LOAD_IC, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(LoadIC_PreMonomorphic, LOAD_IC, PREMONOMORPHIC, \ - Code::kNoExtraICState) \ - V(LoadIC_Normal, LOAD_IC, MONOMORPHIC, \ - Code::kNoExtraICState) \ - V(LoadIC_ArrayLength, LOAD_IC, MONOMORPHIC, \ - Code::kNoExtraICState) \ - V(LoadIC_StringLength, LOAD_IC, MONOMORPHIC, \ - Code::kNoExtraICState) \ - V(LoadIC_StringWrapperLength, LOAD_IC, MONOMORPHIC, \ - Code::kNoExtraICState) \ - V(LoadIC_FunctionPrototype, LOAD_IC, MONOMORPHIC, \ - Code::kNoExtraICState) \ - V(LoadIC_Megamorphic, LOAD_IC, MEGAMORPHIC, \ - Code::kNoExtraICState) \ - \ - V(KeyedLoadIC_Initialize, KEYED_LOAD_IC, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(KeyedLoadIC_PreMonomorphic, KEYED_LOAD_IC, PREMONOMORPHIC, \ - Code::kNoExtraICState) \ - V(KeyedLoadIC_Generic, KEYED_LOAD_IC, MEGAMORPHIC, \ - Code::kNoExtraICState) \ - V(KeyedLoadIC_String, KEYED_LOAD_IC, MEGAMORPHIC, \ - Code::kNoExtraICState) \ - V(KeyedLoadIC_IndexedInterceptor, KEYED_LOAD_IC, MEGAMORPHIC, \ - Code::kNoExtraICState) \ - \ - V(StoreIC_Initialize, STORE_IC, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(StoreIC_ArrayLength, STORE_IC, MONOMORPHIC, \ - Code::kNoExtraICState) \ - V(StoreIC_Normal, STORE_IC, MONOMORPHIC, \ - Code::kNoExtraICState) \ - V(StoreIC_Megamorphic, STORE_IC, MEGAMORPHIC, \ - Code::kNoExtraICState) \ - V(StoreIC_GlobalProxy, STORE_IC, MEGAMORPHIC, \ - Code::kNoExtraICState) \ - V(StoreIC_Initialize_Strict, STORE_IC, UNINITIALIZED, \ - StoreIC::kStoreICStrict) \ - V(StoreIC_ArrayLength_Strict, STORE_IC, MONOMORPHIC, \ - StoreIC::kStoreICStrict) \ - V(StoreIC_Normal_Strict, STORE_IC, MONOMORPHIC, \ - StoreIC::kStoreICStrict) \ - V(StoreIC_Megamorphic_Strict, STORE_IC, MEGAMORPHIC, \ - StoreIC::kStoreICStrict) \ - V(StoreIC_GlobalProxy_Strict, STORE_IC, MEGAMORPHIC, \ - StoreIC::kStoreICStrict) \ - \ - V(KeyedStoreIC_Initialize, KEYED_STORE_IC, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(KeyedStoreIC_Generic, KEYED_STORE_IC, MEGAMORPHIC, \ - Code::kNoExtraICState) \ - \ - /* Uses KeyedLoadIC_Initialize; must be after in list. */ \ - V(FunctionCall, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(FunctionApply, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - \ - V(ArrayCode, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - V(ArrayConstructCode, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - \ - V(StringConstructCode, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) \ - \ - V(OnStackReplacement, BUILTIN, UNINITIALIZED, \ - Code::kNoExtraICState) +#define BUILTIN_LIST_A(V) \ + V(ArgumentsAdaptorTrampoline, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(JSConstructCall, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(JSConstructStubCountdown, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(JSConstructStubGeneric, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(JSConstructStubApi, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(JSEntryTrampoline, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(LazyCompile, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(LazyRecompile, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(NotifyDeoptimized, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(NotifyLazyDeoptimized, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(NotifyOSR, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + \ + V(LoadIC_Miss, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(KeyedLoadIC_Miss, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(StoreIC_Miss, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(KeyedStoreIC_Miss, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + \ + V(LoadIC_Initialize, LOAD_IC, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(LoadIC_PreMonomorphic, LOAD_IC, PREMONOMORPHIC, \ + Code::kNoExtraICState) \ + V(LoadIC_Normal, LOAD_IC, MONOMORPHIC, \ + Code::kNoExtraICState) \ + V(LoadIC_ArrayLength, LOAD_IC, MONOMORPHIC, \ + Code::kNoExtraICState) \ + V(LoadIC_StringLength, LOAD_IC, MONOMORPHIC, \ + Code::kNoExtraICState) \ + V(LoadIC_StringWrapperLength, LOAD_IC, MONOMORPHIC, \ + Code::kNoExtraICState) \ + V(LoadIC_FunctionPrototype, LOAD_IC, MONOMORPHIC, \ + Code::kNoExtraICState) \ + V(LoadIC_Megamorphic, LOAD_IC, MEGAMORPHIC, \ + Code::kNoExtraICState) \ + \ + V(KeyedLoadIC_Initialize, KEYED_LOAD_IC, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(KeyedLoadIC_PreMonomorphic, KEYED_LOAD_IC, PREMONOMORPHIC, \ + Code::kNoExtraICState) \ + V(KeyedLoadIC_Generic, KEYED_LOAD_IC, MEGAMORPHIC, \ + Code::kNoExtraICState) \ + V(KeyedLoadIC_String, KEYED_LOAD_IC, MEGAMORPHIC, \ + Code::kNoExtraICState) \ + V(KeyedLoadIC_IndexedInterceptor, KEYED_LOAD_IC, MEGAMORPHIC, \ + Code::kNoExtraICState) \ + \ + V(StoreIC_Initialize, STORE_IC, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(StoreIC_ArrayLength, STORE_IC, MONOMORPHIC, \ + Code::kNoExtraICState) \ + V(StoreIC_Normal, STORE_IC, MONOMORPHIC, \ + Code::kNoExtraICState) \ + V(StoreIC_Megamorphic, STORE_IC, MEGAMORPHIC, \ + Code::kNoExtraICState) \ + V(StoreIC_GlobalProxy, STORE_IC, MEGAMORPHIC, \ + Code::kNoExtraICState) \ + V(StoreIC_Initialize_Strict, STORE_IC, UNINITIALIZED, \ + kStrictMode) \ + V(StoreIC_ArrayLength_Strict, STORE_IC, MONOMORPHIC, \ + kStrictMode) \ + V(StoreIC_Normal_Strict, STORE_IC, MONOMORPHIC, \ + kStrictMode) \ + V(StoreIC_Megamorphic_Strict, STORE_IC, MEGAMORPHIC, \ + kStrictMode) \ + V(StoreIC_GlobalProxy_Strict, STORE_IC, MEGAMORPHIC, \ + kStrictMode) \ + \ + V(KeyedStoreIC_Initialize, KEYED_STORE_IC, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(KeyedStoreIC_Generic, KEYED_STORE_IC, MEGAMORPHIC, \ + Code::kNoExtraICState) \ + \ + V(KeyedStoreIC_Initialize_Strict, KEYED_STORE_IC, UNINITIALIZED, \ + kStrictMode) \ + V(KeyedStoreIC_Generic_Strict, KEYED_STORE_IC, MEGAMORPHIC, \ + kStrictMode) \ + \ + /* Uses KeyedLoadIC_Initialize; must be after in list. */ \ + V(FunctionCall, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(FunctionApply, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + \ + V(ArrayCode, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + V(ArrayConstructCode, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + \ + V(StringConstructCode, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) \ + \ + V(OnStackReplacement, BUILTIN, UNINITIALIZED, \ + Code::kNoExtraICState) #ifdef ENABLE_DEBUGGER_SUPPORT diff --git a/deps/v8/src/compiler.cc b/deps/v8/src/compiler.cc index f392cceb3c..367de64881 100755 --- a/deps/v8/src/compiler.cc +++ b/deps/v8/src/compiler.cc @@ -221,11 +221,12 @@ static bool MakeCrankshaftCode(CompilationInfo* info) { // or perform on-stack replacement for function with too many // stack-allocated local variables. // - // The encoding is as a signed value, with parameters using the negative - // indices and locals the non-negative ones. + // The encoding is as a signed value, with parameters and receiver using + // the negative indices and locals the non-negative ones. const int limit = LUnallocated::kMaxFixedIndices / 2; Scope* scope = info->scope(); - if (scope->num_parameters() > limit || scope->num_stack_slots() > limit) { + if ((scope->num_parameters() + 1) > limit || + scope->num_stack_slots() > limit) { AbortAndDisable(info); // True indicates the compilation pipeline is still going, not // necessarily that we optimized the code. diff --git a/deps/v8/src/d8.cc b/deps/v8/src/d8.cc index 4dcc794bb3..349ec90410 100644 --- a/deps/v8/src/d8.cc +++ b/deps/v8/src/d8.cc @@ -405,7 +405,7 @@ void Shell::AddHistogramSample(void* histogram, int sample) { void Shell::Initialize() { Shell::counter_map_ = new CounterMap(); // Set up counters - if (i::FLAG_map_counters != NULL) + if (i::StrLength(i::FLAG_map_counters) != 0) MapCounters(i::FLAG_map_counters); if (i::FLAG_dump_counters) { V8::SetCounterFunction(LookupCounter); @@ -425,6 +425,12 @@ void Shell::Initialize() { global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); global_template->Set(String::New("version"), FunctionTemplate::New(Version)); +#ifdef LIVE_OBJECT_LIST + global_template->Set(String::New("lol_is_enabled"), Boolean::New(true)); +#else + global_template->Set(String::New("lol_is_enabled"), Boolean::New(false)); +#endif + Handle os_templ = ObjectTemplate::New(); AddOSMethods(os_templ); global_template->Set(String::New("os"), os_templ); diff --git a/deps/v8/src/d8.js b/deps/v8/src/d8.js index b0edb706ad..979807888e 100644 --- a/deps/v8/src/d8.js +++ b/deps/v8/src/d8.js @@ -117,6 +117,10 @@ Debug.State = { var trace_compile = false; // Tracing all compile events? var trace_debug_json = false; // Tracing all debug json packets? var last_cmd_line = ''; +//var lol_is_enabled; // Set to true in d8.cc if LIVE_OBJECT_LIST is defined. +var lol_next_dump_index = 0; +const kDefaultLolLinesToPrintAtATime = 10; +const kMaxLolLinesToPrintAtATime = 1000; var repeat_cmd_line = ''; var is_running = true; @@ -495,6 +499,13 @@ function DebugRequest(cmd_line) { this.request_ = void 0; break; + case 'liveobjectlist': + case 'lol': + if (lol_is_enabled) { + this.request_ = this.lolToJSONRequest_(args, is_repeating); + break; + } + default: throw new Error('Unknown command "' + cmd + '"'); } @@ -539,10 +550,54 @@ DebugRequest.prototype.createRequest = function(command) { }; +// Note: we use detected command repetition as a signal for continuation here. +DebugRequest.prototype.createLOLRequest = function(command, + start_index, + lines_to_dump, + is_continuation) { + if (is_continuation) { + start_index = lol_next_dump_index; + } + + if (lines_to_dump) { + lines_to_dump = parseInt(lines_to_dump); + } else { + lines_to_dump = kDefaultLolLinesToPrintAtATime; + } + if (lines_to_dump > kMaxLolLinesToPrintAtATime) { + lines_to_dump = kMaxLolLinesToPrintAtATime; + } + + // Save the next start_index to dump from: + lol_next_dump_index = start_index + lines_to_dump; + + var request = this.createRequest(command); + request.arguments = {}; + request.arguments.start = start_index; + request.arguments.count = lines_to_dump; + + return request; +}; + + // Create a JSON request for the evaluation command. DebugRequest.prototype.makeEvaluateJSONRequest_ = function(expression) { // Global varaible used to store whether a handle was requested. lookup_handle = null; + + if (lol_is_enabled) { + // Check if the expression is a obj id in the form @. + var obj_id_match = expression.match(/^@([0-9]+)$/); + if (obj_id_match) { + var obj_id = parseInt(obj_id_match[1]); + // Build a dump request. + var request = this.createRequest('getobj'); + request.arguments = {}; + request.arguments.obj_id = obj_id; + return request.toJSONProtocol(); + } + } + // Check if the expression is a handle id in the form ##. var handle_match = expression.match(/^#([0-9]*)#$/); if (handle_match) { @@ -1103,6 +1158,10 @@ DebugRequest.prototype.infoCommandToJSONRequest_ = function(args) { // Build a evaluate request from the text command. request = this.createRequest('frame'); last_cmd = 'info args'; + } else if (lol_is_enabled && + args && (args == 'liveobjectlist' || args == 'lol')) { + // Build a evaluate request from the text command. + return this.liveObjectListToJSONRequest_(null); } else { throw new Error('Invalid info arguments.'); } @@ -1153,6 +1212,262 @@ DebugRequest.prototype.gcToJSONRequest_ = function(args) { }; +// Args: [v[erbose]] [] [i[ndex] ] [t[ype] ] [sp[ace] ] +DebugRequest.prototype.lolMakeListRequest = + function(cmd, args, first_arg_index, is_repeating) { + + var request; + var start_index = 0; + var dump_limit = void 0; + var type_filter = void 0; + var space_filter = void 0; + var prop_filter = void 0; + var is_verbose = false; + var i; + + for (i = first_arg_index; i < args.length; i++) { + var arg = args[i]; + // Check for [v[erbose]]: + if (arg === 'verbose' || arg === 'v') { + // Nothing to do. This is already implied by args.length > 3. + is_verbose = true; + + // Check for []: + } else if (arg.match(/^[0-9]+$/)) { + dump_limit = arg; + is_verbose = true; + + // Check for i[ndex] : + } else if (arg === 'index' || arg === 'i') { + i++; + if (args.length < i) { + throw new Error('Missing index after ' + arg + '.'); + } + start_index = parseInt(args[i]); + // The user input start index starts at 1: + if (start_index <= 0) { + throw new Error('Invalid index ' + args[i] + '.'); + } + start_index -= 1; + is_verbose = true; + + // Check for t[ype] : + } else if (arg === 'type' || arg === 't') { + i++; + if (args.length < i) { + throw new Error('Missing type after ' + arg + '.'); + } + type_filter = args[i]; + + // Check for space : + } else if (arg === 'space' || arg === 'sp') { + i++; + if (args.length < i) { + throw new Error('Missing space name after ' + arg + '.'); + } + space_filter = args[i]; + + // Check for property : + } else if (arg === 'property' || arg === 'prop') { + i++; + if (args.length < i) { + throw new Error('Missing property name after ' + arg + '.'); + } + prop_filter = args[i]; + + } else { + throw new Error('Unknown args at ' + arg + '.'); + } + } + + // Build the verbose request: + if (is_verbose) { + request = this.createLOLRequest('lol-'+cmd, + start_index, + dump_limit, + is_repeating); + request.arguments.verbose = true; + } else { + request = this.createRequest('lol-'+cmd); + request.arguments = {}; + } + + request.arguments.filter = {}; + if (type_filter) { + request.arguments.filter.type = type_filter; + } + if (space_filter) { + request.arguments.filter.space = space_filter; + } + if (prop_filter) { + request.arguments.filter.prop = prop_filter; + } + + return request; +} + + +function extractObjId(args) { + var id = args; + id = id.match(/^@([0-9]+)$/); + if (id) { + id = id[1]; + } else { + throw new Error('Invalid obj id ' + args + '.'); + } + return parseInt(id); +} + + +DebugRequest.prototype.lolToJSONRequest_ = function(args, is_repeating) { + var request; + // Use default command if one is not specified: + if (!args) { + args = 'info'; + } + + var orig_args = args; + var first_arg_index; + + var arg, i; + var args = args.split(/\s+/g); + var cmd = args[0]; + var id; + + // Command: [v[erbose]] ... + if (cmd.match(/^[0-9]+$/)) { + // Convert to the padded list command: + // Command: l[ist] [v[erbose]] ... + + // Insert the implicit 'list' in front and process as normal: + cmd = 'list'; + args.unshift(cmd); + } + + switch(cmd) { + // Command: c[apture] + case 'capture': + case 'c': + request = this.createRequest('lol-capture'); + break; + + // Command: clear|d[elete] |all + case 'clear': + case 'delete': + case 'del': { + if (args.length < 2) { + throw new Error('Missing argument after ' + cmd + '.'); + } else if (args.length > 2) { + throw new Error('Too many arguments after ' + cmd + '.'); + } + id = args[1]; + if (id.match(/^[0-9]+$/)) { + // Delete a specific lol record: + request = this.createRequest('lol-delete'); + request.arguments = {}; + request.arguments.id = parseInt(id); + } else if (id === 'all') { + // Delete all: + request = this.createRequest('lol-reset'); + } else { + throw new Error('Invalid argument after ' + cmd + '.'); + } + break; + } + + // Command: diff [] + case 'diff': + first_arg_index = 3; + + // Command: list [] + case 'list': + + // Command: ret[ainers] [] + case 'retainers': + case 'ret': + case 'retaining-paths': + case 'rp': { + if (cmd === 'ret') cmd = 'retainers'; + else if (cmd === 'rp') cmd = 'retaining-paths'; + + if (!first_arg_index) first_arg_index = 2; + + if (args.length < first_arg_index) { + throw new Error('Too few arguments after ' + cmd + '.'); + } + + var request_cmd = (cmd === 'list') ? 'diff':cmd; + request = this.lolMakeListRequest(request_cmd, + args, + first_arg_index, + is_repeating); + + if (cmd === 'diff') { + request.arguments.id1 = parseInt(args[1]); + request.arguments.id2 = parseInt(args[2]); + } else if (cmd == 'list') { + request.arguments.id1 = 0; + request.arguments.id2 = parseInt(args[1]); + } else { + request.arguments.id = extractObjId(args[1]); + } + break; + } + + // Command: getid + case 'getid': { + request = this.createRequest('lol-getid'); + request.arguments = {}; + request.arguments.address = args[1]; + break; + } + + // Command: inf[o] [] + case 'info': + case 'inf': { + if (args.length > 2) { + throw new Error('Too many arguments after ' + cmd + '.'); + } + // Built the info request: + request = this.createLOLRequest('lol-info', 0, args[1], is_repeating); + break; + } + + // Command: path + case 'path': { + request = this.createRequest('lol-path'); + request.arguments = {}; + if (args.length > 2) { + request.arguments.id1 = extractObjId(args[1]); + request.arguments.id2 = extractObjId(args[2]); + } else { + request.arguments.id1 = 0; + request.arguments.id2 = extractObjId(args[1]); + } + break; + } + + // Command: print + case 'print': { + request = this.createRequest('lol-print'); + request.arguments = {}; + request.arguments.id = extractObjId(args[1]); + break; + } + + // Command: reset + case 'reset': { + request = this.createRequest('lol-reset'); + break; + } + + default: + throw new Error('Invalid arguments.'); + } + return request.toJSONProtocol(); +}; + + // Create a JSON request for the threads command. DebugRequest.prototype.threadsCommandToJSONRequest_ = function(args) { // Build a threads request from the text command. @@ -1239,6 +1554,49 @@ DebugRequest.prototype.helpCommand_ = function(args) { print(''); print('gc - runs the garbage collector'); print(''); + + if (lol_is_enabled) { + print('liveobjectlist|lol - live object list tracking.'); + print(' where can be:'); + print(' c[apture] - captures a LOL list.'); + print(' clear|del[ete] |all - clears LOL of id .'); + print(' If \'all\' is unspecified instead, will clear all.'); + print(' diff []'); + print(' - prints the diff between LOLs id1 and id2.'); + print(' - also see below.'); + print(' getid
- gets the obj id for the specified address if available.'); + print(' The address must be in hex form prefixed with 0x.'); + print(' inf[o] [] - lists summary info of all LOL lists.'); + print(' If N is specified, will print N items at a time.'); + print(' [l[ist]] []'); + print(' - prints the listing of objects in LOL id.'); + print(' - also see below.'); + print(' reset - clears all LOL lists.'); + print(' ret[ainers] []'); + print(' - prints the list of retainers of obj id.'); + print(' - also see below.'); + print(' path - prints the retaining path from obj id1 to id2.'); + print(' If only one id is specified, will print the path from'); + print(' roots to the specified object if available.'); + print(' print - prints the obj for the specified obj id if available.'); + print(''); + print(' includes:'); + print(' [v[erbose]] - do verbose dump.'); + print(' [] - dump N items at a time. Implies verbose dump.'); + print(' If unspecified, N will default to '+ + kDefaultLolLinesToPrintAtATime+'. Max N is '+ + kMaxLolLinesToPrintAtATime+'.'); + print(' [i[ndex] ] - start dump from index i. Implies verbose dump.'); + print(' [t[ype] ] - filter by type.'); + print(' [sp[ace] ] - filter by heap space where is one of'); + print(' { cell, code, lo, map, new, old-data, old-pointer }.'); + print(''); + print(' If the verbose option, or an option that implies a verbose dump'); + print(' is specified, then a verbose dump will requested. Else, a summary dump'); + print(' will be requested.'); + print(''); + } + print('trace compile'); // hidden command: trace debug json - toggles tracing of debug json packets print(''); @@ -1339,6 +1697,237 @@ function refObjectToString_(protocolPackage, handle) { } +function decodeLolCaptureResponse(body) { + var result; + result = 'Captured live object list '+ body.id + + ': count '+ body.count + ' size ' + body.size; + return result; +} + + +function decodeLolDeleteResponse(body) { + var result; + result = 'Deleted live object list '+ body.id; + return result; +} + + +function digitsIn(value) { + var digits = 0; + if (value === 0) value = 1; + while (value >= 1) { + digits++; + value /= 10; + } + return digits; +} + + +function padding(value, max_digits) { + var padding_digits = max_digits - digitsIn(value); + var padding = ''; + while (padding_digits > 0) { + padding += ' '; + padding_digits--; + } + return padding; +} + + +function decodeLolInfoResponse(body) { + var result; + var lists = body.lists; + var length = lists.length; + var first_index = body.first_index + 1; + var has_more = ((first_index + length) <= body.count); + result = 'captured live object lists'; + if (has_more || (first_index != 1)) { + result += ' ['+ length +' of '+ body.count + + ': starting from '+ first_index +']'; + } + result += ':\n'; + var max_digits = digitsIn(body.count); + var last_count = 0; + var last_size = 0; + for (var i = 0; i < length; i++) { + var entry = lists[i]; + var count = entry.count; + var size = entry.size; + var index = first_index + i; + result += ' [' + padding(index, max_digits) + index + '] id '+ entry.id + + ': count '+ count; + if (last_count > 0) { + result += '(+' + (count - last_count) + ')'; + } + result += ' size '+ size; + if (last_size > 0) { + result += '(+' + (size - last_size) + ')'; + } + result += '\n'; + last_count = count; + last_size = size; + } + result += ' total: '+length+' lists\n'; + if (has_more) { + result += ' -- press for more --\n'; + } else { + repeat_cmd_line = ''; + } + if (length === 0) result += ' none\n'; + + return result; +} + + +function decodeLolListResponse(body, title) { + + var result; + var total_count = body.count; + var total_size = body.size; + var length; + var max_digits; + var i; + var entry; + var index; + + var max_count_digits = digitsIn(total_count); + var max_size_digits; + + var summary = body.summary; + if (summary) { + + var roots_count = 0; + var found_root = body.found_root || 0; + var found_weak_root = body.found_weak_root || 0; + + // Print the summary result: + result = 'summary of objects:\n'; + length = summary.length; + if (found_root !== 0) { + roots_count++; + } + if (found_weak_root !== 0) { + roots_count++; + } + max_digits = digitsIn(length + roots_count); + max_size_digits = digitsIn(total_size); + + index = 1; + if (found_root !== 0) { + result += ' [' + padding(index, max_digits) + index + '] ' + + ' count '+ 1 + padding(0, max_count_digits) + + ' '+ padding(0, max_size_digits+1) + + ' : \n'; + index++; + } + if (found_weak_root !== 0) { + result += ' [' + padding(index, max_digits) + index + '] ' + + ' count '+ 1 + padding(0, max_count_digits) + + ' '+ padding(0, max_size_digits+1) + + ' : \n'; + index++; + } + + for (i = 0; i < length; i++) { + entry = summary[i]; + var count = entry.count; + var size = entry.size; + result += ' [' + padding(index, max_digits) + index + '] ' + + ' count '+ count + padding(count, max_count_digits) + + ' size '+ size + padding(size, max_size_digits) + + ' : <' + entry.desc + '>\n'; + index++; + } + result += '\n total count: '+(total_count+roots_count)+'\n'; + if (body.size) { + result += ' total size: '+body.size+'\n'; + } + + } else { + // Print the full dump result: + var first_index = body.first_index + 1; + var elements = body.elements; + length = elements.length; + var has_more = ((first_index + length) <= total_count); + result = title; + if (has_more || (first_index != 1)) { + result += ' ['+ length +' of '+ total_count + + ': starting from '+ first_index +']'; + } + result += ':\n'; + if (length === 0) result += ' none\n'; + max_digits = digitsIn(length); + + var max_id = 0; + var max_size = 0; + for (i = 0; i < length; i++) { + entry = elements[i]; + if (entry.id > max_id) max_id = entry.id; + if (entry.size > max_size) max_size = entry.size; + } + var max_id_digits = digitsIn(max_id); + max_size_digits = digitsIn(max_size); + + for (i = 0; i < length; i++) { + entry = elements[i]; + index = first_index + i; + result += ' ['+ padding(index, max_digits) + index +']'; + if (entry.id !== 0) { + result += ' @' + entry.id + padding(entry.id, max_id_digits) + + ': size ' + entry.size + ', ' + + padding(entry.size, max_size_digits) + entry.desc + '\n'; + } else { + // Must be a root or weak root: + result += ' ' + entry.desc + '\n'; + } + } + if (has_more) { + result += ' -- press for more --\n'; + } else { + repeat_cmd_line = ''; + } + if (length === 0) result += ' none\n'; + } + + return result; +} + + +function decodeLolDiffResponse(body) { + var title = 'objects'; + return decodeLolListResponse(body, title); +} + + +function decodeLolRetainersResponse(body) { + var title = 'retainers for @' + body.id; + return decodeLolListResponse(body, title); +} + + +function decodeLolPathResponse(body) { + return body.path; +} + + +function decodeLolResetResponse(body) { + return 'Reset all live object lists.'; +} + + +function decodeLolGetIdResponse(body) { + if (body.id == 0) { + return 'Address is invalid, or object has been moved or collected'; + } + return 'obj id is @' + body.id; +} + + +function decodeLolPrintResponse(body) { + return body.dump; +} + + // Rounds number 'num' to 'length' decimal places. function roundNumber(num, length) { var factor = Math.pow(10, length); @@ -1510,6 +2099,7 @@ function DebugResponseDetails(response) { case 'evaluate': case 'lookup': + case 'getobj': if (last_cmd == 'p' || last_cmd == 'print') { result = body.text; } else { @@ -1671,6 +2261,34 @@ function DebugResponseDetails(response) { } break; + case 'lol-capture': + details.text = decodeLolCaptureResponse(body); + break; + case 'lol-delete': + details.text = decodeLolDeleteResponse(body); + break; + case 'lol-diff': + details.text = decodeLolDiffResponse(body); + break; + case 'lol-getid': + details.text = decodeLolGetIdResponse(body); + break; + case 'lol-info': + details.text = decodeLolInfoResponse(body); + break; + case 'lol-print': + details.text = decodeLolPrintResponse(body); + break; + case 'lol-reset': + details.text = decodeLolResetResponse(body); + break; + case 'lol-retainers': + details.text = decodeLolRetainersResponse(body); + break; + case 'lol-path': + details.text = decodeLolPathResponse(body); + break; + default: details.text = 'Response for unknown command \'' + response.command() + '\'' + diff --git a/deps/v8/src/debug-debugger.js b/deps/v8/src/debug-debugger.js index 1adf73ac71..bc0f966fb1 100644 --- a/deps/v8/src/debug-debugger.js +++ b/deps/v8/src/debug-debugger.js @@ -109,6 +109,7 @@ var debugger_flags = { } }, }; +var lol_is_enabled = %HasLOLEnabled(); // Create a new break point object and add it to the list of break points. @@ -1391,6 +1392,8 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request) this.scopeRequest_(request, response); } else if (request.command == 'evaluate') { this.evaluateRequest_(request, response); + } else if (lol_is_enabled && request.command == 'getobj') { + this.getobjRequest_(request, response); } else if (request.command == 'lookup') { this.lookupRequest_(request, response); } else if (request.command == 'references') { @@ -1418,6 +1421,28 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request) } else if (request.command == 'gc') { this.gcRequest_(request, response); + // LiveObjectList tools: + } else if (lol_is_enabled && request.command == 'lol-capture') { + this.lolCaptureRequest_(request, response); + } else if (lol_is_enabled && request.command == 'lol-delete') { + this.lolDeleteRequest_(request, response); + } else if (lol_is_enabled && request.command == 'lol-diff') { + this.lolDiffRequest_(request, response); + } else if (lol_is_enabled && request.command == 'lol-getid') { + this.lolGetIdRequest_(request, response); + } else if (lol_is_enabled && request.command == 'lol-info') { + this.lolInfoRequest_(request, response); + } else if (lol_is_enabled && request.command == 'lol-reset') { + this.lolResetRequest_(request, response); + } else if (lol_is_enabled && request.command == 'lol-retainers') { + this.lolRetainersRequest_(request, response); + } else if (lol_is_enabled && request.command == 'lol-path') { + this.lolPathRequest_(request, response); + } else if (lol_is_enabled && request.command == 'lol-print') { + this.lolPrintRequest_(request, response); + } else if (lol_is_enabled && request.command == 'lol-stats') { + this.lolStatsRequest_(request, response); + } else { throw new Error('Unknown command "' + request.command + '" in request'); } @@ -2011,6 +2036,24 @@ DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) { }; +DebugCommandProcessor.prototype.getobjRequest_ = function(request, response) { + if (!request.arguments) { + return response.failed('Missing arguments'); + } + + // Pull out arguments. + var obj_id = request.arguments.obj_id; + + // Check for legal arguments. + if (IS_UNDEFINED(obj_id)) { + return response.failed('Argument "obj_id" missing'); + } + + // Dump the object. + response.body = MakeMirror(%GetLOLObj(obj_id)); +}; + + DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) { if (!request.arguments) { return response.failed('Missing arguments'); @@ -2341,6 +2384,84 @@ DebugCommandProcessor.prototype.gcRequest_ = function(request, response) { }; +DebugCommandProcessor.prototype.lolCaptureRequest_ = + function(request, response) { + response.body = %CaptureLOL(); +}; + + +DebugCommandProcessor.prototype.lolDeleteRequest_ = + function(request, response) { + var id = request.arguments.id; + var result = %DeleteLOL(id); + if (result) { + response.body = { id: id }; + } else { + response.failed('Failed to delete: live object list ' + id + ' not found.'); + } +}; + + +DebugCommandProcessor.prototype.lolDiffRequest_ = function(request, response) { + var id1 = request.arguments.id1; + var id2 = request.arguments.id2; + var verbose = request.arguments.verbose; + var filter = request.arguments.filter; + if (verbose === true) { + var start = request.arguments.start; + var count = request.arguments.count; + response.body = %DumpLOL(id1, id2, start, count, filter); + } else { + response.body = %SummarizeLOL(id1, id2, filter); + } +}; + + +DebugCommandProcessor.prototype.lolGetIdRequest_ = function(request, response) { + var address = request.arguments.address; + response.body = {}; + response.body.id = %GetLOLObjId(address); +}; + + +DebugCommandProcessor.prototype.lolInfoRequest_ = function(request, response) { + var start = request.arguments.start; + var count = request.arguments.count; + response.body = %InfoLOL(start, count); +}; + + +DebugCommandProcessor.prototype.lolResetRequest_ = function(request, response) { + %ResetLOL(); +}; + + +DebugCommandProcessor.prototype.lolRetainersRequest_ = + function(request, response) { + var id = request.arguments.id; + var verbose = request.arguments.verbose; + var start = request.arguments.start; + var count = request.arguments.count; + var filter = request.arguments.filter; + + response.body = %GetLOLObjRetainers(id, Mirror.prototype, verbose, + start, count, filter); +}; + + +DebugCommandProcessor.prototype.lolPathRequest_ = function(request, response) { + var id1 = request.arguments.id1; + var id2 = request.arguments.id2; + response.body = {}; + response.body.path = %GetLOLPath(id1, id2, Mirror.prototype); +}; + + +DebugCommandProcessor.prototype.lolPrintRequest_ = function(request, response) { + var id = request.arguments.id; + response.body = {}; + response.body.dump = %PrintLOLObj(id); +}; // Check whether the previously processed command caused the VM to become diff --git a/deps/v8/src/debug.cc b/deps/v8/src/debug.cc index d8201a1894..c473941210 100644 --- a/deps/v8/src/debug.cc +++ b/deps/v8/src/debug.cc @@ -836,7 +836,8 @@ bool Debug::Load() { Handle key = Factory::LookupAsciiSymbol("builtins"); Handle global = Handle(context->global()); RETURN_IF_EMPTY_HANDLE_VALUE( - SetProperty(global, key, Handle(global->builtins()), NONE), + SetProperty(global, key, Handle(global->builtins()), + NONE, kNonStrictMode), false); // Compile the JavaScript for the debugger in the debugger context. diff --git a/deps/v8/src/flag-definitions.h b/deps/v8/src/flag-definitions.h index 96f63c530d..ea245a44d7 100644 --- a/deps/v8/src/flag-definitions.h +++ b/deps/v8/src/flag-definitions.h @@ -110,7 +110,6 @@ DEFINE_bool(use_lithium, true, "use lithium code generator") DEFINE_bool(use_range, true, "use hydrogen range analysis") DEFINE_bool(eliminate_dead_phis, true, "eliminate dead phis") DEFINE_bool(use_gvn, true, "use hydrogen global value numbering") -DEFINE_bool(use_peeling, false, "use loop peeling") DEFINE_bool(use_canonicalizing, true, "use hydrogen instruction canonicalizing") DEFINE_bool(use_inlining, true, "use function inlining") DEFINE_bool(limit_inlining, true, "limit code size growth from inlining") @@ -135,11 +134,8 @@ DEFINE_bool(deoptimize_uncommon_cases, true, "deoptimize uncommon cases") DEFINE_bool(polymorphic_inlining, true, "polymorphic inlining") DEFINE_bool(aggressive_loop_invariant_motion, true, "aggressive motion of instructions out of loops") -#ifdef V8_TARGET_ARCH_X64 -DEFINE_bool(use_osr, false, "use on-stack replacement") -#else DEFINE_bool(use_osr, true, "use on-stack replacement") -#endif + DEFINE_bool(trace_osr, false, "trace on-stack replacement") DEFINE_int(stress_runs, 0, "number of stress runs") DEFINE_bool(optimize_closures, true, "optimize closures") @@ -270,6 +266,12 @@ DEFINE_bool(use_idle_notification, true, // ic.cc DEFINE_bool(use_ic, true, "use inline caching") +#ifdef LIVE_OBJECT_LIST +// liveobjectlist.cc +DEFINE_string(lol_workdir, NULL, "path for lol temp files") +DEFINE_bool(verify_lol, false, "perform debugging verification for lol") +#endif + // macro-assembler-ia32.cc DEFINE_bool(native_code_counters, false, "generate extra code for manipulating stats counters") @@ -358,7 +360,7 @@ DEFINE_bool(remote_debugger, false, "Connect JavaScript debugger to the " "debugger agent in another process") DEFINE_bool(debugger_agent, false, "Enable debugger agent") DEFINE_int(debugger_port, 5858, "Port to use for remote debugging") -DEFINE_string(map_counters, NULL, "Map counters to a file") +DEFINE_string(map_counters, "", "Map counters to a file") DEFINE_args(js_arguments, JSArguments(), "Pass all remaining arguments to the script. Alias for \"--\".") diff --git a/deps/v8/src/frame-element.h b/deps/v8/src/frame-element.h index 3b91b9d34a..ae5d6a1bf2 100644 --- a/deps/v8/src/frame-element.h +++ b/deps/v8/src/frame-element.h @@ -113,6 +113,10 @@ class FrameElement BASE_EMBEDDED { static ZoneObjectList* ConstantList(); + static bool ConstantPoolOverflowed() { + return !DataField::is_valid(ConstantList()->length()); + } + // Clear the constants indirection table. static void ClearConstantList() { ConstantList()->Clear(); diff --git a/deps/v8/src/full-codegen.cc b/deps/v8/src/full-codegen.cc index 252fb9257a..b3dc95bdff 100644 --- a/deps/v8/src/full-codegen.cc +++ b/deps/v8/src/full-codegen.cc @@ -739,25 +739,13 @@ void FullCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { case Token::SHL: case Token::SHR: case Token::SAR: { - // Figure out if either of the operands is a constant. - ConstantOperand constant = ShouldInlineSmiCase(op) - ? GetConstantOperand(op, left, right) - : kNoConstants; - - // Load only the operands that we need to materialize. - if (constant == kNoConstants) { - VisitForStackValue(left); - VisitForAccumulatorValue(right); - } else if (constant == kRightConstant) { - VisitForAccumulatorValue(left); - } else { - ASSERT(constant == kLeftConstant); - VisitForAccumulatorValue(right); - } + // Load both operands. + VisitForStackValue(left); + VisitForAccumulatorValue(right); SetSourcePosition(expr->position()); if (ShouldInlineSmiCase(op)) { - EmitInlineSmiBinaryOp(expr, op, mode, left, right, constant); + EmitInlineSmiBinaryOp(expr, op, mode, left, right); } else { EmitBinaryOp(op, mode); } diff --git a/deps/v8/src/full-codegen.h b/deps/v8/src/full-codegen.h index 655e560eb5..5fb11b43d9 100644 --- a/deps/v8/src/full-codegen.h +++ b/deps/v8/src/full-codegen.h @@ -274,12 +274,6 @@ class FullCodeGenerator: public AstVisitor { ForwardBailoutStack* const parent_; }; - enum ConstantOperand { - kNoConstants, - kLeftConstant, - kRightConstant - }; - // Type of a member function that generates inline code for a native function. typedef void (FullCodeGenerator::*InlineFunctionGenerator) (ZoneList*); @@ -298,11 +292,6 @@ class FullCodeGenerator: public AstVisitor { // operation. bool ShouldInlineSmiCase(Token::Value op); - // Compute which (if any) of the operands is a compile-time constant. - ConstantOperand GetConstantOperand(Token::Value op, - Expression* left, - Expression* right); - // Helper function to convert a pure value into a test context. The value // is expected on the stack or the accumulator, depending on the platform. // See the platform-specific implementation for details. @@ -432,6 +421,14 @@ class FullCodeGenerator: public AstVisitor { Label* done); void EmitVariableLoad(Variable* expr); + enum ResolveEvalFlag { + SKIP_CONTEXT_LOOKUP, + PERFORM_CONTEXT_LOOKUP + }; + + // Expects the arguments and the function already pushed. + void EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, int arg_count); + // Platform-specific support for allocating a new closure based on // the given function info. void EmitNewClosure(Handle info, bool pretenure); @@ -457,34 +454,7 @@ class FullCodeGenerator: public AstVisitor { Token::Value op, OverwriteMode mode, Expression* left, - Expression* right, - ConstantOperand constant); - - void EmitConstantSmiBinaryOp(Expression* expr, - Token::Value op, - OverwriteMode mode, - bool left_is_constant_smi, - Smi* value); - - void EmitConstantSmiBitOp(Expression* expr, - Token::Value op, - OverwriteMode mode, - Smi* value); - - void EmitConstantSmiShiftOp(Expression* expr, - Token::Value op, - OverwriteMode mode, - Smi* value); - - void EmitConstantSmiAdd(Expression* expr, - OverwriteMode mode, - bool left_is_constant_smi, - Smi* value); - - void EmitConstantSmiSub(Expression* expr, - OverwriteMode mode, - bool left_is_constant_smi, - Smi* value); + Expression* right); // Assign to the given expression as if via '='. The right-hand-side value // is expected in the accumulator. diff --git a/deps/v8/src/handles-inl.h b/deps/v8/src/handles-inl.h index b31351256e..c0f2fda929 100644 --- a/deps/v8/src/handles-inl.h +++ b/deps/v8/src/handles-inl.h @@ -36,14 +36,14 @@ namespace v8 { namespace internal { -template +template Handle::Handle(T* obj) { ASSERT(!obj->IsFailure()); location_ = HandleScope::CreateHandle(obj); } -template +template inline T* Handle::operator*() const { ASSERT(location_ != NULL); ASSERT(reinterpret_cast
(*location_) != kHandleZapValue); diff --git a/deps/v8/src/handles.cc b/deps/v8/src/handles.cc index b48aa507e2..05c81bb3f5 100644 --- a/deps/v8/src/handles.cc +++ b/deps/v8/src/handles.cc @@ -242,17 +242,21 @@ Handle SetPrototype(Handle function, Handle SetProperty(Handle object, Handle key, Handle value, - PropertyAttributes attributes) { - CALL_HEAP_FUNCTION(object->SetProperty(*key, *value, attributes), Object); + PropertyAttributes attributes, + StrictModeFlag strict) { + CALL_HEAP_FUNCTION(object->SetProperty(*key, *value, attributes, strict), + Object); } Handle SetProperty(Handle object, Handle key, Handle value, - PropertyAttributes attributes) { + PropertyAttributes attributes, + StrictModeFlag strict) { CALL_HEAP_FUNCTION( - Runtime::SetObjectProperty(object, key, value, attributes), Object); + Runtime::SetObjectProperty(object, key, value, attributes, strict), + Object); } @@ -304,10 +308,12 @@ void SetLocalPropertyNoThrow(Handle object, Handle SetPropertyWithInterceptor(Handle object, Handle key, Handle value, - PropertyAttributes attributes) { + PropertyAttributes attributes, + StrictModeFlag strict) { CALL_HEAP_FUNCTION(object->SetPropertyWithInterceptor(*key, *value, - attributes), + attributes, + strict), Object); } @@ -863,10 +869,12 @@ bool CompileLazyInLoop(Handle function, } -bool CompileOptimized(Handle function, int osr_ast_id) { +bool CompileOptimized(Handle function, + int osr_ast_id, + ClearExceptionFlag flag) { CompilationInfo info(function); info.SetOptimizing(osr_ast_id); - return CompileLazyHelper(&info, KEEP_EXCEPTION); + return CompileLazyHelper(&info, flag); } diff --git a/deps/v8/src/handles.h b/deps/v8/src/handles.h index d95ca91170..9d3588bf9a 100644 --- a/deps/v8/src/handles.h +++ b/deps/v8/src/handles.h @@ -39,7 +39,7 @@ namespace internal { // Handles are only valid within a HandleScope. // When a handle is created for an object a cell is allocated in the heap. -template +template class Handle { public: INLINE(explicit Handle(T** location)) { location_ = location; } @@ -112,15 +112,7 @@ class HandleScope { } ~HandleScope() { - current_.next = prev_next_; - current_.level--; - if (current_.limit != prev_limit_) { - current_.limit = prev_limit_; - DeleteExtensions(); - } -#ifdef DEBUG - ZapRange(prev_next_, prev_limit_); -#endif + CloseScope(); } // Counts the number of allocated handles. @@ -148,6 +140,26 @@ class HandleScope { static Address current_limit_address(); static Address current_level_address(); + // Closes the HandleScope (invalidating all handles + // created in the scope of the HandleScope) and returns + // a Handle backed by the parent scope holding the + // value of the argument handle. + template + Handle CloseAndEscape(Handle handle_value) { + T* value = *handle_value; + // Throw away all handles in the current scope. + CloseScope(); + // Allocate one handle in the parent scope. + ASSERT(current_.level > 0); + Handle result(CreateHandle(value)); + // Reinitialize the current scope (so that it's ready + // to be used or closed again). + prev_next_ = current_.next; + prev_limit_ = current_.limit; + current_.level++; + return result; + } + private: // Prevent heap allocation or illegal handle scopes. HandleScope(const HandleScope&); @@ -155,9 +167,23 @@ class HandleScope { void* operator new(size_t size); void operator delete(void* size_t); + inline void CloseScope() { + current_.next = prev_next_; + current_.level--; + if (current_.limit != prev_limit_) { + current_.limit = prev_limit_; + DeleteExtensions(); + } +#ifdef DEBUG + ZapRange(prev_next_, prev_limit_); +#endif + } + static v8::ImplementationUtilities::HandleScopeData current_; - Object** const prev_next_; - Object** const prev_limit_; + // Holds values on entry. The prev_next_ value is never NULL + // on_entry, but is set to NULL when this scope is closed. + Object** prev_next_; + Object** prev_limit_; // Extend the handle scope making room for more handles. static internal::Object** Extend(); @@ -197,12 +223,14 @@ Handle FlattenGetString(Handle str); Handle SetProperty(Handle object, Handle key, Handle value, - PropertyAttributes attributes); + PropertyAttributes attributes, + StrictModeFlag strict); Handle SetProperty(Handle object, Handle key, Handle value, - PropertyAttributes attributes); + PropertyAttributes attributes, + StrictModeFlag strict); Handle ForceSetProperty(Handle object, Handle key, @@ -233,7 +261,8 @@ void SetLocalPropertyNoThrow(Handle object, Handle SetPropertyWithInterceptor(Handle object, Handle key, Handle value, - PropertyAttributes attributes); + PropertyAttributes attributes, + StrictModeFlag strict); Handle SetElement(Handle object, uint32_t index, @@ -354,7 +383,9 @@ bool CompileLazy(Handle function, ClearExceptionFlag flag); bool CompileLazyInLoop(Handle function, ClearExceptionFlag flag); -bool CompileOptimized(Handle function, int osr_ast_id); +bool CompileOptimized(Handle function, + int osr_ast_id, + ClearExceptionFlag flag); class NoHandleAllocation BASE_EMBEDDED { public: diff --git a/deps/v8/src/heap-profiler.cc b/deps/v8/src/heap-profiler.cc index 732d2f4102..07b631fa73 100644 --- a/deps/v8/src/heap-profiler.cc +++ b/deps/v8/src/heap-profiler.cc @@ -911,22 +911,27 @@ static JSObjectsCluster HeapObjectAsCluster(HeapObject* object) { class CountingRetainersIterator { public: CountingRetainersIterator(const JSObjectsCluster& child_cluster, + HeapEntriesAllocator* allocator, HeapEntriesMap* map) - : child_(ClusterAsHeapObject(child_cluster)), map_(map) { + : child_(ClusterAsHeapObject(child_cluster)), + allocator_(allocator), + map_(map) { if (map_->Map(child_) == NULL) - map_->Pair(child_, HeapEntriesMap::kHeapEntryPlaceholder); + map_->Pair(child_, allocator_, HeapEntriesMap::kHeapEntryPlaceholder); } void Call(const JSObjectsCluster& cluster, const NumberAndSizeInfo& number_and_size) { if (map_->Map(ClusterAsHeapObject(cluster)) == NULL) map_->Pair(ClusterAsHeapObject(cluster), + allocator_, HeapEntriesMap::kHeapEntryPlaceholder); map_->CountReference(ClusterAsHeapObject(cluster), child_); } private: HeapObject* child_; + HeapEntriesAllocator* allocator_; HeapEntriesMap* map_; }; @@ -934,6 +939,7 @@ class CountingRetainersIterator { class AllocatingRetainersIterator { public: AllocatingRetainersIterator(const JSObjectsCluster& child_cluster, + HeapEntriesAllocator*, HeapEntriesMap* map) : child_(ClusterAsHeapObject(child_cluster)), map_(map) { child_entry_ = map_->Map(child_); @@ -966,8 +972,9 @@ template class AggregatingRetainerTreeIterator { public: explicit AggregatingRetainerTreeIterator(ClustersCoarser* coarser, + HeapEntriesAllocator* allocator, HeapEntriesMap* map) - : coarser_(coarser), map_(map) { + : coarser_(coarser), allocator_(allocator), map_(map) { } void Call(const JSObjectsCluster& cluster, JSObjectsClusterTree* tree) { @@ -981,25 +988,28 @@ class AggregatingRetainerTreeIterator { tree->ForEach(&retainers_aggregator); tree_to_iterate = &dest_tree_; } - RetainersIterator iterator(cluster, map_); + RetainersIterator iterator(cluster, allocator_, map_); tree_to_iterate->ForEach(&iterator); } private: ClustersCoarser* coarser_; + HeapEntriesAllocator* allocator_; HeapEntriesMap* map_; }; -class AggregatedRetainerTreeAllocator { +class AggregatedRetainerTreeAllocator : public HeapEntriesAllocator { public: AggregatedRetainerTreeAllocator(HeapSnapshot* snapshot, int* root_child_index) : snapshot_(snapshot), root_child_index_(root_child_index) { } + ~AggregatedRetainerTreeAllocator() { } - HeapEntry* GetEntry( - HeapObject* obj, int children_count, int retainers_count) { + HeapEntry* AllocateEntry( + HeapThing ptr, int children_count, int retainers_count) { + HeapObject* obj = reinterpret_cast(ptr); JSObjectsCluster cluster = HeapObjectAsCluster(obj); const char* name = cluster.GetSpecialCaseName(); if (name == NULL) { @@ -1018,12 +1028,13 @@ class AggregatedRetainerTreeAllocator { template void AggregatedHeapSnapshotGenerator::IterateRetainers( - HeapEntriesMap* entries_map) { + HeapEntriesAllocator* allocator, HeapEntriesMap* entries_map) { RetainerHeapProfile* p = agg_snapshot_->js_retainer_profile(); AggregatingRetainerTreeIterator agg_ret_iter_1( - p->coarser(), entries_map); + p->coarser(), allocator, entries_map); p->retainers_tree()->ForEach(&agg_ret_iter_1); - AggregatingRetainerTreeIterator agg_ret_iter_2(NULL, entries_map); + AggregatingRetainerTreeIterator agg_ret_iter_2( + NULL, allocator, entries_map); p->aggregator()->output_tree().ForEach(&agg_ret_iter_2); } @@ -1042,7 +1053,9 @@ void AggregatedHeapSnapshotGenerator::FillHeapSnapshot(HeapSnapshot* snapshot) { agg_snapshot_->js_cons_profile()->ForEach(&counting_cons_iter); histogram_entities_count += counting_cons_iter.entities_count(); HeapEntriesMap entries_map; - IterateRetainers(&entries_map); + int root_child_index = 0; + AggregatedRetainerTreeAllocator allocator(snapshot, &root_child_index); + IterateRetainers(&allocator, &entries_map); histogram_entities_count += entries_map.entries_count(); histogram_children_count += entries_map.total_children_count(); histogram_retainers_count += entries_map.total_retainers_count(); @@ -1056,10 +1069,7 @@ void AggregatedHeapSnapshotGenerator::FillHeapSnapshot(HeapSnapshot* snapshot) { snapshot->AllocateEntries(histogram_entities_count, histogram_children_count, histogram_retainers_count); - snapshot->AddEntry(HeapSnapshot::kInternalRootObject, - root_children_count, - 0); - int root_child_index = 0; + snapshot->AddRootEntry(root_children_count); for (int i = FIRST_NONSTRING_TYPE; i <= kAllStringsType; ++i) { if (agg_snapshot_->info()[i].bytes() > 0) { AddEntryFromAggregatedSnapshot(snapshot, @@ -1075,11 +1085,10 @@ void AggregatedHeapSnapshotGenerator::FillHeapSnapshot(HeapSnapshot* snapshot) { AllocatingConstructorHeapProfileIterator alloc_cons_iter( snapshot, &root_child_index); agg_snapshot_->js_cons_profile()->ForEach(&alloc_cons_iter); - AggregatedRetainerTreeAllocator allocator(snapshot, &root_child_index); - entries_map.UpdateEntries(&allocator); + entries_map.AllocateEntries(); // Fill up references. - IterateRetainers(&entries_map); + IterateRetainers(&allocator, &entries_map); snapshot->SetDominatorsToSelf(); } diff --git a/deps/v8/src/heap-profiler.h b/deps/v8/src/heap-profiler.h index 90c664edee..20ba457c5b 100644 --- a/deps/v8/src/heap-profiler.h +++ b/deps/v8/src/heap-profiler.h @@ -340,6 +340,7 @@ class AggregatedHeapSnapshot { class HeapEntriesMap; +class HeapEntriesAllocator; class HeapSnapshot; class AggregatedHeapSnapshotGenerator { @@ -354,7 +355,8 @@ class AggregatedHeapSnapshotGenerator { void CalculateStringsStats(); void CollectStats(HeapObject* obj); template - void IterateRetainers(HeapEntriesMap* entries_map); + void IterateRetainers( + HeapEntriesAllocator* allocator, HeapEntriesMap* entries_map); AggregatedHeapSnapshot* agg_snapshot_; }; diff --git a/deps/v8/src/heap.cc b/deps/v8/src/heap.cc index 1fadec3831..34ab9aafcf 100644 --- a/deps/v8/src/heap.cc +++ b/deps/v8/src/heap.cc @@ -844,8 +844,6 @@ void Heap::MarkCompactPrologue(bool is_compacting) { ContextSlotCache::Clear(); DescriptorLookupCache::Clear(); - RuntimeProfiler::MarkCompactPrologue(is_compacting); - CompilationCache::MarkCompactPrologue(); CompletelyClearInstanceofCache(); @@ -1056,20 +1054,13 @@ void Heap::Scavenge() { // Scavenge object reachable from the global contexts list directly. scavenge_visitor.VisitPointer(BitCast(&global_contexts_list_)); - // Scavenge objects reachable from the runtime-profiler sampler - // window directly. - Object** sampler_window_address = RuntimeProfiler::SamplerWindowAddress(); - int sampler_window_size = RuntimeProfiler::SamplerWindowSize(); - scavenge_visitor.VisitPointers( - sampler_window_address, - sampler_window_address + sampler_window_size); - new_space_front = DoScavenge(&scavenge_visitor, new_space_front); UpdateNewSpaceReferencesInExternalStringTable( &UpdateNewSpaceReferenceInExternalStringTableEntry); LiveObjectList::UpdateReferencesForScavengeGC(); + RuntimeProfiler::UpdateSamplesAfterScavenge(); ASSERT(new_space_front == new_space_.top()); @@ -5336,7 +5327,11 @@ void PathTracer::ProcessResults() { for (int i = 0; i < object_stack_.length(); i++) { if (i > 0) PrintF("\n |\n |\n V\n\n"); Object* obj = object_stack_[i]; +#ifdef OBJECT_PRINT obj->Print(); +#else + obj->ShortPrint(); +#endif } PrintF("=====================================\n"); } diff --git a/deps/v8/src/hydrogen.cc b/deps/v8/src/hydrogen.cc index 9e40a50c71..e40685cd69 100644 --- a/deps/v8/src/hydrogen.cc +++ b/deps/v8/src/hydrogen.cc @@ -482,128 +482,75 @@ HConstant* HGraph::GetConstantFalse() { } -void HSubgraph::AppendJoin(HBasicBlock* first, - HBasicBlock* second, - int join_id) { +HBasicBlock* HGraphBuilder::CreateJoin(HBasicBlock* first, + HBasicBlock* second, + int join_id) { if (first == NULL) { - exit_block_ = second; + return second; } else if (second == NULL) { - exit_block_ = first; + return first; } else { HBasicBlock* join_block = graph_->CreateBasicBlock(); first->Goto(join_block); second->Goto(join_block); join_block->SetJoinId(join_id); - exit_block_ = join_block; + return join_block; } } -void HSubgraph::ResolveContinue(IterationStatement* statement, - HBasicBlock* continue_block) { +HBasicBlock* HGraphBuilder::JoinContinue(IterationStatement* statement, + HBasicBlock* exit_block, + HBasicBlock* continue_block) { if (continue_block != NULL) { continue_block->SetJoinId(statement->ContinueId()); } - exit_block_ = - JoinBlocks(exit_block(), continue_block, statement->ContinueId()); + return CreateJoin(exit_block, continue_block, statement->ContinueId()); } -HBasicBlock* HSubgraph::JoinBlocks(HBasicBlock* a, HBasicBlock* b, int id) { - if (a == NULL) return b; - if (b == NULL) return a; - HBasicBlock* target = graph_->CreateBasicBlock(); - a->Goto(target); - b->Goto(target); - target->SetJoinId(id); - return target; -} - - -void HSubgraph::AppendEndless(IterationStatement* statement, - HBasicBlock* body_entry, - HBasicBlock* body_exit, - HBasicBlock* break_block) { - if (exit_block() != NULL) { - exit_block()->Goto(body_entry, false); - } - if (body_exit != NULL) { - body_exit->Goto(body_entry, true); - } +HBasicBlock* HGraphBuilder::CreateEndless(IterationStatement* statement, + HBasicBlock* body_entry, + HBasicBlock* body_exit, + HBasicBlock* break_block) { + if (body_exit != NULL) body_exit->Goto(body_entry, true); if (break_block != NULL) break_block->SetJoinId(statement->ExitId()); - exit_block_ = break_block; body_entry->PostProcessLoopHeader(statement); + return break_block; } -void HSubgraph::AppendDoWhile(IterationStatement* statement, - HBasicBlock* body_entry, - HBasicBlock* go_back, - HBasicBlock* exit_block, - HBasicBlock* break_block) { - if (this->exit_block() != NULL) { - this->exit_block()->Goto(body_entry, false); - } - if (go_back != NULL) { - go_back->Goto(body_entry, true); - } +HBasicBlock* HGraphBuilder::CreateDoWhile(IterationStatement* statement, + HBasicBlock* body_entry, + HBasicBlock* go_back, + HBasicBlock* exit_block, + HBasicBlock* break_block) { + if (go_back != NULL) go_back->Goto(body_entry, true); if (break_block != NULL) break_block->SetJoinId(statement->ExitId()); - exit_block_ = - JoinBlocks(exit_block, break_block, statement->ExitId()); + HBasicBlock* new_exit = + CreateJoin(exit_block, break_block, statement->ExitId()); body_entry->PostProcessLoopHeader(statement); + return new_exit; } -void HSubgraph::AppendWhile(IterationStatement* statement, - HBasicBlock* condition_entry, - HBasicBlock* exit_block, - HBasicBlock* body_exit, - HBasicBlock* break_block, - HBasicBlock* loop_entry, - HBasicBlock* loop_exit) { - if (this->exit_block() != NULL) { - this->exit_block()->Goto(condition_entry, false); - } - +HBasicBlock* HGraphBuilder::CreateWhile(IterationStatement* statement, + HBasicBlock* loop_entry, + HBasicBlock* cond_false, + HBasicBlock* body_exit, + HBasicBlock* break_block) { if (break_block != NULL) break_block->SetJoinId(statement->ExitId()); - exit_block_ = - JoinBlocks(exit_block, break_block, statement->ExitId()); - - if (loop_entry != NULL) { - if (body_exit != NULL) { - body_exit->Goto(loop_entry, true); - } - loop_entry->SetJoinId(statement->EntryId()); - exit_block_ = JoinBlocks(exit_block_, loop_exit, statement->ExitId()); - } else { - if (body_exit != NULL) { - body_exit->Goto(condition_entry, true); - } - } - condition_entry->PostProcessLoopHeader(statement); + HBasicBlock* new_exit = + CreateJoin(cond_false, break_block, statement->ExitId()); + if (body_exit != NULL) body_exit->Goto(loop_entry, true); + loop_entry->PostProcessLoopHeader(statement); + return new_exit; } -void HSubgraph::Append(BreakableStatement* stmt, - HBasicBlock* entry_block, - HBasicBlock* exit_block, - HBasicBlock* break_block) { - exit_block_->Goto(entry_block); - exit_block_ = exit_block; - - if (stmt != NULL) { - entry_block->SetJoinId(stmt->EntryId()); - if (break_block != NULL) break_block->SetJoinId(stmt->EntryId()); - exit_block_ = JoinBlocks(exit_block, break_block, stmt->ExitId()); - } -} - - -void HSubgraph::FinishExit(HControlInstruction* instruction) { - ASSERT(exit_block() != NULL); - exit_block_->Finish(instruction); - exit_block_->ClearEnvironment(); - exit_block_ = NULL; +void HBasicBlock::FinishExit(HControlInstruction* instruction) { + Finish(instruction); + ClearEnvironment(); } @@ -2165,16 +2112,16 @@ HGraph* HGraphBuilder::CreateGraph(CompilationInfo* info) { ZoneList* stmts = info->function()->body(); HSubgraph* body = CreateGotoSubgraph(environment()); + current_block()->Goto(body->entry_block()); AddToSubgraph(body, stmts); if (HasStackOverflow()) return NULL; - current_subgraph_->Append(NULL, - body->entry_block(), - body->exit_block(), - NULL); body->entry_block()->SetJoinId(info->function()->id()); + set_current_block(body->exit_block()); if (graph()->exit_block() != NULL) { - graph_->FinishExit(new HReturn(graph_->GetConstantUndefined())); + HReturn* instr = new HReturn(graph()->GetConstantUndefined()); + graph()->exit_block()->FinishExit(instr); + graph()->set_exit_block(NULL); } } @@ -2361,28 +2308,29 @@ HSubgraph* HGraphBuilder::CreateBranchSubgraph(HEnvironment* env) { } -HSubgraph* HGraphBuilder::CreateLoopHeaderSubgraph(HEnvironment* env) { - HSubgraph* subgraph = new HSubgraph(graph()); - HBasicBlock* block = graph()->CreateBasicBlock(); - HEnvironment* new_env = env->CopyAsLoopHeader(block); - block->SetInitialEnvironment(new_env); - subgraph->Initialize(block); - subgraph->entry_block()->AttachLoopInformation(); - return subgraph; +HBasicBlock* HGraphBuilder::CreateLoopHeader() { + HBasicBlock* header = graph()->CreateBasicBlock(); + HEnvironment* entry_env = environment()->CopyAsLoopHeader(header); + header->SetInitialEnvironment(entry_env); + header->AttachLoopInformation(); + return header; } void HGraphBuilder::VisitBlock(Block* stmt) { if (stmt->labels() != NULL) { HSubgraph* block_graph = CreateGotoSubgraph(environment()); + current_block()->Goto(block_graph->entry_block()); + block_graph->entry_block()->SetJoinId(stmt->EntryId()); BreakAndContinueInfo break_info(stmt); { BreakAndContinueScope push(&break_info, this); ADD_TO_SUBGRAPH(block_graph, stmt->statements()); } - subgraph()->Append(stmt, - block_graph->entry_block(), - block_graph->exit_block(), - break_info.break_block()); + HBasicBlock* break_block = break_info.break_block(); + if (break_block != NULL) break_block->SetJoinId(stmt->EntryId()); + set_current_block(CreateJoin(block_graph->exit_block(), + break_block, + stmt->ExitId())); } else { VisitStatements(stmt->statements()); } @@ -2418,9 +2366,9 @@ void HGraphBuilder::VisitIfStatement(IfStatement* stmt) { else_graph->entry_block()->SetJoinId(stmt->ElseId()); ADD_TO_SUBGRAPH(else_graph, stmt->else_statement()); - current_subgraph_->AppendJoin(then_graph->exit_block(), - else_graph->exit_block(), - stmt->id()); + set_current_block(CreateJoin(then_graph->exit_block(), + else_graph->exit_block(), + stmt->id())); } } @@ -2476,7 +2424,8 @@ void HGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) { // Not an inlined return, so an actual one. VISIT_FOR_VALUE(stmt->expression()); HValue* result = environment()->Pop(); - subgraph()->FinishExit(new HReturn(result)); + current_block()->FinishExit(new HReturn(result)); + set_current_block(NULL); } else { // Return from an inlined function, visit the subexpression in the // expression context of the call. @@ -2496,7 +2445,7 @@ void HGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) { return_value = environment()->Pop(); } current_block()->AddLeaveInlined(return_value, - function_return_); + function_return_); set_current_block(NULL); } } @@ -2685,145 +2634,116 @@ bool HGraph::HasOsrEntryAt(IterationStatement* statement) { } -void HSubgraph::PreProcessOsrEntry(IterationStatement* statement) { +void HGraphBuilder::PreProcessOsrEntry(IterationStatement* statement) { if (!graph()->HasOsrEntryAt(statement)) return; HBasicBlock* non_osr_entry = graph()->CreateBasicBlock(); HBasicBlock* osr_entry = graph()->CreateBasicBlock(); HValue* true_value = graph()->GetConstantTrue(); HTest* test = new HTest(true_value, non_osr_entry, osr_entry); - exit_block()->Finish(test); + current_block()->Finish(test); HBasicBlock* loop_predecessor = graph()->CreateBasicBlock(); non_osr_entry->Goto(loop_predecessor); + set_current_block(osr_entry); int osr_entry_id = statement->OsrEntryId(); // We want the correct environment at the OsrEntry instruction. Build // it explicitly. The expression stack should be empty. - int count = osr_entry->last_environment()->length(); - ASSERT(count == (osr_entry->last_environment()->parameter_count() + - osr_entry->last_environment()->local_count())); + int count = environment()->length(); + ASSERT(count == + (environment()->parameter_count() + environment()->local_count())); for (int i = 0; i < count; ++i) { HUnknownOSRValue* unknown = new HUnknownOSRValue; - osr_entry->AddInstruction(unknown); - osr_entry->last_environment()->Bind(i, unknown); + AddInstruction(unknown); + environment()->Bind(i, unknown); } - osr_entry->AddSimulate(osr_entry_id); - osr_entry->AddInstruction(new HOsrEntry(osr_entry_id)); - osr_entry->Goto(loop_predecessor); + AddSimulate(osr_entry_id); + AddInstruction(new HOsrEntry(osr_entry_id)); + current_block()->Goto(loop_predecessor); loop_predecessor->SetJoinId(statement->EntryId()); - set_exit_block(loop_predecessor); + set_current_block(loop_predecessor); } void HGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { ASSERT(current_block() != NULL); - subgraph()->PreProcessOsrEntry(stmt); + PreProcessOsrEntry(stmt); + HBasicBlock* loop_entry = CreateLoopHeader(); + current_block()->Goto(loop_entry, false); + set_current_block(loop_entry); - HSubgraph* body_graph = CreateLoopHeaderSubgraph(environment()); BreakAndContinueInfo break_info(stmt); { BreakAndContinueScope push(&break_info, this); - ADD_TO_SUBGRAPH(body_graph, stmt->body()); + Visit(stmt->body()); + CHECK_BAILOUT; } - body_graph->ResolveContinue(stmt, break_info.continue_block()); - - if (body_graph->exit_block() == NULL || stmt->cond()->ToBooleanIsTrue()) { - subgraph()->AppendEndless(stmt, - body_graph->entry_block(), - body_graph->exit_block(), + HBasicBlock* body_exit = + JoinContinue(stmt, current_block(), break_info.continue_block()); + HBasicBlock* loop_exit = NULL; + if (body_exit == NULL || stmt->cond()->ToBooleanIsTrue()) { + loop_exit = CreateEndless(stmt, + loop_entry, + body_exit, break_info.break_block()); } else { - HSubgraph* go_back = CreateEmptySubgraph(); - HSubgraph* exit = CreateEmptySubgraph(); - { - SubgraphScope scope(this, body_graph); - VISIT_FOR_CONTROL(stmt->cond(), - go_back->entry_block(), - exit->entry_block()); - go_back->entry_block()->SetJoinId(stmt->BackEdgeId()); - exit->entry_block()->SetJoinId(stmt->ExitId()); - } - subgraph()->AppendDoWhile(stmt, - body_graph->entry_block(), - go_back->exit_block(), - exit->exit_block(), + set_current_block(body_exit); + HBasicBlock* cond_true = graph()->CreateBasicBlock(); + HBasicBlock* cond_false = graph()->CreateBasicBlock(); + VISIT_FOR_CONTROL(stmt->cond(), cond_true, cond_false); + cond_true->SetJoinId(stmt->BackEdgeId()); + cond_false->SetJoinId(stmt->ExitId()); + loop_exit = CreateDoWhile(stmt, + loop_entry, + cond_true, + cond_false, break_info.break_block()); } + set_current_block(loop_exit); } void HGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { ASSERT(current_block() != NULL); - subgraph()->PreProcessOsrEntry(stmt); - - HSubgraph* cond_graph = NULL; - HSubgraph* body_graph = NULL; - HSubgraph* exit_graph = NULL; - - // If the condition is constant true, do not generate a condition subgraph. - if (stmt->cond()->ToBooleanIsTrue()) { - body_graph = CreateLoopHeaderSubgraph(environment()); - } else { - cond_graph = CreateLoopHeaderSubgraph(environment()); - body_graph = CreateEmptySubgraph(); - exit_graph = CreateEmptySubgraph(); - { - SubgraphScope scope(this, cond_graph); - VISIT_FOR_CONTROL(stmt->cond(), - body_graph->entry_block(), - exit_graph->entry_block()); - body_graph->entry_block()->SetJoinId(stmt->BodyId()); - exit_graph->entry_block()->SetJoinId(stmt->ExitId()); - } + PreProcessOsrEntry(stmt); + HBasicBlock* loop_entry = CreateLoopHeader(); + current_block()->Goto(loop_entry, false); + set_current_block(loop_entry); + + // If the condition is constant true, do not generate a branch. + HBasicBlock* cond_false = NULL; + if (!stmt->cond()->ToBooleanIsTrue()) { + HBasicBlock* cond_true = graph()->CreateBasicBlock(); + cond_false = graph()->CreateBasicBlock(); + VISIT_FOR_CONTROL(stmt->cond(), cond_true, cond_false); + cond_true->SetJoinId(stmt->BodyId()); + cond_false->SetJoinId(stmt->ExitId()); + set_current_block(cond_true); } BreakAndContinueInfo break_info(stmt); { BreakAndContinueScope push(&break_info, this); - ADD_TO_SUBGRAPH(body_graph, stmt->body()); + Visit(stmt->body()); + CHECK_BAILOUT; } - body_graph->ResolveContinue(stmt, break_info.continue_block()); - - if (cond_graph != NULL) { - AppendPeeledWhile(stmt, - cond_graph->entry_block(), - exit_graph->exit_block(), - body_graph->exit_block(), - break_info.break_block()); - } else { + HBasicBlock* body_exit = + JoinContinue(stmt, current_block(), break_info.continue_block()); + HBasicBlock* loop_exit = NULL; + if (stmt->cond()->ToBooleanIsTrue()) { // TODO(fschneider): Implement peeling for endless loops as well. - subgraph()->AppendEndless(stmt, - body_graph->entry_block(), - body_graph->exit_block(), + loop_exit = CreateEndless(stmt, + loop_entry, + body_exit, break_info.break_block()); + } else { + loop_exit = CreateWhile(stmt, + loop_entry, + cond_false, + body_exit, + break_info.break_block()); } -} - - -void HGraphBuilder::AppendPeeledWhile(IterationStatement* stmt, - HBasicBlock* condition_entry, - HBasicBlock* exit_block, - HBasicBlock* body_exit, - HBasicBlock* break_block) { - HBasicBlock* loop_entry = NULL; - HBasicBlock* loop_exit = NULL; - if (FLAG_use_peeling && body_exit != NULL && stmt != peeled_statement_) { - // Save the last peeled iteration statement to prevent infinite recursion. - IterationStatement* outer_peeled_statement = peeled_statement_; - peeled_statement_ = stmt; - HSubgraph* loop = CreateGotoSubgraph(body_exit->last_environment()); - ADD_TO_SUBGRAPH(loop, stmt); - peeled_statement_ = outer_peeled_statement; - loop_entry = loop->entry_block(); - loop_exit = loop->exit_block(); - } - subgraph()->AppendWhile(stmt, - condition_entry, - exit_block, - body_exit, - break_block, - loop_entry, - loop_exit); + set_current_block(loop_exit); } @@ -2834,57 +2754,50 @@ void HGraphBuilder::VisitForStatement(ForStatement* stmt) { CHECK_BAILOUT; } ASSERT(current_block() != NULL); - subgraph()->PreProcessOsrEntry(stmt); + PreProcessOsrEntry(stmt); + HBasicBlock* loop_entry = CreateLoopHeader(); + current_block()->Goto(loop_entry, false); + set_current_block(loop_entry); - HSubgraph* cond_graph = NULL; - HSubgraph* body_graph = NULL; - HSubgraph* exit_graph = NULL; + HBasicBlock* cond_false = NULL; if (stmt->cond() != NULL) { - cond_graph = CreateLoopHeaderSubgraph(environment()); - body_graph = CreateEmptySubgraph(); - exit_graph = CreateEmptySubgraph(); - { - SubgraphScope scope(this, cond_graph); - VISIT_FOR_CONTROL(stmt->cond(), - body_graph->entry_block(), - exit_graph->entry_block()); - body_graph->entry_block()->SetJoinId(stmt->BodyId()); - exit_graph->entry_block()->SetJoinId(stmt->ExitId()); - } - } else { - body_graph = CreateLoopHeaderSubgraph(environment()); + HBasicBlock* cond_true = graph()->CreateBasicBlock(); + cond_false = graph()->CreateBasicBlock(); + VISIT_FOR_CONTROL(stmt->cond(), cond_true, cond_false); + cond_true->SetJoinId(stmt->BodyId()); + cond_false->SetJoinId(stmt->ExitId()); + set_current_block(cond_true); } + BreakAndContinueInfo break_info(stmt); { BreakAndContinueScope push(&break_info, this); - ADD_TO_SUBGRAPH(body_graph, stmt->body()); + Visit(stmt->body()); + CHECK_BAILOUT; } + HBasicBlock* body_exit = + JoinContinue(stmt, current_block(), break_info.continue_block()); - HSubgraph* next_graph = NULL; - body_graph->ResolveContinue(stmt, break_info.continue_block()); - - if (stmt->next() != NULL && body_graph->exit_block() != NULL) { - next_graph = - CreateGotoSubgraph(body_graph->exit_block()->last_environment()); - ADD_TO_SUBGRAPH(next_graph, stmt->next()); - body_graph->Append(NULL, - next_graph->entry_block(), - next_graph->exit_block(), - NULL); - next_graph->entry_block()->SetJoinId(stmt->ContinueId()); + if (stmt->next() != NULL && body_exit != NULL) { + set_current_block(body_exit); + Visit(stmt->next()); + CHECK_BAILOUT; + body_exit = current_block(); } - if (cond_graph != NULL) { - AppendPeeledWhile(stmt, - cond_graph->entry_block(), - exit_graph->exit_block(), - body_graph->exit_block(), - break_info.break_block()); - } else { - subgraph()->AppendEndless(stmt, - body_graph->entry_block(), - body_graph->exit_block(), + HBasicBlock* loop_exit = NULL; + if (stmt->cond() == NULL) { + loop_exit = CreateEndless(stmt, + loop_entry, + body_exit, break_info.break_block()); + } else { + loop_exit = CreateWhile(stmt, + loop_entry, + cond_false, + body_exit, + break_info.break_block()); } + set_current_block(loop_exit); } @@ -2937,9 +2850,9 @@ void HGraphBuilder::VisitConditional(Conditional* expr) { else_graph->entry_block()->SetJoinId(expr->ElseId()); ADD_TO_SUBGRAPH(else_graph, expr->else_expression()); - current_subgraph_->AppendJoin(then_graph->exit_block(), - else_graph->exit_block(), - expr->id()); + set_current_block(CreateJoin(then_graph->exit_block(), + else_graph->exit_block(), + expr->id())); ast_context()->ReturnValue(Pop()); } @@ -3317,7 +3230,8 @@ void HGraphBuilder::HandlePolymorphicStoreNamedField(Assignment* expr, HSubgraph* default_graph = CreateBranchSubgraph(environment()); { SubgraphScope scope(this, default_graph); if (!needs_generic && FLAG_deoptimize_uncommon_cases) { - default_graph->FinishExit(new HDeoptimize()); + default_graph->exit_block()->FinishExit(new HDeoptimize()); + default_graph->set_exit_block(NULL); } else { HInstruction* instr = BuildStoreNamedGeneric(object, name, value); Push(value); @@ -3604,7 +3518,8 @@ void HGraphBuilder::VisitThrow(Throw* expr) { instr->set_position(expr->position()); AddInstruction(instr); AddSimulate(expr->id()); - current_subgraph_->FinishExit(new HAbnormalExit); + current_block()->FinishExit(new HAbnormalExit); + set_current_block(NULL); } @@ -3652,7 +3567,8 @@ void HGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr, HSubgraph* default_graph = CreateBranchSubgraph(environment()); { SubgraphScope scope(this, default_graph); if (!needs_generic && FLAG_deoptimize_uncommon_cases) { - default_graph->FinishExit(new HDeoptimize()); + default_graph->exit_block()->FinishExit(new HDeoptimize()); + default_graph->set_exit_block(NULL); } else { HInstruction* instr = BuildLoadNamedGeneric(object, expr); instr->set_position(expr->position()); @@ -3853,9 +3769,11 @@ bool HGraphBuilder::TryArgumentsAccess(Property* expr) { HInstruction* elements = AddInstruction(new HArgumentsElements); result = new HArgumentsLength(elements); } else { + Push(graph()->GetArgumentsObject()); VisitForValue(expr->key()); if (HasStackOverflow()) return false; HValue* key = Pop(); + Drop(1); // Arguments object. HInstruction* elements = AddInstruction(new HArgumentsElements); HInstruction* length = AddInstruction(new HArgumentsLength(elements)); AddInstruction(new HBoundsCheck(key, length)); @@ -4010,7 +3928,8 @@ void HGraphBuilder::HandlePolymorphicCallNamed(Call* expr, HSubgraph* default_graph = CreateBranchSubgraph(environment()); { SubgraphScope scope(this, default_graph); if (!needs_generic && FLAG_deoptimize_uncommon_cases) { - default_graph->FinishExit(new HDeoptimize()); + default_graph->exit_block()->FinishExit(new HDeoptimize()); + default_graph->set_exit_block(NULL); } else { HContext* context = new HContext; AddInstruction(context); @@ -4091,6 +4010,8 @@ bool HGraphBuilder::TryInline(Call* expr) { !Scope::Analyze(&inner_info)) { if (Top::has_pending_exception()) { SetStackOverflow(); + // Stop trying to optimize and inline this function. + target->shared()->set_optimization_disabled(true); } return false; } @@ -4730,9 +4651,9 @@ void HGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { false_graph->exit_block()->last_environment()->Push( graph_->GetConstantFalse()); - current_subgraph_->AppendJoin(true_graph->exit_block(), - false_graph->exit_block(), - expr->id()); + set_current_block(CreateJoin(true_graph->exit_block(), + false_graph->exit_block(), + expr->id())); ast_context()->ReturnValue(Pop()); } else { ASSERT(ast_context()->IsEffect()); diff --git a/deps/v8/src/hydrogen.h b/deps/v8/src/hydrogen.h index e8c0b0630d..1ac4fc430e 100644 --- a/deps/v8/src/hydrogen.h +++ b/deps/v8/src/hydrogen.h @@ -117,6 +117,7 @@ class HBasicBlock: public ZoneObject { void SetJoinId(int id); void Finish(HControlInstruction* last); + void FinishExit(HControlInstruction* instruction); void Goto(HBasicBlock* block, bool include_stack_check = false); int PredecessorIndexOf(HBasicBlock* predecessor) const; @@ -206,34 +207,6 @@ class HSubgraph: public ZoneObject { exit_block_ = block; } - void PreProcessOsrEntry(IterationStatement* statement); - - void AppendJoin(HBasicBlock* first, HBasicBlock* second, int join_id); - void AppendWhile(IterationStatement* statement, - HBasicBlock* condition_entry, - HBasicBlock* exit_block, - HBasicBlock* body_exit, - HBasicBlock* break_block, - HBasicBlock* loop_entry, - HBasicBlock* loop_exit); - void AppendDoWhile(IterationStatement* statement, - HBasicBlock* body_entry, - HBasicBlock* go_back, - HBasicBlock* exit_block, - HBasicBlock* break_block); - void AppendEndless(IterationStatement* statement, - HBasicBlock* body_entry, - HBasicBlock* body_exit, - HBasicBlock* break_block); - void Append(BreakableStatement* stmt, - HBasicBlock* entry_block, - HBasicBlock* exit_block, - HBasicBlock* break_block); - void ResolveContinue(IterationStatement* statement, - HBasicBlock* continue_block); - HBasicBlock* JoinBlocks(HBasicBlock* a, HBasicBlock* b, int id); - - void FinishExit(HControlInstruction* instruction); void Initialize(HBasicBlock* block) { ASSERT(entry_block_ == NULL); entry_block_ = block; @@ -698,11 +671,29 @@ class HGraphBuilder: public AstVisitor { void Bailout(const char* reason); - void AppendPeeledWhile(IterationStatement* stmt, - HBasicBlock* condition_entry, - HBasicBlock* exit_block, - HBasicBlock* body_exit, - HBasicBlock* break_block); + void PreProcessOsrEntry(IterationStatement* statement); + + HBasicBlock* CreateJoin(HBasicBlock* first, + HBasicBlock* second, + int join_id); + HBasicBlock* CreateWhile(IterationStatement* statement, + HBasicBlock* loop_entry, + HBasicBlock* cond_false, + HBasicBlock* body_exit, + HBasicBlock* break_block); + HBasicBlock* CreateDoWhile(IterationStatement* statement, + HBasicBlock* body_entry, + HBasicBlock* go_back, + HBasicBlock* exit_block, + HBasicBlock* break_block); + HBasicBlock* CreateEndless(IterationStatement* statement, + HBasicBlock* body_entry, + HBasicBlock* body_exit, + HBasicBlock* break_block); + HBasicBlock* JoinContinue(IterationStatement* statement, + HBasicBlock* exit_block, + HBasicBlock* continue_block); + void AddToSubgraph(HSubgraph* graph, ZoneList* stmts); void AddToSubgraph(HSubgraph* graph, Statement* stmt); @@ -748,7 +739,7 @@ class HGraphBuilder: public AstVisitor { HSubgraph* CreateEmptySubgraph(); HSubgraph* CreateGotoSubgraph(HEnvironment* env); HSubgraph* CreateBranchSubgraph(HEnvironment* env); - HSubgraph* CreateLoopHeaderSubgraph(HEnvironment* env); + HBasicBlock* CreateLoopHeader(); HSubgraph* CreateInlinedSubgraph(HEnvironment* outer, Handle target, FunctionLiteral* function); diff --git a/deps/v8/src/ia32/code-stubs-ia32.cc b/deps/v8/src/ia32/code-stubs-ia32.cc index cb05c38247..7efa934086 100644 --- a/deps/v8/src/ia32/code-stubs-ia32.cc +++ b/deps/v8/src/ia32/code-stubs-ia32.cc @@ -3399,7 +3399,7 @@ void MathPowStub::Generate(MacroAssembler* masm) { __ test(edx, Immediate(kSmiTagMask)); __ j(not_zero, &base_nonsmi); - // Optimized version when both exponent and base is a smi. + // Optimized version when both exponent and base are smis. Label powi; __ SmiUntag(edx); __ cvtsi2sd(xmm0, Operand(edx)); @@ -3438,7 +3438,6 @@ void MathPowStub::Generate(MacroAssembler* masm) { __ j(not_carry, &no_multiply); __ mulsd(xmm1, xmm0); __ bind(&no_multiply); - __ test(eax, Operand(eax)); __ mulsd(xmm0, xmm0); __ j(not_zero, &while_true); @@ -3525,7 +3524,7 @@ void MathPowStub::Generate(MacroAssembler* masm) { __ AllocateHeapNumber(ecx, eax, edx, &call_runtime); __ movdbl(FieldOperand(ecx, HeapNumber::kValueOffset), xmm1); __ mov(eax, ecx); - __ ret(2); + __ ret(2 * kPointerSize); __ bind(&call_runtime); __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); diff --git a/deps/v8/src/ia32/codegen-ia32.cc b/deps/v8/src/ia32/codegen-ia32.cc index ae544dc63b..3a2753d27c 100644 --- a/deps/v8/src/ia32/codegen-ia32.cc +++ b/deps/v8/src/ia32/codegen-ia32.cc @@ -3526,7 +3526,8 @@ void CodeGenerator::DeclareGlobals(Handle pairs) { frame_->EmitPush(esi); // The context is the first argument. frame_->EmitPush(Immediate(pairs)); frame_->EmitPush(Immediate(Smi::FromInt(is_eval() ? 1 : 0))); - Result ignored = frame_->CallRuntime(Runtime::kDeclareGlobals, 3); + frame_->EmitPush(Immediate(Smi::FromInt(strict_mode_flag()))); + Result ignored = frame_->CallRuntime(Runtime::kDeclareGlobals, 4); // Return value is ignored. } @@ -5259,7 +5260,8 @@ void CodeGenerator::StoreToSlot(Slot* slot, InitState init_state) { // by initialization. value = frame_->CallRuntime(Runtime::kInitializeConstContextSlot, 3); } else { - value = frame_->CallRuntime(Runtime::kStoreContextSlot, 3); + frame_->Push(Smi::FromInt(strict_mode_flag())); + value = frame_->CallRuntime(Runtime::kStoreContextSlot, 4); } // Storing a variable must keep the (new) value on the expression // stack. This is necessary for compiling chained assignment @@ -5360,10 +5362,20 @@ void CodeGenerator::VisitVariableProxy(VariableProxy* node) { void CodeGenerator::VisitLiteral(Literal* node) { Comment cmnt(masm_, "[ Literal"); - if (in_safe_int32_mode()) { - frame_->PushUntaggedElement(node->handle()); + if (frame_->ConstantPoolOverflowed()) { + Result temp = allocator_->Allocate(); + ASSERT(temp.is_valid()); + if (in_safe_int32_mode()) { + temp.set_untagged_int32(true); + } + __ Set(temp.reg(), Immediate(node->handle())); + frame_->Push(&temp); } else { - frame_->Push(node->handle()); + if (in_safe_int32_mode()) { + frame_->PushUntaggedElement(node->handle()); + } else { + frame_->Push(node->handle()); + } } } @@ -5608,8 +5620,9 @@ void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { Load(property->key()); Load(property->value()); if (property->emit_store()) { + frame_->Push(Smi::FromInt(NONE)); // PropertyAttributes // Ignore the result. - Result ignored = frame_->CallRuntime(Runtime::kSetProperty, 3); + Result ignored = frame_->CallRuntime(Runtime::kSetProperty, 4); } else { frame_->Drop(3); } @@ -8300,6 +8313,7 @@ void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { switch (op) { case Token::SUB: { __ neg(value.reg()); + frame_->Push(&value); if (node->no_negative_zero()) { // -MIN_INT is MIN_INT with the overflow flag set. unsafe_bailout_->Branch(overflow); @@ -8312,17 +8326,18 @@ void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { } case Token::BIT_NOT: { __ not_(value.reg()); + frame_->Push(&value); break; } case Token::ADD: { // Unary plus has no effect on int32 values. + frame_->Push(&value); break; } default: UNREACHABLE(); break; } - frame_->Push(&value); } else { Load(node->expression()); bool can_overwrite = node->expression()->ResultOverwriteAllowed(); @@ -9458,11 +9473,13 @@ class DeferredReferenceSetKeyedValue: public DeferredCode { DeferredReferenceSetKeyedValue(Register value, Register key, Register receiver, - Register scratch) + Register scratch, + StrictModeFlag strict_mode) : value_(value), key_(key), receiver_(receiver), - scratch_(scratch) { + scratch_(scratch), + strict_mode_(strict_mode) { set_comment("[ DeferredReferenceSetKeyedValue"); } @@ -9476,6 +9493,7 @@ class DeferredReferenceSetKeyedValue: public DeferredCode { Register receiver_; Register scratch_; Label patch_site_; + StrictModeFlag strict_mode_; }; @@ -9534,7 +9552,9 @@ void DeferredReferenceSetKeyedValue::Generate() { } // Call the IC stub. - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + (strict_mode_ == kStrictMode) ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); __ call(ic, RelocInfo::CODE_TARGET); // The delta from the start of the map-compare instruction to the // test instruction. We use masm_-> directly here instead of the @@ -9896,7 +9916,8 @@ Result CodeGenerator::EmitKeyedStore(StaticType* key_type) { new DeferredReferenceSetKeyedValue(result.reg(), key.reg(), receiver.reg(), - tmp.reg()); + tmp.reg(), + strict_mode_flag()); // Check that the receiver is not a smi. __ test(receiver.reg(), Immediate(kSmiTagMask)); @@ -9951,7 +9972,7 @@ Result CodeGenerator::EmitKeyedStore(StaticType* key_type) { deferred->BindExit(); } else { - result = frame()->CallKeyedStoreIC(); + result = frame()->CallKeyedStoreIC(strict_mode_flag()); // Make sure that we do not have a test instruction after the // call. A test instruction after the call is used to // indicate that we have generated an inline version of the diff --git a/deps/v8/src/ia32/full-codegen-ia32.cc b/deps/v8/src/ia32/full-codegen-ia32.cc index 3cdca4c621..67e0e8fac9 100644 --- a/deps/v8/src/ia32/full-codegen-ia32.cc +++ b/deps/v8/src/ia32/full-codegen-ia32.cc @@ -322,23 +322,6 @@ void FullCodeGenerator::EmitReturnSequence() { } -FullCodeGenerator::ConstantOperand FullCodeGenerator::GetConstantOperand( - Token::Value op, Expression* left, Expression* right) { - ASSERT(ShouldInlineSmiCase(op)); - if (op == Token::DIV || op == Token::MOD || op == Token::MUL) { - // We never generate inlined constant smi operations for these. - return kNoConstants; - } else if (right->IsSmiLiteral()) { - return kRightConstant; - } else if (left->IsSmiLiteral() && !Token::IsShiftOp(op)) { - // Don't inline shifts with constant left hand side. - return kLeftConstant; - } else { - return kNoConstants; - } -} - - void FullCodeGenerator::EffectContext::Plug(Slot* slot) const { } @@ -548,7 +531,7 @@ void FullCodeGenerator::DoTest(Label* if_true, __ j(equal, if_true); __ cmp(result_register(), Factory::false_value()); __ j(equal, if_false); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); __ test(result_register(), Operand(result_register())); __ j(zero, if_false); __ test(result_register(), Immediate(kSmiTagMask)); @@ -655,6 +638,7 @@ void FullCodeGenerator::EmitDeclaration(Variable* variable, ASSERT(variable != NULL); // Must have been resolved. Slot* slot = variable->AsSlot(); Property* prop = variable->AsProperty(); + if (slot != NULL) { switch (slot->type()) { case Slot::PARAMETER: @@ -740,7 +724,9 @@ void FullCodeGenerator::EmitDeclaration(Variable* variable, prop->key()->AsLiteral()->handle()->IsSmi()); __ Set(ecx, Immediate(prop->key()->AsLiteral()->handle())); - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin(is_strict() + ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); } } @@ -757,7 +743,8 @@ void FullCodeGenerator::DeclareGlobals(Handle pairs) { __ push(esi); // The context is the first argument. __ push(Immediate(pairs)); __ push(Immediate(Smi::FromInt(is_eval() ? 1 : 0))); - __ CallRuntime(Runtime::kDeclareGlobals, 3); + __ push(Immediate(Smi::FromInt(strict_mode_flag()))); + __ CallRuntime(Runtime::kDeclareGlobals, 4); // Return value is ignored. } @@ -814,7 +801,6 @@ void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { SetSourcePosition(clause->position()); Handle ic = CompareIC::GetUninitialized(Token::EQ_STRICT); EmitCallIC(ic, &patch_site); - __ test(eax, Operand(eax)); __ j(not_equal, &next_test); __ Drop(1); // Switch value is no longer needed. @@ -895,7 +881,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { __ cmp(edx, Factory::empty_descriptor_array()); __ j(equal, &call_runtime); - // Check that there in an enum cache in the non-empty instance + // Check that there is an enum cache in the non-empty instance // descriptors (edx). This is the case if the next enumeration // index field does not contain a smi. __ mov(edx, FieldOperand(edx, DescriptorArray::kEnumerationIndexOffset)); @@ -1380,7 +1366,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForAccumulatorValue(value); __ mov(ecx, Immediate(key->handle())); __ mov(edx, Operand(esp, 0)); - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); PrepareForBailoutForId(key->id(), NO_REGISTERS); } else { @@ -1394,7 +1382,8 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(key); VisitForStackValue(value); if (property->emit_store()) { - __ CallRuntime(Runtime::kSetProperty, 3); + __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes + __ CallRuntime(Runtime::kSetProperty, 4); } else { __ Drop(3); } @@ -1572,14 +1561,8 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { } Token::Value op = expr->binary_op(); - ConstantOperand constant = ShouldInlineSmiCase(op) - ? GetConstantOperand(op, expr->target(), expr->value()) - : kNoConstants; - ASSERT(constant == kRightConstant || constant == kNoConstants); - if (constant == kNoConstants) { - __ push(eax); // Left operand goes on the stack. - VisitForAccumulatorValue(expr->value()); - } + __ push(eax); // Left operand goes on the stack. + VisitForAccumulatorValue(expr->value()); OverwriteMode mode = expr->value()->ResultOverwriteAllowed() ? OVERWRITE_RIGHT @@ -1591,8 +1574,7 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { op, mode, expr->target(), - expr->value(), - constant); + expr->value()); } else { EmitBinaryOp(op, mode); } @@ -1640,220 +1622,11 @@ void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { } -void FullCodeGenerator::EmitConstantSmiAdd(Expression* expr, - OverwriteMode mode, - bool left_is_constant_smi, - Smi* value) { - NearLabel call_stub, done; - // Optimistically add smi value with unknown object. If result overflows or is - // not a smi then we had either a smi overflow or added a smi with a tagged - // pointer. - __ add(Operand(eax), Immediate(value)); - __ j(overflow, &call_stub); - JumpPatchSite patch_site(masm_); - patch_site.EmitJumpIfSmi(eax, &done); - - // Undo the optimistic add operation and call the shared stub. - __ bind(&call_stub); - __ sub(Operand(eax), Immediate(value)); - TypeRecordingBinaryOpStub stub(Token::ADD, mode); - if (left_is_constant_smi) { - __ mov(edx, Immediate(value)); - } else { - __ mov(edx, eax); - __ mov(eax, Immediate(value)); - } - EmitCallIC(stub.GetCode(), &patch_site); - - __ bind(&done); - context()->Plug(eax); -} - - -void FullCodeGenerator::EmitConstantSmiSub(Expression* expr, - OverwriteMode mode, - bool left_is_constant_smi, - Smi* value) { - NearLabel call_stub, done; - // Optimistically subtract smi value with unknown object. If result overflows - // or is not a smi then we had either a smi overflow or added a smi with a - // tagged pointer. - if (left_is_constant_smi) { - __ mov(ecx, eax); - __ mov(eax, Immediate(value)); - __ sub(Operand(eax), ecx); - } else { - __ sub(Operand(eax), Immediate(value)); - } - __ j(overflow, &call_stub); - JumpPatchSite patch_site(masm_); - patch_site.EmitJumpIfSmi(eax, &done); - - __ bind(&call_stub); - if (left_is_constant_smi) { - __ mov(edx, Immediate(value)); - __ mov(eax, ecx); - } else { - __ add(Operand(eax), Immediate(value)); // Undo the subtraction. - __ mov(edx, eax); - __ mov(eax, Immediate(value)); - } - TypeRecordingBinaryOpStub stub(Token::SUB, mode); - EmitCallIC(stub.GetCode(), &patch_site); - - __ bind(&done); - context()->Plug(eax); -} - - -void FullCodeGenerator::EmitConstantSmiShiftOp(Expression* expr, - Token::Value op, - OverwriteMode mode, - Smi* value) { - NearLabel call_stub, smi_case, done; - int shift_value = value->value() & 0x1f; - - JumpPatchSite patch_site(masm_); - patch_site.EmitJumpIfSmi(eax, &smi_case); - - // Call stub. - __ bind(&call_stub); - __ mov(edx, eax); - __ mov(eax, Immediate(value)); - TypeRecordingBinaryOpStub stub(op, mode); - EmitCallIC(stub.GetCode(), &patch_site); - __ jmp(&done); - - // Smi case. - __ bind(&smi_case); - switch (op) { - case Token::SHL: - if (shift_value != 0) { - __ mov(edx, eax); - if (shift_value > 1) { - __ shl(edx, shift_value - 1); - } - // Convert int result to smi, checking that it is in int range. - STATIC_ASSERT(kSmiTagSize == 1); // Adjust code if not the case. - __ add(edx, Operand(edx)); - __ j(overflow, &call_stub); - __ mov(eax, edx); // Put result back into eax. - } - break; - case Token::SAR: - if (shift_value != 0) { - __ sar(eax, shift_value); - __ and_(eax, ~kSmiTagMask); - } - break; - case Token::SHR: - // SHR must return a positive value. When shifting by 0 or 1 we need to - // check that smi tagging the result will not create a negative value. - if (shift_value < 2) { - __ mov(edx, eax); - __ SmiUntag(edx); - __ shr(edx, shift_value); - __ test(edx, Immediate(0xc0000000)); - __ j(not_zero, &call_stub); - __ SmiTag(edx); - __ mov(eax, edx); // Put result back into eax. - } else { - __ SmiUntag(eax); - __ shr(eax, shift_value); - __ SmiTag(eax); - } - break; - default: - UNREACHABLE(); - } - - __ bind(&done); - context()->Plug(eax); -} - - -void FullCodeGenerator::EmitConstantSmiBitOp(Expression* expr, - Token::Value op, - OverwriteMode mode, - Smi* value) { - NearLabel smi_case, done; - - JumpPatchSite patch_site(masm_); - patch_site.EmitJumpIfSmi(eax, &smi_case); - - // The order of the arguments does not matter for bit-ops with a - // constant operand. - __ mov(edx, Immediate(value)); - TypeRecordingBinaryOpStub stub(op, mode); - EmitCallIC(stub.GetCode(), &patch_site); - __ jmp(&done); - - // Smi case. - __ bind(&smi_case); - switch (op) { - case Token::BIT_OR: - __ or_(Operand(eax), Immediate(value)); - break; - case Token::BIT_XOR: - __ xor_(Operand(eax), Immediate(value)); - break; - case Token::BIT_AND: - __ and_(Operand(eax), Immediate(value)); - break; - default: - UNREACHABLE(); - } - - __ bind(&done); - context()->Plug(eax); -} - - -void FullCodeGenerator::EmitConstantSmiBinaryOp(Expression* expr, - Token::Value op, - OverwriteMode mode, - bool left_is_constant_smi, - Smi* value) { - switch (op) { - case Token::BIT_OR: - case Token::BIT_XOR: - case Token::BIT_AND: - EmitConstantSmiBitOp(expr, op, mode, value); - break; - case Token::SHL: - case Token::SAR: - case Token::SHR: - ASSERT(!left_is_constant_smi); - EmitConstantSmiShiftOp(expr, op, mode, value); - break; - case Token::ADD: - EmitConstantSmiAdd(expr, mode, left_is_constant_smi, value); - break; - case Token::SUB: - EmitConstantSmiSub(expr, mode, left_is_constant_smi, value); - break; - default: - UNREACHABLE(); - } -} - - void FullCodeGenerator::EmitInlineSmiBinaryOp(Expression* expr, Token::Value op, OverwriteMode mode, Expression* left, - Expression* right, - ConstantOperand constant) { - if (constant == kRightConstant) { - Smi* value = Smi::cast(*right->AsLiteral()->handle()); - EmitConstantSmiBinaryOp(expr, op, mode, false, value); - return; - } else if (constant == kLeftConstant) { - Smi* value = Smi::cast(*left->AsLiteral()->handle()); - EmitConstantSmiBinaryOp(expr, op, mode, true, value); - return; - } - + Expression* right) { // Do combined smi check of the operands. Left operand is on the // stack. Right operand is in eax. NearLabel done, smi_case, stub_call; @@ -1985,7 +1758,9 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) { __ mov(edx, eax); __ pop(eax); // Restore value. __ mov(ecx, prop->key()->AsLiteral()->handle()); - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); break; } @@ -2006,7 +1781,9 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) { __ pop(edx); } __ pop(eax); // Restore value. - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); break; } @@ -2101,7 +1878,8 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, __ push(eax); // Value. __ push(esi); // Context. __ push(Immediate(var->name())); - __ CallRuntime(Runtime::kStoreContextSlot, 3); + __ push(Immediate(Smi::FromInt(strict_mode_flag()))); + __ CallRuntime(Runtime::kStoreContextSlot, 4); break; } } @@ -2132,7 +1910,9 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { } else { __ pop(edx); } - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); // If the assignment ends an initialization block, revert to fast case. @@ -2170,7 +1950,9 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { } // Record source code position before IC call. SetSourcePosition(expr->position()); - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); // If the assignment ends an initialization block, revert to fast case. @@ -2283,6 +2065,27 @@ void FullCodeGenerator::EmitCallWithStub(Call* expr) { } +void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, + int arg_count) { + // Push copy of the first argument or undefined if it doesn't exist. + if (arg_count > 0) { + __ push(Operand(esp, arg_count * kPointerSize)); + } else { + __ push(Immediate(Factory::undefined_value())); + } + + // Push the receiver of the enclosing function. + __ push(Operand(ebp, (2 + scope()->num_parameters()) * kPointerSize)); + + // Push the strict mode flag. + __ push(Immediate(Smi::FromInt(strict_mode_flag()))); + + __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP + ? Runtime::kResolvePossiblyDirectEvalNoLookup + : Runtime::kResolvePossiblyDirectEval, 4); +} + + void FullCodeGenerator::VisitCall(Call* expr) { #ifdef DEBUG // We want to verify that RecordJSReturnSite gets called on all paths @@ -2311,21 +2114,30 @@ void FullCodeGenerator::VisitCall(Call* expr) { VisitForStackValue(args->at(i)); } - // Push copy of the function - found below the arguments. - __ push(Operand(esp, (arg_count + 1) * kPointerSize)); - - // Push copy of the first argument or undefined if it doesn't exist. - if (arg_count > 0) { - __ push(Operand(esp, arg_count * kPointerSize)); - } else { - __ push(Immediate(Factory::undefined_value())); + // If we know that eval can only be shadowed by eval-introduced + // variables we attempt to load the global eval function directly + // in generated code. If we succeed, there is no need to perform a + // context lookup in the runtime system. + Label done; + if (var->AsSlot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) { + Label slow; + EmitLoadGlobalSlotCheckExtensions(var->AsSlot(), + NOT_INSIDE_TYPEOF, + &slow); + // Push the function and resolve eval. + __ push(eax); + EmitResolvePossiblyDirectEval(SKIP_CONTEXT_LOOKUP, arg_count); + __ jmp(&done); + __ bind(&slow); } - // Push the receiver of the enclosing function and do runtime call. - __ push(Operand(ebp, (2 + scope()->num_parameters()) * kPointerSize)); - // Push the strict mode flag. - __ push(Immediate(Smi::FromInt(strict_mode_flag()))); - __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4); + // Push copy of the function (found below the arguments) and + // resolve eval. + __ push(Operand(esp, (arg_count + 1) * kPointerSize)); + EmitResolvePossiblyDirectEval(PERFORM_CONTEXT_LOOKUP, arg_count); + if (done.is_linked()) { + __ bind(&done); + } // The runtime call returns a pair of values in eax (function) and // edx (receiver). Touch up the stack with the right values. @@ -2390,7 +2202,9 @@ void FullCodeGenerator::VisitCall(Call* expr) { Literal* key = prop->key()->AsLiteral(); if (key != NULL && key->handle()->IsSymbol()) { // Call to a named property, use call IC. - VisitForStackValue(prop->obj()); + { PreservePositionScope scope(masm()->positions_recorder()); + VisitForStackValue(prop->obj()); + } EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET); } else { // Call to a keyed property. @@ -3401,7 +3215,6 @@ void FullCodeGenerator::EmitHasCachedArrayIndex(ZoneList* args) { void FullCodeGenerator::EmitGetCachedArrayIndex(ZoneList* args) { ASSERT(args->length() == 1); - VisitForAccumulatorValue(args->at(0)); if (FLAG_debug_code) { @@ -3417,7 +3230,7 @@ void FullCodeGenerator::EmitGetCachedArrayIndex(ZoneList* args) { void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { Label bailout, done, one_char_separator, long_separator, - non_trivial_array, not_size_one_array, loop, loop_condition, + non_trivial_array, not_size_one_array, loop, loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry; ASSERT(args->length() == 2); @@ -3459,7 +3272,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { // If the array has length zero, return the empty string. __ mov(array_length, FieldOperand(array, JSArray::kLengthOffset)); - __ sar(array_length, 1); + __ SmiUntag(array_length); __ j(not_zero, &non_trivial_array); __ mov(result_operand, Factory::empty_string()); __ jmp(&done); @@ -3482,14 +3295,15 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { // Loop condition: while (index < length). // Live loop registers: index, array_length, string, // scratch, string_length, elements. - __ jmp(&loop_condition); + if (FLAG_debug_code) { + __ cmp(index, Operand(array_length)); + __ Assert(less, "No empty arrays here in EmitFastAsciiArrayJoin"); + } __ bind(&loop); - __ cmp(index, Operand(array_length)); - __ j(greater_equal, &done); - - __ mov(string, FieldOperand(elements, index, - times_pointer_size, - FixedArray::kHeaderSize)); + __ mov(string, FieldOperand(elements, + index, + times_pointer_size, + FixedArray::kHeaderSize)); __ test(string, Immediate(kSmiTagMask)); __ j(zero, &bailout); __ mov(scratch, FieldOperand(string, HeapObject::kMapOffset)); @@ -3502,7 +3316,6 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { FieldOperand(string, SeqAsciiString::kLengthOffset)); __ j(overflow, &bailout); __ add(Operand(index), Immediate(1)); - __ bind(&loop_condition); __ cmp(index, Operand(array_length)); __ j(less, &loop); @@ -3531,7 +3344,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); __ and_(scratch, Immediate( kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask)); - __ cmp(scratch, kStringTag | kAsciiStringTag | kSeqStringTag); + __ cmp(scratch, ASCII_STRING_TYPE); __ j(not_equal, &bailout); // Add (separator length times array_length) - separator length @@ -3791,6 +3604,7 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { Label* if_true = NULL; Label* if_false = NULL; Label* fall_through = NULL; + // Notice that the labels are swapped. context()->PrepareTest(&materialize_true, &materialize_false, &if_false, &if_true, &fall_through); @@ -4023,7 +3837,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case NAMED_PROPERTY: { __ mov(ecx, prop->key()->AsLiteral()->handle()); __ pop(edx); - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); if (expr->is_postfix()) { @@ -4038,7 +3854,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case KEYED_PROPERTY: { __ pop(ecx); __ pop(edx); - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); if (expr->is_postfix()) { @@ -4386,6 +4204,22 @@ void FullCodeGenerator::EmitCallIC(Handle ic, RelocInfo::Mode mode) { void FullCodeGenerator::EmitCallIC(Handle ic, JumpPatchSite* patch_site) { + switch (ic->kind()) { + case Code::LOAD_IC: + __ IncrementCounter(&Counters::named_load_full, 1); + break; + case Code::KEYED_LOAD_IC: + __ IncrementCounter(&Counters::keyed_load_full, 1); + break; + case Code::STORE_IC: + __ IncrementCounter(&Counters::named_store_full, 1); + break; + case Code::KEYED_STORE_IC: + __ IncrementCounter(&Counters::keyed_store_full, 1); + default: + break; + } + __ call(ic, RelocInfo::CODE_TARGET); if (patch_site != NULL && patch_site->is_bound()) { patch_site->EmitPatchInfo(); diff --git a/deps/v8/src/ia32/ic-ia32.cc b/deps/v8/src/ia32/ic-ia32.cc index 73cd60df56..6b9e749629 100644 --- a/deps/v8/src/ia32/ic-ia32.cc +++ b/deps/v8/src/ia32/ic-ia32.cc @@ -761,7 +761,8 @@ void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) { } -void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { +void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, + StrictModeFlag strict_mode) { // ----------- S t a t e ------------- // -- eax : value // -- ecx : key @@ -801,7 +802,7 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { // Slow case: call runtime. __ bind(&slow); - GenerateRuntimeSetProperty(masm); + GenerateRuntimeSetProperty(masm, strict_mode); // Check whether the elements is a pixel array. __ bind(&check_pixel_array); @@ -1488,7 +1489,7 @@ void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { void StoreIC::GenerateMegamorphic(MacroAssembler* masm, - Code::ExtraICState extra_ic_state) { + StrictModeFlag strict_mode) { // ----------- S t a t e ------------- // -- eax : value // -- ecx : name @@ -1499,7 +1500,7 @@ void StoreIC::GenerateMegamorphic(MacroAssembler* masm, Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, NOT_IN_LOOP, MONOMORPHIC, - extra_ic_state); + strict_mode); StubCache::GenerateProbe(masm, flags, edx, ecx, ebx, no_reg); // Cache miss: Jump to runtime. @@ -1617,7 +1618,8 @@ void StoreIC::GenerateNormal(MacroAssembler* masm) { } -void StoreIC::GenerateGlobalProxy(MacroAssembler* masm) { +void StoreIC::GenerateGlobalProxy(MacroAssembler* masm, + StrictModeFlag strict_mode) { // ----------- S t a t e ------------- // -- eax : value // -- ecx : name @@ -1628,14 +1630,17 @@ void StoreIC::GenerateGlobalProxy(MacroAssembler* masm) { __ push(edx); __ push(ecx); __ push(eax); - __ push(ebx); + __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes + __ push(Immediate(Smi::FromInt(strict_mode))); + __ push(ebx); // return address // Do tail-call to runtime routine. - __ TailCallRuntime(Runtime::kSetProperty, 3, 1); + __ TailCallRuntime(Runtime::kSetProperty, 5, 1); } -void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm) { +void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, + StrictModeFlag strict_mode) { // ----------- S t a t e ------------- // -- eax : value // -- ecx : key @@ -1647,10 +1652,12 @@ void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm) { __ push(edx); __ push(ecx); __ push(eax); - __ push(ebx); + __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes + __ push(Immediate(Smi::FromInt(strict_mode))); // Strict mode. + __ push(ebx); // return address // Do tail-call to runtime routine. - __ TailCallRuntime(Runtime::kSetProperty, 3, 1); + __ TailCallRuntime(Runtime::kSetProperty, 5, 1); } diff --git a/deps/v8/src/ia32/lithium-codegen-ia32.cc b/deps/v8/src/ia32/lithium-codegen-ia32.cc index d61ebdc0f6..0b345d31ad 100644 --- a/deps/v8/src/ia32/lithium-codegen-ia32.cc +++ b/deps/v8/src/ia32/lithium-codegen-ia32.cc @@ -127,7 +127,7 @@ bool LCodeGen::GenerateRelocPadding() { int reloc_size = masm()->relocation_writer_size(); while (reloc_size < deoptimization_reloc_size.min_size) { __ RecordComment(RelocInfo::kFillerCommentString, true); - reloc_size += RelocInfo::kRelocCommentSize; + reloc_size += RelocInfo::kMinRelocCommentSize; } return !is_aborted(); } @@ -588,7 +588,8 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { Handle data = Factory::NewDeoptimizationInputData(length, TENURED); - data->SetTranslationByteArray(*translations_.CreateByteArray()); + Handle translations = translations_.CreateByteArray(); + data->SetTranslationByteArray(*translations); data->SetInlinedFunctionCount(Smi::FromInt(inlined_function_count_)); Handle literals = @@ -1912,12 +1913,7 @@ void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, __ bind(&before_push_delta); __ mov(temp, Immediate(delta)); __ StoreToSafepointRegisterSlot(temp, temp); - __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); - __ call(stub.GetCode(), RelocInfo::CODE_TARGET); - ASSERT_EQ(kAdditionalDelta, - masm_->SizeOfCodeGeneratedSince(&before_push_delta)); - RecordSafepointWithRegisters( - instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); + CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr, false); // Put the result value into the eax slot and restore all registers. __ StoreToSafepointRegisterSlot(eax, eax); __ PopSafepointRegisters(); @@ -2786,7 +2782,9 @@ void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { ASSERT(ToRegister(instr->value()).is(eax)); __ mov(ecx, instr->name()); - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + info_->is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -2854,7 +2852,9 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { ASSERT(ToRegister(instr->key()).is(ecx)); ASSERT(ToRegister(instr->value()).is(eax)); - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + info_->is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); CallCode(ic, RelocInfo::CODE_TARGET, instr); } diff --git a/deps/v8/src/ia32/lithium-ia32.cc b/deps/v8/src/ia32/lithium-ia32.cc index 221a7aa154..ea6d41aa14 100644 --- a/deps/v8/src/ia32/lithium-ia32.cc +++ b/deps/v8/src/ia32/lithium-ia32.cc @@ -870,10 +870,18 @@ LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, ASSERT(instr->representation().IsDouble()); ASSERT(instr->left()->representation().IsDouble()); ASSERT(instr->right()->representation().IsDouble()); - LOperand* left = UseRegisterAtStart(instr->left()); - LOperand* right = UseRegisterAtStart(instr->right()); - LArithmeticD* result = new LArithmeticD(op, left, right); - return DefineSameAsFirst(result); + if (op == Token::MOD) { + LOperand* left = UseFixedDouble(instr->left(), xmm2); + LOperand* right = UseFixedDouble(instr->right(), xmm1); + LArithmeticD* result = new LArithmeticD(op, left, right); + return MarkAsCall(DefineFixedDouble(result, xmm1), instr); + + } else { + LOperand* left = UseRegisterAtStart(instr->left()); + LOperand* right = UseRegisterAtStart(instr->right()); + LArithmeticD* result = new LArithmeticD(op, left, right); + return DefineSameAsFirst(result); + } } @@ -1165,8 +1173,7 @@ LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal( new LInstanceOfKnownGlobal( UseFixed(instr->value(), InstanceofStub::left()), FixedTemp(edi)); - MarkAsSaveDoubles(result); - return AssignEnvironment(AssignPointerMap(DefineFixed(result, eax))); + return MarkAsCall(DefineFixed(result, eax), instr); } diff --git a/deps/v8/src/ia32/stub-cache-ia32.cc b/deps/v8/src/ia32/stub-cache-ia32.cc index 51cc46a08e..633097af66 100644 --- a/deps/v8/src/ia32/stub-cache-ia32.cc +++ b/deps/v8/src/ia32/stub-cache-ia32.cc @@ -2552,12 +2552,13 @@ MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, __ push(edx); // receiver __ push(ecx); // name __ push(eax); // value + __ push(Immediate(Smi::FromInt(strict_mode_))); __ push(ebx); // restore return address // Do tail-call to the runtime system. ExternalReference store_ic_property = ExternalReference(IC_Utility(IC::kStoreInterceptorProperty)); - __ TailCallExternalReference(store_ic_property, 3, 1); + __ TailCallExternalReference(store_ic_property, 4, 1); // Handle store cache miss. __ bind(&miss); @@ -3712,10 +3713,13 @@ MaybeObject* ExternalArrayStubCompiler::CompileKeyedStoreStub( __ push(edx); __ push(ecx); __ push(eax); - __ push(ebx); + __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes + __ push(Immediate(Smi::FromInt( + Code::ExtractExtraICStateFromFlags(flags) & kStrictMode))); + __ push(ebx); // return address // Do tail-call to runtime routine. - __ TailCallRuntime(Runtime::kSetProperty, 3, 1); + __ TailCallRuntime(Runtime::kSetProperty, 5, 1); return GetCode(flags); } diff --git a/deps/v8/src/ia32/virtual-frame-ia32.cc b/deps/v8/src/ia32/virtual-frame-ia32.cc index 1cc91a9fea..93d711e936 100644 --- a/deps/v8/src/ia32/virtual-frame-ia32.cc +++ b/deps/v8/src/ia32/virtual-frame-ia32.cc @@ -1038,9 +1038,9 @@ Result VirtualFrame::CallStoreIC(Handle name, StrictModeFlag strict_mode) { // Value and (if not contextual) receiver are on top of the frame. // The IC expects name in ecx, value in eax, and receiver in edx. - Handle ic(Builtins::builtin(strict_mode == kStrictMode - ? Builtins::StoreIC_Initialize_Strict - : Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + (strict_mode == kStrictMode) ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); Result value = Pop(); RelocInfo::Mode mode; @@ -1061,7 +1061,7 @@ Result VirtualFrame::CallStoreIC(Handle name, } -Result VirtualFrame::CallKeyedStoreIC() { +Result VirtualFrame::CallKeyedStoreIC(StrictModeFlag strict_mode) { // Value, key, and receiver are on the top of the frame. The IC // expects value in eax, key in ecx, and receiver in edx. Result value = Pop(); @@ -1105,7 +1105,9 @@ Result VirtualFrame::CallKeyedStoreIC() { receiver.Unuse(); } - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + (strict_mode == kStrictMode) ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); } @@ -1306,6 +1308,7 @@ void VirtualFrame::EmitPush(Immediate immediate, TypeInfo info) { void VirtualFrame::PushUntaggedElement(Handle value) { + ASSERT(!ConstantPoolOverflowed()); elements_.Add(FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED)); elements_[element_count() - 1].set_untagged_int32(true); } @@ -1336,6 +1339,20 @@ void VirtualFrame::Push(Expression* expr) { } +void VirtualFrame::Push(Handle value) { + if (ConstantPoolOverflowed()) { + Result temp = cgen()->allocator()->Allocate(); + ASSERT(temp.is_valid()); + __ Set(temp.reg(), Immediate(value)); + Push(&temp); + } else { + FrameElement element = + FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED); + elements_.Add(element); + } +} + + #undef __ } } // namespace v8::internal diff --git a/deps/v8/src/ia32/virtual-frame-ia32.h b/deps/v8/src/ia32/virtual-frame-ia32.h index 729469fdcc..51874309d5 100644 --- a/deps/v8/src/ia32/virtual-frame-ia32.h +++ b/deps/v8/src/ia32/virtual-frame-ia32.h @@ -370,7 +370,7 @@ class VirtualFrame: public ZoneObject { // Call keyed store IC. Value, key, and receiver are found on top // of the frame. All three are dropped. - Result CallKeyedStoreIC(); + Result CallKeyedStoreIC(StrictModeFlag strict_mode); // Call call IC. Function name, arguments, and receiver are found on top // of the frame and dropped by the call. The argument count does not @@ -419,9 +419,11 @@ class VirtualFrame: public ZoneObject { void EmitPush(Immediate immediate, TypeInfo info = TypeInfo::Unknown()); + inline bool ConstantPoolOverflowed(); + // Push an element on the virtual frame. + void Push(Handle value); inline void Push(Register reg, TypeInfo info = TypeInfo::Unknown()); - inline void Push(Handle value); inline void Push(Smi* value); void PushUntaggedElement(Handle value); diff --git a/deps/v8/src/ic-inl.h b/deps/v8/src/ic-inl.h index 8fbc18436d..9d358eddb3 100644 --- a/deps/v8/src/ic-inl.h +++ b/deps/v8/src/ic-inl.h @@ -76,6 +76,15 @@ Code* IC::GetTargetAtAddress(Address address) { void IC::SetTargetAtAddress(Address address, Code* target) { ASSERT(target->is_inline_cache_stub() || target->is_compare_ic_stub()); +#ifdef DEBUG + // STORE_IC and KEYED_STORE_IC use Code::extra_ic_state() to mark + // ICs as strict mode. The strict-ness of the IC must be preserved. + Code* old_target = GetTargetAtAddress(address); + if (old_target->kind() == Code::STORE_IC || + old_target->kind() == Code::KEYED_STORE_IC) { + ASSERT(old_target->extra_ic_state() == target->extra_ic_state()); + } +#endif Assembler::set_target_address_at(address, target->instruction_start()); } diff --git a/deps/v8/src/ic.cc b/deps/v8/src/ic.cc index 7482830ae0..2d666d6e8b 100644 --- a/deps/v8/src/ic.cc +++ b/deps/v8/src/ic.cc @@ -343,7 +343,7 @@ void StoreIC::Clear(Address address, Code* target) { if (target->ic_state() == UNINITIALIZED) return; ClearInlinedVersion(address); SetTargetAtAddress(address, - target->extra_ic_state() == kStoreICStrict + (target->extra_ic_state() == kStrictMode) ? initialize_stub_strict() : initialize_stub()); } @@ -366,7 +366,10 @@ void KeyedStoreIC::RestoreInlinedVersion(Address address) { void KeyedStoreIC::Clear(Address address, Code* target) { if (target->ic_state() == UNINITIALIZED) return; - SetTargetAtAddress(address, initialize_stub()); + SetTargetAtAddress(address, + (target->extra_ic_state() == kStrictMode) + ? initialize_stub_strict() + : initialize_stub()); } @@ -804,6 +807,7 @@ MaybeObject* KeyedCallIC::LoadFunction(State state, HandleScope scope; Handle result = GetProperty(object, key); + RETURN_IF_EMPTY_HANDLE(result); // Make receiver an object if the callee requires it. Strict mode or builtin // functions do not wrap the receiver, non-strict functions and objects @@ -1226,7 +1230,8 @@ MaybeObject* KeyedLoadIC::Load(State state, if (receiver->HasExternalArrayElements()) { MaybeObject* probe = StubCache::ComputeKeyedLoadOrStoreExternalArray(*receiver, - false); + false, + kNonStrictMode); stub = probe->IsFailure() ? NULL : Code::cast(probe->ToObjectUnchecked()); } else if (receiver->HasIndexedInterceptor()) { @@ -1382,7 +1387,7 @@ static bool LookupForWrite(JSObject* object, MaybeObject* StoreIC::Store(State state, - Code::ExtraICState extra_ic_state, + StrictModeFlag strict_mode, Handle object, Handle name, Handle value) { @@ -1412,11 +1417,11 @@ MaybeObject* StoreIC::Store(State state, #ifdef DEBUG if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); #endif - Builtins::Name target = (extra_ic_state == kStoreICStrict) + Builtins::Name target = (strict_mode == kStrictMode) ? Builtins::StoreIC_ArrayLength_Strict : Builtins::StoreIC_ArrayLength; set_target(Builtins::builtin(target)); - return receiver->SetProperty(*name, *value, NONE); + return receiver->SetProperty(*name, *value, NONE, strict_mode); } // Lookup the property locally in the receiver. @@ -1440,13 +1445,15 @@ MaybeObject* StoreIC::Store(State state, // Index is an offset from the end of the object. int offset = map->instance_size() + (index * kPointerSize); if (PatchInlinedStore(address(), map, offset)) { - set_target(megamorphic_stub()); + set_target((strict_mode == kStrictMode) + ? megamorphic_stub_strict() + : megamorphic_stub()); #ifdef DEBUG if (FLAG_trace_ic) { PrintF("[StoreIC : inline patch %s]\n", *name->ToCString()); } #endif - return receiver->SetProperty(*name, *value, NONE); + return receiver->SetProperty(*name, *value, NONE, strict_mode); #ifdef DEBUG } else { @@ -1473,11 +1480,16 @@ MaybeObject* StoreIC::Store(State state, // If no inlined store ic was patched, generate a stub for this // store. - UpdateCaches(&lookup, state, extra_ic_state, receiver, name, value); + UpdateCaches(&lookup, state, strict_mode, receiver, name, value); } else { - // Strict mode doesn't allow setting non-existent global property. - if (extra_ic_state == kStoreICStrict && IsContextual(object)) { - return ReferenceError("not_defined", name); + // Strict mode doesn't allow setting non-existent global property + // or an assignment to a read only property. + if (strict_mode == kStrictMode) { + if (lookup.IsFound() && lookup.IsReadOnly()) { + return TypeError("strict_read_only_property", object, name); + } else if (IsContextual(object)) { + return ReferenceError("not_defined", name); + } } } } @@ -1485,7 +1497,7 @@ MaybeObject* StoreIC::Store(State state, if (receiver->IsJSGlobalProxy()) { // Generate a generic stub that goes to the runtime when we see a global // proxy as receiver. - Code* stub = (extra_ic_state == kStoreICStrict) + Code* stub = (strict_mode == kStrictMode) ? global_proxy_stub_strict() : global_proxy_stub(); if (target() != stub) { @@ -1497,13 +1509,13 @@ MaybeObject* StoreIC::Store(State state, } // Set the property. - return receiver->SetProperty(*name, *value, NONE); + return receiver->SetProperty(*name, *value, NONE, strict_mode); } void StoreIC::UpdateCaches(LookupResult* lookup, State state, - Code::ExtraICState extra_ic_state, + StrictModeFlag strict_mode, Handle receiver, Handle name, Handle value) { @@ -1525,7 +1537,7 @@ void StoreIC::UpdateCaches(LookupResult* lookup, switch (type) { case FIELD: { maybe_code = StubCache::ComputeStoreField( - *name, *receiver, lookup->GetFieldIndex(), NULL, extra_ic_state); + *name, *receiver, lookup->GetFieldIndex(), NULL, strict_mode); break; } case MAP_TRANSITION: { @@ -1535,7 +1547,7 @@ void StoreIC::UpdateCaches(LookupResult* lookup, Handle transition(lookup->GetTransitionMap()); int index = transition->PropertyIndexFor(*name); maybe_code = StubCache::ComputeStoreField( - *name, *receiver, index, *transition, extra_ic_state); + *name, *receiver, index, *transition, strict_mode); break; } case NORMAL: { @@ -1547,10 +1559,10 @@ void StoreIC::UpdateCaches(LookupResult* lookup, JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(global->GetPropertyCell(lookup)); maybe_code = StubCache::ComputeStoreGlobal( - *name, *global, cell, extra_ic_state); + *name, *global, cell, strict_mode); } else { if (lookup->holder() != *receiver) return; - maybe_code = StubCache::ComputeStoreNormal(extra_ic_state); + maybe_code = StubCache::ComputeStoreNormal(strict_mode); } break; } @@ -1559,13 +1571,13 @@ void StoreIC::UpdateCaches(LookupResult* lookup, AccessorInfo* callback = AccessorInfo::cast(lookup->GetCallbackObject()); if (v8::ToCData
(callback->setter()) == 0) return; maybe_code = StubCache::ComputeStoreCallback( - *name, *receiver, callback, extra_ic_state); + *name, *receiver, callback, strict_mode); break; } case INTERCEPTOR: { ASSERT(!receiver->GetNamedInterceptor()->setter()->IsUndefined()); maybe_code = StubCache::ComputeStoreInterceptor( - *name, *receiver, extra_ic_state); + *name, *receiver, strict_mode); break; } default: @@ -1582,7 +1594,7 @@ void StoreIC::UpdateCaches(LookupResult* lookup, } else if (state == MONOMORPHIC) { // Only move to megamorphic if the target changes. if (target() != Code::cast(code)) { - set_target(extra_ic_state == kStoreICStrict + set_target((strict_mode == kStrictMode) ? megamorphic_stub_strict() : megamorphic_stub()); } @@ -1598,6 +1610,7 @@ void StoreIC::UpdateCaches(LookupResult* lookup, MaybeObject* KeyedStoreIC::Store(State state, + StrictModeFlag strict_mode, Handle object, Handle key, Handle value) { @@ -1629,11 +1642,11 @@ MaybeObject* KeyedStoreIC::Store(State state, // Update inline cache and stub cache. if (FLAG_use_ic) { - UpdateCaches(&lookup, state, receiver, name, value); + UpdateCaches(&lookup, state, strict_mode, receiver, name, value); } // Set the property. - return receiver->SetProperty(*name, *value, NONE); + return receiver->SetProperty(*name, *value, NONE, strict_mode); } // Do not use ICs for objects that require access checks (including @@ -1642,23 +1655,25 @@ MaybeObject* KeyedStoreIC::Store(State state, ASSERT(!(use_ic && object->IsJSGlobalProxy())); if (use_ic) { - Code* stub = generic_stub(); + Code* stub = + (strict_mode == kStrictMode) ? generic_stub_strict() : generic_stub(); if (state == UNINITIALIZED) { if (object->IsJSObject()) { Handle receiver = Handle::cast(object); if (receiver->HasExternalArrayElements()) { MaybeObject* probe = - StubCache::ComputeKeyedLoadOrStoreExternalArray(*receiver, true); + StubCache::ComputeKeyedLoadOrStoreExternalArray( + *receiver, true, strict_mode); stub = probe->IsFailure() ? NULL : Code::cast(probe->ToObjectUnchecked()); } else if (receiver->HasPixelElements()) { MaybeObject* probe = - StubCache::ComputeKeyedStorePixelArray(*receiver); + StubCache::ComputeKeyedStorePixelArray(*receiver, strict_mode); stub = probe->IsFailure() ? NULL : Code::cast(probe->ToObjectUnchecked()); } else if (key->IsSmi() && receiver->map()->has_fast_elements()) { MaybeObject* probe = - StubCache::ComputeKeyedStoreSpecialized(*receiver); + StubCache::ComputeKeyedStoreSpecialized(*receiver, strict_mode); stub = probe->IsFailure() ? NULL : Code::cast(probe->ToObjectUnchecked()); } @@ -1668,12 +1683,13 @@ MaybeObject* KeyedStoreIC::Store(State state, } // Set the property. - return Runtime::SetObjectProperty(object, key, value, NONE); + return Runtime::SetObjectProperty(object, key, value, NONE, strict_mode); } void KeyedStoreIC::UpdateCaches(LookupResult* lookup, State state, + StrictModeFlag strict_mode, Handle receiver, Handle name, Handle value) { @@ -1700,8 +1716,8 @@ void KeyedStoreIC::UpdateCaches(LookupResult* lookup, switch (type) { case FIELD: { - maybe_code = StubCache::ComputeKeyedStoreField(*name, *receiver, - lookup->GetFieldIndex()); + maybe_code = StubCache::ComputeKeyedStoreField( + *name, *receiver, lookup->GetFieldIndex(), NULL, strict_mode); break; } case MAP_TRANSITION: { @@ -1710,8 +1726,8 @@ void KeyedStoreIC::UpdateCaches(LookupResult* lookup, ASSERT(type == MAP_TRANSITION); Handle transition(lookup->GetTransitionMap()); int index = transition->PropertyIndexFor(*name); - maybe_code = StubCache::ComputeKeyedStoreField(*name, *receiver, - index, *transition); + maybe_code = StubCache::ComputeKeyedStoreField( + *name, *receiver, index, *transition, strict_mode); break; } // fall through. @@ -1719,7 +1735,9 @@ void KeyedStoreIC::UpdateCaches(LookupResult* lookup, default: { // Always rewrite to the generic case so that we do not // repeatedly try to rewrite. - maybe_code = generic_stub(); + maybe_code = (strict_mode == kStrictMode) + ? generic_stub_strict() + : generic_stub(); break; } } @@ -1734,7 +1752,9 @@ void KeyedStoreIC::UpdateCaches(LookupResult* lookup, if (state == UNINITIALIZED || state == PREMONOMORPHIC) { set_target(Code::cast(code)); } else if (state == MONOMORPHIC) { - set_target(megamorphic_stub()); + set_target((strict_mode == kStrictMode) + ? megamorphic_stub_strict() + : megamorphic_stub()); } #ifdef DEBUG @@ -1835,8 +1855,11 @@ MUST_USE_RESULT MaybeObject* StoreIC_Miss(Arguments args) { StoreIC ic; IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); - return ic.Store(state, extra_ic_state, args.at(0), - args.at(1), args.at(2)); + return ic.Store(state, + static_cast(extra_ic_state & kStrictMode), + args.at(0), + args.at(1), + args.at(2)); } @@ -1900,7 +1923,11 @@ MUST_USE_RESULT MaybeObject* KeyedStoreIC_Miss(Arguments args) { ASSERT(args.length() == 3); KeyedStoreIC ic; IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); - return ic.Store(state, args.at(0), args.at(1), + Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); + return ic.Store(state, + static_cast(extra_ic_state & kStrictMode), + args.at(0), + args.at(1), args.at(2)); } diff --git a/deps/v8/src/ic.h b/deps/v8/src/ic.h index 96838c7338..e12cbaf8ef 100644 --- a/deps/v8/src/ic.h +++ b/deps/v8/src/ic.h @@ -398,16 +398,10 @@ class KeyedLoadIC: public IC { class StoreIC: public IC { public: - - enum StoreICStrictMode { - kStoreICNonStrict = kNonStrictMode, - kStoreICStrict = kStrictMode - }; - StoreIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_store_stub()); } MUST_USE_RESULT MaybeObject* Store(State state, - Code::ExtraICState extra_ic_state, + StrictModeFlag strict_mode, Handle object, Handle name, Handle value); @@ -416,10 +410,11 @@ class StoreIC: public IC { static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } static void GenerateMiss(MacroAssembler* masm); static void GenerateMegamorphic(MacroAssembler* masm, - Code::ExtraICState extra_ic_state); + StrictModeFlag strict_mode); static void GenerateArrayLength(MacroAssembler* masm); static void GenerateNormal(MacroAssembler* masm); - static void GenerateGlobalProxy(MacroAssembler* masm); + static void GenerateGlobalProxy(MacroAssembler* masm, + StrictModeFlag strict_mode); // Clear the use of an inlined version. static void ClearInlinedVersion(Address address); @@ -433,11 +428,18 @@ class StoreIC: public IC { // lookup result. void UpdateCaches(LookupResult* lookup, State state, - Code::ExtraICState extra_ic_state, + StrictModeFlag strict_mode, Handle receiver, Handle name, Handle value); + void set_target(Code* code) { + // Strict mode must be preserved across IC patching. + ASSERT((code->extra_ic_state() & kStrictMode) == + (target()->extra_ic_state() & kStrictMode)); + IC::set_target(code); + } + // Stub accessors. static Code* megamorphic_stub() { return Builtins::builtin(Builtins::StoreIC_Megamorphic); @@ -473,6 +475,7 @@ class KeyedStoreIC: public IC { KeyedStoreIC() : IC(NO_EXTRA_FRAME) { } MUST_USE_RESULT MaybeObject* Store(State state, + StrictModeFlag strict_mode, Handle object, Handle name, Handle value); @@ -480,8 +483,9 @@ class KeyedStoreIC: public IC { // Code generators for stub routines. Only called once at startup. static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } static void GenerateMiss(MacroAssembler* masm); - static void GenerateRuntimeSetProperty(MacroAssembler* masm); - static void GenerateGeneric(MacroAssembler* masm); + static void GenerateRuntimeSetProperty(MacroAssembler* masm, + StrictModeFlag strict_mode); + static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); // Clear the inlined version so the IC is always hit. static void ClearInlinedVersion(Address address); @@ -493,20 +497,37 @@ class KeyedStoreIC: public IC { // Update the inline cache. void UpdateCaches(LookupResult* lookup, State state, + StrictModeFlag strict_mode, Handle receiver, Handle name, Handle value); + void set_target(Code* code) { + // Strict mode must be preserved across IC patching. + ASSERT((code->extra_ic_state() & kStrictMode) == + (target()->extra_ic_state() & kStrictMode)); + IC::set_target(code); + } + // Stub accessors. static Code* initialize_stub() { return Builtins::builtin(Builtins::KeyedStoreIC_Initialize); } + static Code* initialize_stub_strict() { + return Builtins::builtin(Builtins::KeyedStoreIC_Initialize_Strict); + } static Code* megamorphic_stub() { return Builtins::builtin(Builtins::KeyedStoreIC_Generic); } + static Code* megamorphic_stub_strict() { + return Builtins::builtin(Builtins::KeyedStoreIC_Generic_Strict); + } static Code* generic_stub() { return Builtins::builtin(Builtins::KeyedStoreIC_Generic); } + static Code* generic_stub_strict() { + return Builtins::builtin(Builtins::KeyedStoreIC_Generic_Strict); + } static void Clear(Address address, Code* target); diff --git a/deps/v8/src/liveobjectlist-inl.h b/deps/v8/src/liveobjectlist-inl.h index 997da4ee95..f742de3a03 100644 --- a/deps/v8/src/liveobjectlist-inl.h +++ b/deps/v8/src/liveobjectlist-inl.h @@ -32,5 +32,95 @@ #include "liveobjectlist.h" +namespace v8 { +namespace internal { + +#ifdef LIVE_OBJECT_LIST + +void LiveObjectList::GCEpilogue() { + if (!NeedLOLProcessing()) return; + GCEpiloguePrivate(); +} + + +void LiveObjectList::GCPrologue() { + if (!NeedLOLProcessing()) return; +#ifdef VERIFY_LOL + if (FLAG_verify_lol) { + Verify(); + } +#endif +} + + +void LiveObjectList::IterateElements(ObjectVisitor* v) { + if (!NeedLOLProcessing()) return; + IterateElementsPrivate(v); +} + + +void LiveObjectList::ProcessNonLive(HeapObject *obj) { + // Only do work if we have at least one list to process. + if (last()) DoProcessNonLive(obj); +} + + +void LiveObjectList::UpdateReferencesForScavengeGC() { + if (LiveObjectList::NeedLOLProcessing()) { + UpdateLiveObjectListVisitor update_visitor; + LiveObjectList::IterateElements(&update_visitor); + } +} + + +LiveObjectList* LiveObjectList::FindLolForId(int id, + LiveObjectList* start_lol) { + if (id != 0) { + LiveObjectList* lol = start_lol; + while (lol != NULL) { + if (lol->id() == id) { + return lol; + } + lol = lol->prev_; + } + } + return NULL; +} + + +// Iterates the elements in every lol and returns the one that matches the +// specified key. If no matching element is found, then it returns NULL. +template +inline LiveObjectList::Element* +LiveObjectList::FindElementFor(T (*GetValue)(LiveObjectList::Element*), T key) { + LiveObjectList *lol = last(); + while (lol != NULL) { + Element* elements = lol->elements_; + for (int i = 0; i < lol->obj_count_; i++) { + Element* element = &elements[i]; + if (GetValue(element) == key) { + return element; + } + } + lol = lol->prev_; + } + return NULL; +} + + +inline int LiveObjectList::GetElementId(LiveObjectList::Element* element) { + return element->id_; +} + + +inline HeapObject* +LiveObjectList::GetElementObj(LiveObjectList::Element* element) { + return element->obj_; +} + +#endif // LIVE_OBJECT_LIST + +} } // namespace v8::internal + #endif // V8_LIVEOBJECTLIST_INL_H_ diff --git a/deps/v8/src/liveobjectlist.cc b/deps/v8/src/liveobjectlist.cc index 28a3d6d6ec..cd6fcf99ef 100644 --- a/deps/v8/src/liveobjectlist.cc +++ b/deps/v8/src/liveobjectlist.cc @@ -37,7 +37,7 @@ #include "heap.h" #include "inspector.h" #include "list-inl.h" -#include "liveobjectlist.h" +#include "liveobjectlist-inl.h" #include "string-stream.h" #include "top.h" #include "v8utils.h" @@ -46,6 +46,2480 @@ namespace v8 { namespace internal { +typedef int (*RawComparer)(const void*, const void*); + + +#ifdef CHECK_ALL_OBJECT_TYPES + +#define DEBUG_LIVE_OBJECT_TYPES(v) \ + v(Smi, "unexpected: Smi") \ + \ + v(CodeCache, "unexpected: CodeCache") \ + v(BreakPointInfo, "unexpected: BreakPointInfo") \ + v(DebugInfo, "unexpected: DebugInfo") \ + v(TypeSwitchInfo, "unexpected: TypeSwitchInfo") \ + v(SignatureInfo, "unexpected: SignatureInfo") \ + v(Script, "unexpected: Script") \ + v(ObjectTemplateInfo, "unexpected: ObjectTemplateInfo") \ + v(FunctionTemplateInfo, "unexpected: FunctionTemplateInfo") \ + v(CallHandlerInfo, "unexpected: CallHandlerInfo") \ + v(InterceptorInfo, "unexpected: InterceptorInfo") \ + v(AccessCheckInfo, "unexpected: AccessCheckInfo") \ + v(AccessorInfo, "unexpected: AccessorInfo") \ + v(ExternalTwoByteString, "unexpected: ExternalTwoByteString") \ + v(ExternalAsciiString, "unexpected: ExternalAsciiString") \ + v(ExternalString, "unexpected: ExternalString") \ + v(SeqTwoByteString, "unexpected: SeqTwoByteString") \ + v(SeqAsciiString, "unexpected: SeqAsciiString") \ + v(SeqString, "unexpected: SeqString") \ + v(JSFunctionResultCache, "unexpected: JSFunctionResultCache") \ + v(GlobalContext, "unexpected: GlobalContext") \ + v(MapCache, "unexpected: MapCache") \ + v(CodeCacheHashTable, "unexpected: CodeCacheHashTable") \ + v(CompilationCacheTable, "unexpected: CompilationCacheTable") \ + v(SymbolTable, "unexpected: SymbolTable") \ + v(Dictionary, "unexpected: Dictionary") \ + v(HashTable, "unexpected: HashTable") \ + v(DescriptorArray, "unexpected: DescriptorArray") \ + v(ExternalFloatArray, "unexpected: ExternalFloatArray") \ + v(ExternalUnsignedIntArray, "unexpected: ExternalUnsignedIntArray") \ + v(ExternalIntArray, "unexpected: ExternalIntArray") \ + v(ExternalUnsignedShortArray, "unexpected: ExternalUnsignedShortArray") \ + v(ExternalShortArray, "unexpected: ExternalShortArray") \ + v(ExternalUnsignedByteArray, "unexpected: ExternalUnsignedByteArray") \ + v(ExternalByteArray, "unexpected: ExternalByteArray") \ + v(JSValue, "unexpected: JSValue") + +#else +#define DEBUG_LIVE_OBJECT_TYPES(v) +#endif + + +#define FOR_EACH_LIVE_OBJECT_TYPE(v) \ + DEBUG_LIVE_OBJECT_TYPES(v) \ + \ + v(JSArray, "JSArray") \ + v(JSRegExp, "JSRegExp") \ + v(JSFunction, "JSFunction") \ + v(JSGlobalObject, "JSGlobal") \ + v(JSBuiltinsObject, "JSBuiltins") \ + v(GlobalObject, "Global") \ + v(JSGlobalProxy, "JSGlobalProxy") \ + v(JSObject, "JSObject") \ + \ + v(Context, "meta: Context") \ + v(ByteArray, "meta: ByteArray") \ + v(PixelArray, "meta: PixelArray") \ + v(ExternalArray, "meta: ExternalArray") \ + v(FixedArray, "meta: FixedArray") \ + v(String, "String") \ + v(HeapNumber, "HeapNumber") \ + \ + v(Code, "meta: Code") \ + v(Map, "meta: Map") \ + v(Oddball, "Oddball") \ + v(Proxy, "meta: Proxy") \ + v(SharedFunctionInfo, "meta: SharedFunctionInfo") \ + v(Struct, "meta: Struct") \ + \ + v(HeapObject, "HeapObject") + + +enum /* LiveObjectType */ { +#define DECLARE_OBJECT_TYPE_ENUM(type, name) kType##type, + FOR_EACH_LIVE_OBJECT_TYPE(DECLARE_OBJECT_TYPE_ENUM) + kInvalidLiveObjType, + kNumberOfTypes +#undef DECLARE_OBJECT_TYPE_ENUM +}; + + +LiveObjectType GetObjectType(HeapObject* heap_obj) { + // TODO(mlam): investigate usint Map::instance_type() instead. +#define CHECK_FOR_OBJECT_TYPE(type, name) \ + if (heap_obj->Is##type()) return kType##type; + FOR_EACH_LIVE_OBJECT_TYPE(CHECK_FOR_OBJECT_TYPE) +#undef CHECK_FOR_OBJECT_TYPE + + UNREACHABLE(); + return kInvalidLiveObjType; +} + + +inline const char* GetObjectTypeDesc(LiveObjectType type) { + static const char* const name[kNumberOfTypes] = { + #define DEFINE_OBJECT_TYPE_NAME(type, name) name, + FOR_EACH_LIVE_OBJECT_TYPE(DEFINE_OBJECT_TYPE_NAME) + "invalid" + #undef DEFINE_OBJECT_TYPE_NAME + }; + ASSERT(type < kNumberOfTypes); + return name[type]; +} + + +const char* GetObjectTypeDesc(HeapObject* heap_obj) { + LiveObjectType type = GetObjectType(heap_obj); + return GetObjectTypeDesc(type); +} + + +bool IsOfType(LiveObjectType type, HeapObject *obj) { + // Note: there are types that are more general (e.g. JSObject) that would + // have passed the Is##type_() test for more specialized types (e.g. + // JSFunction). If we find a more specialized match but we're looking for + // the general type, then we should reject the ones that matches the + // specialized type. +#define CHECK_OBJECT_TYPE(type_, name) \ + if (obj->Is##type_()) return (type == kType##type_); + + FOR_EACH_LIVE_OBJECT_TYPE(CHECK_OBJECT_TYPE) +#undef CHECK_OBJECT_TYPE + + return false; +} + + +const AllocationSpace kInvalidSpace = static_cast(-1); + +static AllocationSpace FindSpaceFor(String* space_str) { + SmartPointer s = + space_str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); + + const char* key_str = *s; + switch (key_str[0]) { + case 'c': + if (strcmp(key_str, "cell") == 0) return CELL_SPACE; + if (strcmp(key_str, "code") == 0) return CODE_SPACE; + break; + case 'l': + if (strcmp(key_str, "lo") == 0) return LO_SPACE; + break; + case 'm': + if (strcmp(key_str, "map") == 0) return MAP_SPACE; + break; + case 'n': + if (strcmp(key_str, "new") == 0) return NEW_SPACE; + break; + case 'o': + if (strcmp(key_str, "old-pointer") == 0) return OLD_POINTER_SPACE; + if (strcmp(key_str, "old-data") == 0) return OLD_DATA_SPACE; + break; + } + return kInvalidSpace; +} + + +static bool InSpace(AllocationSpace space, HeapObject *heap_obj) { + if (space != LO_SPACE) { + return Heap::InSpace(heap_obj, space); + } + + // This is an optimization to speed up the check for an object in the LO + // space by exclusion because we know that all object pointers passed in + // here are guaranteed to be in the heap. Hence, it is safe to infer + // using an exclusion test. + // Note: calling Heap::InSpace(heap_obj, LO_SPACE) is too slow for our + // filters. + int first_space = static_cast(FIRST_SPACE); + int last_space = static_cast(LO_SPACE); + for (int sp = first_space; sp < last_space; sp++) { + if (Heap::InSpace(heap_obj, static_cast(sp))) { + return false; + } + } + SLOW_ASSERT(Heap::InSpace(heap_obj, LO_SPACE)); + return true; +} + + +static LiveObjectType FindTypeFor(String* type_str) { + SmartPointer s = + type_str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); + +#define CHECK_OBJECT_TYPE(type_, name) { \ + const char* type_desc = GetObjectTypeDesc(kType##type_); \ + const char* key_str = *s; \ + if (strstr(type_desc, key_str) != NULL) return kType##type_; \ + } + FOR_EACH_LIVE_OBJECT_TYPE(CHECK_OBJECT_TYPE) +#undef CHECK_OBJECT_TYPE + + return kInvalidLiveObjType; +} + + +class LolFilter { + public: + explicit LolFilter(Handle filter_obj); + + inline bool is_active() const { return is_active_; } + inline bool Matches(HeapObject* obj) { + return !is_active() || MatchesSlow(obj); + } + + private: + void InitTypeFilter(Handle filter_obj); + void InitSpaceFilter(Handle filter_obj); + void InitPropertyFilter(Handle filter_obj); + bool MatchesSlow(HeapObject* obj); + + bool is_active_; + LiveObjectType type_; + AllocationSpace space_; + Handle prop_; +}; + + +LolFilter::LolFilter(Handle filter_obj) + : is_active_(false), + type_(kInvalidLiveObjType), + space_(kInvalidSpace), + prop_() { + if (filter_obj.is_null()) return; + + InitTypeFilter(filter_obj); + InitSpaceFilter(filter_obj); + InitPropertyFilter(filter_obj); +} + + +void LolFilter::InitTypeFilter(Handle filter_obj) { + Handle type_sym = Factory::LookupAsciiSymbol("type"); + MaybeObject* maybe_result = filter_obj->GetProperty(*type_sym); + Object* type_obj; + if (maybe_result->ToObject(&type_obj)) { + if (type_obj->IsString()) { + String* type_str = String::cast(type_obj); + type_ = FindTypeFor(type_str); + if (type_ != kInvalidLiveObjType) { + is_active_ = true; + } + } + } +} + + +void LolFilter::InitSpaceFilter(Handle filter_obj) { + Handle space_sym = Factory::LookupAsciiSymbol("space"); + MaybeObject* maybe_result = filter_obj->GetProperty(*space_sym); + Object* space_obj; + if (maybe_result->ToObject(&space_obj)) { + if (space_obj->IsString()) { + String* space_str = String::cast(space_obj); + space_ = FindSpaceFor(space_str); + if (space_ != kInvalidSpace) { + is_active_ = true; + } + } + } +} + + +void LolFilter::InitPropertyFilter(Handle filter_obj) { + Handle prop_sym = Factory::LookupAsciiSymbol("prop"); + MaybeObject* maybe_result = filter_obj->GetProperty(*prop_sym); + Object* prop_obj; + if (maybe_result->ToObject(&prop_obj)) { + if (prop_obj->IsString()) { + prop_ = Handle(String::cast(prop_obj)); + is_active_ = true; + } + } +} + + +bool LolFilter::MatchesSlow(HeapObject* obj) { + if ((type_ != kInvalidLiveObjType) && !IsOfType(type_, obj)) { + return false; // Fail because obj is not of the type of interest. + } + if ((space_ != kInvalidSpace) && !InSpace(space_, obj)) { + return false; // Fail because obj is not in the space of interest. + } + if (!prop_.is_null() && obj->IsJSObject()) { + LookupResult result; + obj->Lookup(*prop_, &result); + if (!result.IsProperty()) { + return false; // Fail because obj does not have the property of interest. + } + } + return true; +} + + +class LolIterator { + public: + LolIterator(LiveObjectList* older, LiveObjectList* newer) + : older_(older), + newer_(newer), + curr_(0), + elements_(0), + count_(0), + index_(0) { } + + inline void Init() { + SetCurrent(newer_); + // If the elements_ list is empty, then move on to the next list as long + // as we're not at the last list (indicated by done()). + while ((elements_ == NULL) && !Done()) { + SetCurrent(curr_->prev_); + } + } + + inline bool Done() const { + return (curr_ == older_); + } + + // Object level iteration. + inline void Next() { + index_++; + if (index_ >= count_) { + // Iterate backwards until we get to the oldest list. + while (!Done()) { + SetCurrent(curr_->prev_); + // If we have elements to process, we're good to go. + if (elements_ != NULL) break; + + // Else, we should advance to the next older list. + } + } + } + + inline int Id() const { + return elements_[index_].id_; + } + inline HeapObject* Obj() const { + return elements_[index_].obj_; + } + + inline int LolObjCount() const { + if (curr_ != NULL) return curr_->obj_count_; + return 0; + } + + protected: + inline void SetCurrent(LiveObjectList* new_curr) { + curr_ = new_curr; + if (curr_ != NULL) { + elements_ = curr_->elements_; + count_ = curr_->obj_count_; + index_ = 0; + } + } + + LiveObjectList* older_; + LiveObjectList* newer_; + LiveObjectList* curr_; + LiveObjectList::Element* elements_; + int count_; + int index_; +}; + + +class LolForwardIterator : public LolIterator { + public: + LolForwardIterator(LiveObjectList* first, LiveObjectList* last) + : LolIterator(first, last) { + } + + inline void Init() { + SetCurrent(older_); + // If the elements_ list is empty, then move on to the next list as long + // as we're not at the last list (indicated by Done()). + while ((elements_ == NULL) && !Done()) { + SetCurrent(curr_->next_); + } + } + + inline bool Done() const { + return (curr_ == newer_); + } + + // Object level iteration. + inline void Next() { + index_++; + if (index_ >= count_) { + // Done with current list. Move on to the next. + while (!Done()) { // If not at the last list already, ... + SetCurrent(curr_->next_); + // If we have elements to process, we're good to go. + if (elements_ != NULL) break; + + // Else, we should advance to the next list. + } + } + } +}; + + +// Minimizes the white space in a string. Tabs and newlines are replaced +// with a space where appropriate. +static int CompactString(char* str) { + char* src = str; + char* dst = str; + char prev_ch = 0; + while (*dst != '\0') { + char ch = *src++; + // We will treat non-ascii chars as '?'. + if ((ch & 0x80) != 0) { + ch = '?'; + } + // Compact contiguous whitespace chars into a single ' '. + if (isspace(ch)) { + if (prev_ch != ' ') *dst++ = ' '; + prev_ch = ' '; + continue; + } + *dst++ = ch; + prev_ch = ch; + } + return (dst - str); +} + + +// Generates a custom description based on the specific type of +// object we're looking at. We only generate specialized +// descriptions where we can. In all other cases, we emit the +// generic info. +static void GenerateObjectDesc(HeapObject* obj, + char* buffer, + int buffer_size) { + Vector buffer_v(buffer, buffer_size); + ASSERT(obj != NULL); + if (obj->IsJSArray()) { + JSArray* jsarray = JSArray::cast(obj); + double length = jsarray->length()->Number(); + OS::SNPrintF(buffer_v, + "%p <%s> len %g", + reinterpret_cast(obj), + GetObjectTypeDesc(obj), + length); + + } else if (obj->IsString()) { + String *str = String::cast(obj); + // Only grab up to 160 chars in case they are double byte. + // We'll only dump 80 of them after we compact them. + const int kMaxCharToDump = 80; + const int kMaxBufferSize = kMaxCharToDump * 2; + SmartPointer str_sp = str->ToCString(DISALLOW_NULLS, + ROBUST_STRING_TRAVERSAL, + 0, + kMaxBufferSize); + char* str_cstr = *str_sp; + int length = CompactString(str_cstr); + OS::SNPrintF(buffer_v, + "%p <%s> '%.80s%s'", + reinterpret_cast(obj), + GetObjectTypeDesc(obj), + str_cstr, + (length > kMaxCharToDump) ? "..." : ""); + + } else if (obj->IsJSFunction() || obj->IsSharedFunctionInfo()) { + SharedFunctionInfo* sinfo; + if (obj->IsJSFunction()) { + JSFunction* func = JSFunction::cast(obj); + sinfo = func->shared(); + } else { + sinfo = SharedFunctionInfo::cast(obj); + } + + String* name = sinfo->DebugName(); + SmartPointer name_sp = + name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); + char* name_cstr = *name_sp; + + HeapStringAllocator string_allocator; + StringStream stream(&string_allocator); + sinfo->SourceCodePrint(&stream, 50); + SmartPointer source_sp = stream.ToCString(); + const char* source_cstr = *source_sp; + + OS::SNPrintF(buffer_v, + "%p <%s> '%s' %s", + reinterpret_cast(obj), + GetObjectTypeDesc(obj), + name_cstr, + source_cstr); + + } else if (obj->IsFixedArray()) { + FixedArray* fixed = FixedArray::cast(obj); + + OS::SNPrintF(buffer_v, + "%p <%s> len %d", + reinterpret_cast(obj), + GetObjectTypeDesc(obj), + fixed->length()); + + } else { + OS::SNPrintF(buffer_v, + "%p <%s>", + reinterpret_cast(obj), + GetObjectTypeDesc(obj)); + } +} + + +// Utility function for filling in a line of detail in a verbose dump. +static bool AddObjDetail(Handle arr, + int index, + int obj_id, + Handle target, + const char* desc_str, + Handle id_sym, + Handle desc_sym, + Handle size_sym, + Handle detail, + Handle desc, + Handle error) { + detail = Factory::NewJSObject(Top::object_function()); + if (detail->IsFailure()) { + error = detail; + return false; + } + + int size = 0; + char buffer[512]; + if (desc_str == NULL) { + ASSERT(!target.is_null()); + HeapObject* obj = *target; + GenerateObjectDesc(obj, buffer, sizeof(buffer)); + desc_str = buffer; + size = obj->Size(); + } + desc = Factory::NewStringFromAscii(CStrVector(desc_str)); + if (desc->IsFailure()) { + error = desc; + return false; + } + + { MaybeObject* maybe_result = + detail->SetProperty(*id_sym, Smi::FromInt(obj_id), NONE); + if (maybe_result->IsFailure()) return false; + } + { MaybeObject* maybe_result = + detail->SetProperty(*desc_sym, *desc, NONE); + if (maybe_result->IsFailure()) return false; + } + { MaybeObject* maybe_result = + detail->SetProperty(*size_sym, Smi::FromInt(size), NONE); + if (maybe_result->IsFailure()) return false; + } + + arr->set(index, *detail); + return true; +} + + +class DumpWriter { + public: + virtual ~DumpWriter() {} + + virtual void ComputeTotalCountAndSize(LolFilter* filter, + int* count, + int* size) = 0; + virtual bool Write(Handle elements_arr, + int start, + int dump_limit, + LolFilter* filter, + Handle error) = 0; +}; + + +class LolDumpWriter: public DumpWriter { + public: + LolDumpWriter(LiveObjectList* older, LiveObjectList* newer) + : older_(older), newer_(newer) { + } + + void ComputeTotalCountAndSize(LolFilter* filter, int* count, int* size) { + *count = 0; + *size = 0; + + LolIterator it(older_, newer_); + for (it.Init(); !it.Done(); it.Next()) { + HeapObject* heap_obj = it.Obj(); + if (!filter->Matches(heap_obj)) { + continue; + } + + *size += heap_obj->Size(); + (*count)++; + } + } + + bool Write(Handle elements_arr, + int start, + int dump_limit, + LolFilter* filter, + Handle error) { + // The lols are listed in latest to earliest. We want to dump from + // earliest to latest. So, compute the last element to start with. + int index = 0; + int count = 0; + + // Prefetch some needed symbols. + Handle id_sym = Factory::LookupAsciiSymbol("id"); + Handle desc_sym = Factory::LookupAsciiSymbol("desc"); + Handle size_sym = Factory::LookupAsciiSymbol("size"); + + // Fill the array with the lol object details. + Handle detail; + Handle desc; + Handle target; + + LiveObjectList* first_lol = (older_ != NULL) ? + older_->next_ : LiveObjectList::first_; + LiveObjectList* last_lol = (newer_ != NULL) ? newer_->next_ : NULL; + + LolForwardIterator it(first_lol, last_lol); + for (it.Init(); !it.Done() && (index < dump_limit); it.Next()) { + HeapObject* heap_obj = it.Obj(); + + // Skip objects that have been filtered out. + if (!filter->Matches(heap_obj)) { + continue; + } + + // Only report objects that are in the section of interest. + if (count >= start) { + target = Handle(heap_obj); + bool success = AddObjDetail(elements_arr, + index++, + it.Id(), + target, + NULL, + id_sym, + desc_sym, + size_sym, + detail, + desc, + error); + if (!success) return false; + } + count++; + } + return true; + } + + private: + LiveObjectList* older_; + LiveObjectList* newer_; +}; + + +class RetainersDumpWriter: public DumpWriter { + public: + RetainersDumpWriter(Handle target, + Handle instance_filter, + Handle args_function) + : target_(target), + instance_filter_(instance_filter), + args_function_(args_function) { + } + + void ComputeTotalCountAndSize(LolFilter* filter, int* count, int* size) { + Handle retainers_arr; + Handle error; + + *size = -1; + LiveObjectList::GetRetainers(target_, + instance_filter_, + retainers_arr, + 0, + Smi::kMaxValue, + count, + filter, + NULL, + *args_function_, + error); + } + + bool Write(Handle elements_arr, + int start, + int dump_limit, + LolFilter* filter, + Handle error) { + int dummy; + int count; + + // Fill the retainer objects. + count = LiveObjectList::GetRetainers(target_, + instance_filter_, + elements_arr, + start, + dump_limit, + &dummy, + filter, + NULL, + *args_function_, + error); + if (count < 0) { + return false; + } + return true; + } + + private: + Handle target_; + Handle instance_filter_; + Handle args_function_; +}; + + +class LiveObjectSummary { + public: + explicit LiveObjectSummary(LolFilter* filter) + : total_count_(0), + total_size_(0), + found_root_(false), + found_weak_root_(false), + filter_(filter) { + memset(counts_, 0, sizeof(counts_[0]) * kNumberOfEntries); + memset(sizes_, 0, sizeof(sizes_[0]) * kNumberOfEntries); + } + + void Add(HeapObject* heap_obj) { + int size = heap_obj->Size(); + LiveObjectType type = GetObjectType(heap_obj); + ASSERT(type != kInvalidLiveObjType); + counts_[type]++; + sizes_[type] += size; + total_count_++; + total_size_ += size; + } + + void set_found_root() { found_root_ = true; } + void set_found_weak_root() { found_weak_root_ = true; } + + inline int Count(LiveObjectType type) { + return counts_[type]; + } + inline int Size(LiveObjectType type) { + return sizes_[type]; + } + inline int total_count() { + return total_count_; + } + inline int total_size() { + return total_size_; + } + inline bool found_root() { + return found_root_; + } + inline bool found_weak_root() { + return found_weak_root_; + } + int GetNumberOfEntries() { + int entries = 0; + for (int i = 0; i < kNumberOfEntries; i++) { + if (counts_[i]) entries++; + } + return entries; + } + + inline LolFilter* filter() { return filter_; } + + static const int kNumberOfEntries = kNumberOfTypes; + + private: + int counts_[kNumberOfEntries]; + int sizes_[kNumberOfEntries]; + int total_count_; + int total_size_; + bool found_root_; + bool found_weak_root_; + + LolFilter *filter_; +}; + + +// Abstraction for a summary writer. +class SummaryWriter { + public: + virtual ~SummaryWriter() {} + virtual void Write(LiveObjectSummary* summary) = 0; +}; + + +// A summary writer for filling in a summary of lol lists and diffs. +class LolSummaryWriter: public SummaryWriter { + public: + LolSummaryWriter(LiveObjectList *older_lol, + LiveObjectList *newer_lol) + : older_(older_lol), newer_(newer_lol) { + } + + void Write(LiveObjectSummary* summary) { + LolFilter* filter = summary->filter(); + + // Fill the summary with the lol object details. + LolIterator it(older_, newer_); + for (it.Init(); !it.Done(); it.Next()) { + HeapObject* heap_obj = it.Obj(); + if (!filter->Matches(heap_obj)) { + continue; + } + summary->Add(heap_obj); + } + } + + private: + LiveObjectList* older_; + LiveObjectList* newer_; +}; + + +// A summary writer for filling in a retainers list. +class RetainersSummaryWriter: public SummaryWriter { + public: + RetainersSummaryWriter(Handle target, + Handle instance_filter, + Handle args_function) + : target_(target), + instance_filter_(instance_filter), + args_function_(args_function) { + } + + void Write(LiveObjectSummary* summary) { + Handle retainers_arr; + Handle error; + int dummy_total_count; + LiveObjectList::GetRetainers(target_, + instance_filter_, + retainers_arr, + 0, + Smi::kMaxValue, + &dummy_total_count, + summary->filter(), + summary, + *args_function_, + error); + } + + private: + Handle target_; + Handle instance_filter_; + Handle args_function_; +}; + + +uint32_t LiveObjectList::next_element_id_ = 1; +int LiveObjectList::list_count_ = 0; +int LiveObjectList::last_id_ = 0; +LiveObjectList* LiveObjectList::first_ = NULL; +LiveObjectList* LiveObjectList::last_ = NULL; + + +LiveObjectList::LiveObjectList(LiveObjectList* prev, int capacity) + : prev_(prev), + next_(NULL), + capacity_(capacity), + obj_count_(0) { + elements_ = NewArray(capacity); + id_ = ++last_id_; + + list_count_++; +} + + +LiveObjectList::~LiveObjectList() { + DeleteArray(elements_); + delete prev_; +} + + +int LiveObjectList::GetTotalObjCountAndSize(int* size_p) { + int size = 0; + int count = 0; + LiveObjectList *lol = this; + do { + // Only compute total size if requested i.e. when size_p is not null. + if (size_p != NULL) { + Element* elements = lol->elements_; + for (int i = 0; i < lol->obj_count_; i++) { + HeapObject* heap_obj = elements[i].obj_; + size += heap_obj->Size(); + } + } + count += lol->obj_count_; + lol = lol->prev_; + } while (lol != NULL); + + if (size_p != NULL) { + *size_p = size; + } + return count; +} + + +// Adds an object to the lol. +// Returns true if successful, else returns false. +bool LiveObjectList::Add(HeapObject* obj) { + // If the object is already accounted for in the prev list which we inherit + // from, then no need to add it to this list. + if ((prev() != NULL) && (prev()->Find(obj) != NULL)) { + return true; + } + ASSERT(obj_count_ <= capacity_); + if (obj_count_ == capacity_) { + // The heap must have grown and we have more objects than capacity to store + // them. + return false; // Fail this addition. + } + Element& element = elements_[obj_count_++]; + element.id_ = next_element_id_++; + element.obj_ = obj; + return true; +} + + +// Comparator used for sorting and searching the lol. +int LiveObjectList::CompareElement(const Element* a, const Element* b) { + const HeapObject* obj1 = a->obj_; + const HeapObject* obj2 = b->obj_; + // For lol elements, it doesn't matter which comes first if 2 elements point + // to the same object (which gets culled later). Hence, we only care about + // the the greater than / less than relationships. + return (obj1 > obj2) ? 1 : (obj1 == obj2) ? 0 : -1; +} + + +// Looks for the specified object in the lol, and returns its element if found. +LiveObjectList::Element* LiveObjectList::Find(HeapObject* obj) { + LiveObjectList* lol = this; + Element key; + Element* result = NULL; + + key.obj_ = obj; + // Iterate through the chain of lol's to look for the object. + while ((result == NULL) && (lol != NULL)) { + result = reinterpret_cast( + bsearch(&key, lol->elements_, lol->obj_count_, + sizeof(Element), + reinterpret_cast(CompareElement))); + lol = lol->prev_; + } + return result; +} + + +// "Nullifies" (convert the HeapObject* into an SMI) so that it will get cleaned +// up in the GCEpilogue, while preserving the sort order of the lol. +// NOTE: the lols need to be already sorted before NullifyMostRecent() is +// called. +void LiveObjectList::NullifyMostRecent(HeapObject* obj) { + LiveObjectList* lol = last(); + Element key; + Element* result = NULL; + + key.obj_ = obj; + // Iterate through the chain of lol's to look for the object. + while (lol != NULL) { + result = reinterpret_cast( + bsearch(&key, lol->elements_, lol->obj_count_, + sizeof(Element), + reinterpret_cast(CompareElement))); + if (result != NULL) { + // Since there may be more than one (we are nullifying dup's after all), + // find the first in the current lol, and nullify that. The lol should + // be sorted already to make this easy (see the use of SortAll()). + int i = result - lol->elements_; + + // NOTE: we sort the lol in increasing order. So, if an object has been + // "nullified" (its lowest bit will be cleared to make it look like an + // SMI), it would/should show up before the equivalent dups that have not + // yet been "nullified". Hence, we should be searching backwards for the + // first occurence of a matching object and nullify that instance. This + // will ensure that we preserve the expected sorting order. + for (i--; i > 0; i--) { + Element* element = &lol->elements_[i]; + HeapObject* curr_obj = element->obj_; + if (curr_obj != obj) { + break; // No more matches. Let's move on. + } + result = element; // Let this earlier match be the result. + } + + // Nullify the object. + NullifyNonLivePointer(&result->obj_); + return; + } + lol = lol->prev_; + } +} + + +// Sorts the lol. +void LiveObjectList::Sort() { + if (obj_count_ > 0) { + Vector elements_v(elements_, obj_count_); + elements_v.Sort(CompareElement); + } +} + + +// Sorts all captured lols starting from the latest. +void LiveObjectList::SortAll() { + LiveObjectList* lol = last(); + while (lol != NULL) { + lol->Sort(); + lol = lol->prev_; + } +} + + +// Counts the number of objects in the heap. +static int CountHeapObjects() { + int count = 0; + // Iterate over all the heap spaces and count the number of objects. + HeapIterator iterator(HeapIterator::kFilterFreeListNodes); + HeapObject* heap_obj = NULL; + while ((heap_obj = iterator.next()) != NULL) { + count++; + } + return count; +} + + +// Captures a current snapshot of all objects in the heap. +MaybeObject* LiveObjectList::Capture() { + HandleScope scope; + + // Count the number of objects in the heap. + int total_count = CountHeapObjects(); + int count = total_count; + int size = 0; + + LiveObjectList* last_lol = last(); + if (last_lol != NULL) { + count -= last_lol->TotalObjCount(); + } + + LiveObjectList* lol; + + // Create a lol large enough to track all the objects. + lol = new LiveObjectList(last_lol, count); + if (lol == NULL) { + return NULL; // No memory to proceed. + } + + // The HeapIterator needs to be in its own scope because it disables + // allocation, and we need allocate below. + { + // Iterate over all the heap spaces and add the objects. + HeapIterator iterator(HeapIterator::kFilterFreeListNodes); + HeapObject* heap_obj = NULL; + bool failed = false; + while (!failed && (heap_obj = iterator.next()) != NULL) { + failed = !lol->Add(heap_obj); + size += heap_obj->Size(); + } + ASSERT(!failed); + + lol->Sort(); + + // Add the current lol to the list of lols. + if (last_ != NULL) { + last_->next_ = lol; + } else { + first_ = lol; + } + last_ = lol; + +#ifdef VERIFY_LOL + if (FLAG_verify_lol) { + Verify(true); + } +#endif + } + + Handle id_sym = Factory::LookupAsciiSymbol("id"); + Handle count_sym = Factory::LookupAsciiSymbol("count"); + Handle size_sym = Factory::LookupAsciiSymbol("size"); + + Handle result = Factory::NewJSObject(Top::object_function()); + if (result->IsFailure()) return Object::cast(*result); + + { MaybeObject* maybe_result = + result->SetProperty(*id_sym, Smi::FromInt(lol->id()), NONE); + if (maybe_result->IsFailure()) return maybe_result; + } + { MaybeObject* maybe_result = + result->SetProperty(*count_sym, Smi::FromInt(total_count), NONE); + if (maybe_result->IsFailure()) return maybe_result; + } + { MaybeObject* maybe_result = + result->SetProperty(*size_sym, Smi::FromInt(size), NONE); + if (maybe_result->IsFailure()) return maybe_result; + } + + return *result; +} + + +// Delete doesn't actually deletes an lol. It just marks it as invisible since +// its contents are considered to be part of subsequent lists as well. The +// only time we'll actually delete the lol is when we Reset() or if the lol is +// invisible, and its element count reaches 0. +bool LiveObjectList::Delete(int id) { + LiveObjectList *lol = last(); + while (lol != NULL) { + if (lol->id() == id) { + break; + } + lol = lol->prev_; + } + + // If no lol is found for this id, then we fail to delete. + if (lol == NULL) return false; + + // Else, mark the lol as invisible i.e. id == 0. + lol->id_ = 0; + list_count_--; + ASSERT(list_count_ >= 0); + if (lol->obj_count_ == 0) { + // Point the next lol's prev to this lol's prev. + LiveObjectList* next = lol->next_; + LiveObjectList* prev = lol->prev_; + // Point next's prev to prev. + if (next != NULL) { + next->prev_ = lol->prev_; + } else { + last_ = lol->prev_; + } + // Point prev's next to next. + if (prev != NULL) { + prev->next_ = lol->next_; + } else { + first_ = lol->next_; + } + + lol->prev_ = NULL; + lol->next_ = NULL; + + // Delete this now empty and invisible lol. + delete lol; + } + + // Just in case we've marked everything invisible, then clean up completely. + if (list_count_ == 0) { + Reset(); + } + + return true; +} + + +MaybeObject* LiveObjectList::Dump(int older_id, + int newer_id, + int start_idx, + int dump_limit, + Handle filter_obj) { + if ((older_id < 0) || (newer_id < 0) || (last() == NULL)) { + return Failure::Exception(); // Fail: 0 is not a valid lol id. + } + if (newer_id < older_id) { + // They are not in the expected order. Swap them. + int temp = older_id; + older_id = newer_id; + newer_id = temp; + } + + LiveObjectList *newer_lol = FindLolForId(newer_id, last()); + LiveObjectList *older_lol = FindLolForId(older_id, newer_lol); + + // If the id is defined, and we can't find a LOL for it, then we have an + // invalid id. + if ((newer_id != 0) && (newer_lol == NULL)) { + return Failure::Exception(); // Fail: the newer lol id is invalid. + } + if ((older_id != 0) && (older_lol == NULL)) { + return Failure::Exception(); // Fail: the older lol id is invalid. + } + + LolFilter filter(filter_obj); + LolDumpWriter writer(older_lol, newer_lol); + return DumpPrivate(&writer, start_idx, dump_limit, &filter); +} + + +MaybeObject* LiveObjectList::DumpPrivate(DumpWriter* writer, + int start, + int dump_limit, + LolFilter* filter) { + HandleScope scope; + + // Calculate the number of entries of the dump. + int count = -1; + int size = -1; + writer->ComputeTotalCountAndSize(filter, &count, &size); + + // Adjust for where to start the dump. + if ((start < 0) || (start >= count)) { + return Failure::Exception(); // invalid start. + } + + int remaining_count = count - start; + if (dump_limit > remaining_count) { + dump_limit = remaining_count; + } + + // Allocate an array to hold the result. + Handle elements_arr = Factory::NewFixedArray(dump_limit); + if (elements_arr->IsFailure()) return Object::cast(*elements_arr); + + // Fill in the dump. + Handle error; + bool success = writer->Write(elements_arr, + start, + dump_limit, + filter, + error); + if (!success) return Object::cast(*error); + + MaybeObject* maybe_result; + + // Allocate the result body. + Handle body = Factory::NewJSObject(Top::object_function()); + if (body->IsFailure()) return Object::cast(*body); + + // Set the updated body.count. + Handle count_sym = Factory::LookupAsciiSymbol("count"); + maybe_result = body->SetProperty(*count_sym, Smi::FromInt(count), NONE); + if (maybe_result->IsFailure()) return maybe_result; + + // Set the updated body.size if appropriate. + if (size >= 0) { + Handle size_sym = Factory::LookupAsciiSymbol("size"); + maybe_result = body->SetProperty(*size_sym, Smi::FromInt(size), NONE); + if (maybe_result->IsFailure()) return maybe_result; + } + + // Set body.first_index. + Handle first_sym = Factory::LookupAsciiSymbol("first_index"); + maybe_result = body->SetProperty(*first_sym, Smi::FromInt(start), NONE); + if (maybe_result->IsFailure()) return maybe_result; + + // Allocate the JSArray of the elements. + Handle elements = Factory::NewJSObject(Top::array_function()); + if (elements->IsFailure()) return Object::cast(*elements); + Handle::cast(elements)->SetContent(*elements_arr); + + // Set body.elements. + Handle elements_sym = Factory::LookupAsciiSymbol("elements"); + maybe_result = body->SetProperty(*elements_sym, *elements, NONE); + if (maybe_result->IsFailure()) return maybe_result; + + return *body; +} + + +MaybeObject* LiveObjectList::Summarize(int older_id, + int newer_id, + Handle filter_obj) { + if ((older_id < 0) || (newer_id < 0) || (last() == NULL)) { + return Failure::Exception(); // Fail: 0 is not a valid lol id. + } + if (newer_id < older_id) { + // They are not in the expected order. Swap them. + int temp = older_id; + older_id = newer_id; + newer_id = temp; + } + + LiveObjectList *newer_lol = FindLolForId(newer_id, last()); + LiveObjectList *older_lol = FindLolForId(older_id, newer_lol); + + // If the id is defined, and we can't find a LOL for it, then we have an + // invalid id. + if ((newer_id != 0) && (newer_lol == NULL)) { + return Failure::Exception(); // Fail: the newer lol id is invalid. + } + if ((older_id != 0) && (older_lol == NULL)) { + return Failure::Exception(); // Fail: the older lol id is invalid. + } + + LolFilter filter(filter_obj); + LolSummaryWriter writer(older_lol, newer_lol); + return SummarizePrivate(&writer, &filter, false); +} + + +// Creates a summary report for the debugger. +// Note: the SummaryWriter takes care of iterating over objects and filling in +// the summary. +MaybeObject* LiveObjectList::SummarizePrivate(SummaryWriter* writer, + LolFilter* filter, + bool is_tracking_roots) { + HandleScope scope; + MaybeObject* maybe_result; + + LiveObjectSummary summary(filter); + writer->Write(&summary); + + // The result body will look like this: + // body: { + // count: , + // size: , + // found_root: , // optional. + // found_weak_root: , // optional. + // summary: [ + // { + // desc: "", + // count: , + // size: size + // }, + // ... + // ] + // } + + // Prefetch some needed symbols. + Handle desc_sym = Factory::LookupAsciiSymbol("desc"); + Handle count_sym = Factory::LookupAsciiSymbol("count"); + Handle size_sym = Factory::LookupAsciiSymbol("size"); + Handle summary_sym = Factory::LookupAsciiSymbol("summary"); + + // Allocate the summary array. + int entries_count = summary.GetNumberOfEntries(); + Handle summary_arr = + Factory::NewFixedArray(entries_count); + if (summary_arr->IsFailure()) return Object::cast(*summary_arr); + + int idx = 0; + for (int i = 0; i < LiveObjectSummary::kNumberOfEntries; i++) { + // Allocate the summary record. + Handle detail = Factory::NewJSObject(Top::object_function()); + if (detail->IsFailure()) return Object::cast(*detail); + + // Fill in the summary record. + LiveObjectType type = static_cast(i); + int count = summary.Count(type); + if (count) { + const char* desc_cstr = GetObjectTypeDesc(type); + Handle desc = Factory::LookupAsciiSymbol(desc_cstr); + int size = summary.Size(type); + + maybe_result = detail->SetProperty(*desc_sym, *desc, NONE); + if (maybe_result->IsFailure()) return maybe_result; + maybe_result = detail->SetProperty(*count_sym, Smi::FromInt(count), NONE); + if (maybe_result->IsFailure()) return maybe_result; + maybe_result = detail->SetProperty(*size_sym, Smi::FromInt(size), NONE); + if (maybe_result->IsFailure()) return maybe_result; + + summary_arr->set(idx++, *detail); + } + } + + // Wrap the summary fixed array in a JS array. + Handle summary_obj = Factory::NewJSObject(Top::array_function()); + if (summary_obj->IsFailure()) return Object::cast(*summary_obj); + Handle::cast(summary_obj)->SetContent(*summary_arr); + + // Create the body object. + Handle body = Factory::NewJSObject(Top::object_function()); + if (body->IsFailure()) return Object::cast(*body); + + // Fill out the body object. + int total_count = summary.total_count(); + int total_size = summary.total_size(); + maybe_result = + body->SetProperty(*count_sym, Smi::FromInt(total_count), NONE); + if (maybe_result->IsFailure()) return maybe_result; + + maybe_result = body->SetProperty(*size_sym, Smi::FromInt(total_size), NONE); + if (maybe_result->IsFailure()) return maybe_result; + + if (is_tracking_roots) { + int found_root = summary.found_root(); + int found_weak_root = summary.found_weak_root(); + Handle root_sym = Factory::LookupAsciiSymbol("found_root"); + Handle weak_root_sym = + Factory::LookupAsciiSymbol("found_weak_root"); + maybe_result = + body->SetProperty(*root_sym, Smi::FromInt(found_root), NONE); + if (maybe_result->IsFailure()) return maybe_result; + maybe_result = + body->SetProperty(*weak_root_sym, Smi::FromInt(found_weak_root), NONE); + if (maybe_result->IsFailure()) return maybe_result; + } + + maybe_result = body->SetProperty(*summary_sym, *summary_obj, NONE); + if (maybe_result->IsFailure()) return maybe_result; + + return *body; +} + + +// Returns an array listing the captured lols. +// Note: only dumps the section starting at start_idx and only up to +// dump_limit entries. +MaybeObject* LiveObjectList::Info(int start_idx, int dump_limit) { + HandleScope scope; + MaybeObject* maybe_result; + + int total_count = LiveObjectList::list_count(); + int dump_count = total_count; + + // Adjust for where to start the dump. + if (total_count == 0) { + start_idx = 0; // Ensure this to get an empty list. + } else if ((start_idx < 0) || (start_idx >= total_count)) { + return Failure::Exception(); // invalid start. + } + dump_count -= start_idx; + + // Adjust for the dump limit. + if (dump_count > dump_limit) { + dump_count = dump_limit; + } + + // Allocate an array to hold the result. + Handle list = Factory::NewFixedArray(dump_count); + if (list->IsFailure()) return Object::cast(*list); + + // Prefetch some needed symbols. + Handle id_sym = Factory::LookupAsciiSymbol("id"); + Handle count_sym = Factory::LookupAsciiSymbol("count"); + Handle size_sym = Factory::LookupAsciiSymbol("size"); + + // Fill the array with the lol details. + int idx = 0; + LiveObjectList* lol = first_; + while ((lol != NULL) && (idx < start_idx)) { // Skip tail entries. + if (lol->id() != 0) { + idx++; + } + lol = lol->next(); + } + idx = 0; + while ((lol != NULL) && (dump_limit != 0)) { + if (lol->id() != 0) { + int count; + int size; + count = lol->GetTotalObjCountAndSize(&size); + + Handle detail = Factory::NewJSObject(Top::object_function()); + if (detail->IsFailure()) return Object::cast(*detail); + + maybe_result = + detail->SetProperty(*id_sym, Smi::FromInt(lol->id()), NONE); + if (maybe_result->IsFailure()) return maybe_result; + maybe_result = + detail->SetProperty(*count_sym, Smi::FromInt(count), NONE); + if (maybe_result->IsFailure()) return maybe_result; + maybe_result = detail->SetProperty(*size_sym, Smi::FromInt(size), NONE); + if (maybe_result->IsFailure()) return maybe_result; + list->set(idx++, *detail); + dump_limit--; + } + lol = lol->next(); + } + + // Return the result as a JS array. + Handle lols = Factory::NewJSObject(Top::array_function()); + Handle::cast(lols)->SetContent(*list); + + Handle result = Factory::NewJSObject(Top::object_function()); + if (result->IsFailure()) return Object::cast(*result); + + maybe_result = + result->SetProperty(*count_sym, Smi::FromInt(total_count), NONE); + if (maybe_result->IsFailure()) return maybe_result; + + Handle first_sym = Factory::LookupAsciiSymbol("first_index"); + maybe_result = + result->SetProperty(*first_sym, Smi::FromInt(start_idx), NONE); + if (maybe_result->IsFailure()) return maybe_result; + + Handle lists_sym = Factory::LookupAsciiSymbol("lists"); + maybe_result = result->SetProperty(*lists_sym, *lols, NONE); + if (maybe_result->IsFailure()) return maybe_result; + + return *result; +} + + +// Deletes all captured lols. +void LiveObjectList::Reset() { + LiveObjectList *lol = last(); + // Just delete the last. Each lol will delete it's prev automatically. + delete lol; + + next_element_id_ = 1; + list_count_ = 0; + last_id_ = 0; + first_ = NULL; + last_ = NULL; +} + + +// Gets the object for the specified obj id. +Object* LiveObjectList::GetObj(int obj_id) { + Element* element = FindElementFor(GetElementId, obj_id); + if (element != NULL) { + return Object::cast(element->obj_); + } + return Heap::undefined_value(); +} + + +// Gets the obj id for the specified address if valid. +int LiveObjectList::GetObjId(Object* obj) { + // Make a heap object pointer from the address. + HeapObject* hobj = HeapObject::cast(obj); + Element* element = FindElementFor(GetElementObj, hobj); + if (element != NULL) { + return element->id_; + } + return 0; // Invalid address. +} + + +// Gets the obj id for the specified address if valid. +Object* LiveObjectList::GetObjId(Handle address) { + SmartPointer addr_str = + address->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); + + // Extract the address value from the string. + int value = static_cast(StringToInt(*address, 16)); + Object* obj = reinterpret_cast(value); + return Smi::FromInt(GetObjId(obj)); +} + + +// Helper class for copying HeapObjects. +class LolVisitor: public ObjectVisitor { + public: + + LolVisitor(HeapObject* target, Handle handle_to_skip) + : target_(target), handle_to_skip_(handle_to_skip), found_(false) {} + + void VisitPointer(Object** p) { CheckPointer(p); } + + void VisitPointers(Object** start, Object** end) { + // Check all HeapObject pointers in [start, end). + for (Object** p = start; !found() && p < end; p++) CheckPointer(p); + } + + inline bool found() const { return found_; } + inline bool reset() { return found_ = false; } + + private: + inline void CheckPointer(Object** p) { + Object* object = *p; + if (HeapObject::cast(object) == target_) { + // We may want to skip this handle because the handle may be a local + // handle in a handle scope in one of our callers. Once we return, + // that handle will be popped. Hence, we don't want to count it as + // a root that would have kept the target object alive. + if (!handle_to_skip_.is_null() && + handle_to_skip_.location() == reinterpret_cast(p)) { + return; // Skip this handle. + } + found_ = true; + } + } + + HeapObject* target_; + Handle handle_to_skip_; + bool found_; +}; + + +inline bool AddRootRetainerIfFound(const LolVisitor& visitor, + LolFilter* filter, + LiveObjectSummary *summary, + void (*SetRootFound)(LiveObjectSummary *s), + int start, + int dump_limit, + int* total_count, + Handle retainers_arr, + int* count, + int* index, + const char* root_name, + Handle id_sym, + Handle desc_sym, + Handle size_sym, + Handle error) { + HandleScope scope; + + // Scratch handles. + Handle detail; + Handle desc; + Handle retainer; + + if (visitor.found()) { + if (!filter->is_active()) { + (*total_count)++; + if (summary) { + SetRootFound(summary); + } else if ((*total_count > start) && ((*index) < dump_limit)) { + (*count)++; + if (!retainers_arr.is_null()) { + return AddObjDetail(retainers_arr, + (*index)++, + 0, + retainer, + root_name, + id_sym, + desc_sym, + size_sym, + detail, + desc, + error); + } + } + } + } + return true; +} + + +inline void SetFoundRoot(LiveObjectSummary *summary) { + summary->set_found_root(); +} + + +inline void SetFoundWeakRoot(LiveObjectSummary *summary) { + summary->set_found_weak_root(); +} + + +int LiveObjectList::GetRetainers(Handle target, + Handle instance_filter, + Handle retainers_arr, + int start, + int dump_limit, + int* total_count, + LolFilter* filter, + LiveObjectSummary *summary, + JSFunction* arguments_function, + Handle error) { + HandleScope scope; + + // Scratch handles. + Handle detail; + Handle desc; + Handle retainer; + + // Prefetch some needed symbols. + Handle id_sym = Factory::LookupAsciiSymbol("id"); + Handle desc_sym = Factory::LookupAsciiSymbol("desc"); + Handle size_sym = Factory::LookupAsciiSymbol("size"); + + NoHandleAllocation ha; + int count = 0; + int index = 0; + Handle last_obj; + + *total_count = 0; + + // Iterate roots. + LolVisitor lol_visitor(*target, target); + Heap::IterateStrongRoots(&lol_visitor, VISIT_ALL); + if (!AddRootRetainerIfFound(lol_visitor, + filter, + summary, + SetFoundRoot, + start, + dump_limit, + total_count, + retainers_arr, + &count, + &index, + "", + id_sym, + desc_sym, + size_sym, + error)) { + return -1; + } + + lol_visitor.reset(); + Heap::IterateWeakRoots(&lol_visitor, VISIT_ALL); + if (!AddRootRetainerIfFound(lol_visitor, + filter, + summary, + SetFoundWeakRoot, + start, + dump_limit, + total_count, + retainers_arr, + &count, + &index, + "", + id_sym, + desc_sym, + size_sym, + error)) { + return -1; + } + + // Iterate the live object lists. + LolIterator it(NULL, last()); + for (it.Init(); !it.Done() && (index < dump_limit); it.Next()) { + HeapObject* heap_obj = it.Obj(); + + // Only look at all JSObjects. + if (heap_obj->IsJSObject()) { + // Skip context extension objects and argument arrays as these are + // checked in the context of functions using them. + JSObject* obj = JSObject::cast(heap_obj); + if (obj->IsJSContextExtensionObject() || + obj->map()->constructor() == arguments_function) { + continue; + } + + // Check if the JS object has a reference to the object looked for. + if (obj->ReferencesObject(*target)) { + // Check instance filter if supplied. This is normally used to avoid + // references from mirror objects (see Runtime_IsInPrototypeChain). + if (!instance_filter->IsUndefined()) { + Object* V = obj; + while (true) { + Object* prototype = V->GetPrototype(); + if (prototype->IsNull()) { + break; + } + if (*instance_filter == prototype) { + obj = NULL; // Don't add this object. + break; + } + V = prototype; + } + } + + if (obj != NULL) { + // Skip objects that have been filtered out. + if (filter->Matches(heap_obj)) { + continue; + } + + // Valid reference found add to instance array if supplied an update + // count. + last_obj = Handle(obj); + (*total_count)++; + + if (summary != NULL) { + summary->Add(heap_obj); + } else if ((*total_count > start) && (index < dump_limit)) { + count++; + if (!retainers_arr.is_null()) { + retainer = Handle(heap_obj); + bool success = AddObjDetail(retainers_arr, + index++, + it.Id(), + retainer, + NULL, + id_sym, + desc_sym, + size_sym, + detail, + desc, + error); + if (!success) return -1; + } + } + } + } + } + } + + // Check for circular reference only. This can happen when the object is only + // referenced from mirrors and has a circular reference in which case the + // object is not really alive and would have been garbage collected if not + // referenced from the mirror. + + if (*total_count == 1 && !last_obj.is_null() && *last_obj == *target) { + count = 0; + *total_count = 0; + } + + return count; +} + + +MaybeObject* LiveObjectList::GetObjRetainers(int obj_id, + Handle instance_filter, + bool verbose, + int start, + int dump_limit, + Handle filter_obj) { + HandleScope scope; + + // Get the target object. + HeapObject* heap_obj = HeapObject::cast(GetObj(obj_id)); + if (heap_obj == Heap::undefined_value()) { + return heap_obj; + } + + Handle target = Handle(heap_obj); + + // Get the constructor function for context extension and arguments array. + JSObject* arguments_boilerplate = + Top::context()->global_context()->arguments_boilerplate(); + JSFunction* arguments_function = + JSFunction::cast(arguments_boilerplate->map()->constructor()); + + Handle args_function = Handle(arguments_function); + LolFilter filter(filter_obj); + + if (!verbose) { + RetainersSummaryWriter writer(target, instance_filter, args_function); + return SummarizePrivate(&writer, &filter, true); + + } else { + RetainersDumpWriter writer(target, instance_filter, args_function); + Object* body_obj; + MaybeObject* maybe_result = + DumpPrivate(&writer, start, dump_limit, &filter); + if (!maybe_result->ToObject(&body_obj)) { + return maybe_result; + } + + // Set body.id. + Handle body = Handle(JSObject::cast(body_obj)); + Handle id_sym = Factory::LookupAsciiSymbol("id"); + maybe_result = body->SetProperty(*id_sym, Smi::FromInt(obj_id), NONE); + if (maybe_result->IsFailure()) return maybe_result; + + return *body; + } +} + + +Object* LiveObjectList::PrintObj(int obj_id) { + Object* obj = GetObj(obj_id); + if (!obj) { + return Heap::undefined_value(); + } + + EmbeddedVector temp_filename; + static int temp_count = 0; + const char* path_prefix = "."; + + if (FLAG_lol_workdir) { + path_prefix = FLAG_lol_workdir; + } + OS::SNPrintF(temp_filename, "%s/lol-print-%d", path_prefix, ++temp_count); + + FILE* f = OS::FOpen(temp_filename.start(), "w+"); + + PrintF(f, "@%d ", LiveObjectList::GetObjId(obj)); +#ifdef OBJECT_PRINT +#ifdef INSPECTOR + Inspector::DumpObjectType(f, obj); +#endif // INSPECTOR + PrintF(f, "\n"); + obj->Print(f); +#else // !OBJECT_PRINT + obj->ShortPrint(f); +#endif // !OBJECT_PRINT + PrintF(f, "\n"); + Flush(f); + fclose(f); + + // Create a string from the temp_file. + // Note: the mmapped resource will take care of closing the file. + MemoryMappedExternalResource* resource = + new MemoryMappedExternalResource(temp_filename.start(), true); + if (resource->exists() && !resource->is_empty()) { + ASSERT(resource->IsAscii()); + Handle dump_string = + Factory::NewExternalStringFromAscii(resource); + ExternalStringTable::AddString(*dump_string); + return *dump_string; + } else { + delete resource; + } + return Heap::undefined_value(); +} + + +class LolPathTracer: public PathTracer { + public: + LolPathTracer(FILE* out, + Object* search_target, + WhatToFind what_to_find) + : PathTracer(search_target, what_to_find, VISIT_ONLY_STRONG), out_(out) {} + + private: + void ProcessResults(); + + FILE* out_; +}; + + +void LolPathTracer::ProcessResults() { + if (found_target_) { + PrintF(out_, "=====================================\n"); + PrintF(out_, "==== Path to object ====\n"); + PrintF(out_, "=====================================\n\n"); + + ASSERT(!object_stack_.is_empty()); + Object* prev = NULL; + for (int i = 0, index = 0; i < object_stack_.length(); i++) { + Object* obj = object_stack_[i]; + + // Skip this object if it is basically the internals of the + // previous object (which would have dumped its details already). + if (prev && prev->IsJSObject() && + (obj != search_target_)) { + JSObject* jsobj = JSObject::cast(prev); + if (obj->IsFixedArray() && + jsobj->properties() == FixedArray::cast(obj)) { + // Skip this one because it would have been printed as the + // properties of the last object already. + continue; + } else if (obj->IsHeapObject() && + jsobj->elements() == HeapObject::cast(obj)) { + // Skip this one because it would have been printed as the + // elements of the last object already. + continue; + } + } + + // Print a connecting arrow. + if (i > 0) PrintF(out_, "\n |\n |\n V\n\n"); + + // Print the object index. + PrintF(out_, "[%d] ", ++index); + + // Print the LOL object ID: + int id = LiveObjectList::GetObjId(obj); + if (id > 0) PrintF(out_, "@%d ", id); + +#ifdef OBJECT_PRINT +#ifdef INSPECTOR + Inspector::DumpObjectType(out_, obj); +#endif // INSPECTOR + PrintF(out_, "\n"); + obj->Print(out_); +#else // !OBJECT_PRINT + obj->ShortPrint(out_); + PrintF(out_, "\n"); +#endif // !OBJECT_PRINT + Flush(out_); + } + PrintF(out_, "\n"); + PrintF(out_, "=====================================\n\n"); + Flush(out_); + } +} + + +Object* LiveObjectList::GetPathPrivate(HeapObject* obj1, HeapObject* obj2) { + EmbeddedVector temp_filename; + static int temp_count = 0; + const char* path_prefix = "."; + + if (FLAG_lol_workdir) { + path_prefix = FLAG_lol_workdir; + } + OS::SNPrintF(temp_filename, "%s/lol-getpath-%d", path_prefix, ++temp_count); + + FILE* f = OS::FOpen(temp_filename.start(), "w+"); + + // Save the previous verbosity. + bool prev_verbosity = FLAG_use_verbose_printer; + FLAG_use_verbose_printer = false; + + // Dump the paths. + { + // The tracer needs to be scoped because its usage asserts no allocation, + // and we need to allocate the result string below. + LolPathTracer tracer(f, obj2, LolPathTracer::FIND_FIRST); + + bool found = false; + if (obj1 == NULL) { + // Check for ObjectGroups that references this object. + // TODO(mlam): refactor this to be more modular. + { + List* groups = GlobalHandles::ObjectGroups(); + for (int i = 0; i < groups->length(); i++) { + ObjectGroup* group = groups->at(i); + if (group == NULL) continue; + + bool found_group = false; + List& objects = group->objects_; + for (int j = 0; j < objects.length(); j++) { + Object* object = *objects[j]; + HeapObject* hobj = HeapObject::cast(object); + if (obj2 == hobj) { + found_group = true; + break; + } + } + + if (found_group) { + PrintF(f, + "obj %p is a member of object group %p {\n", + reinterpret_cast(obj2), + reinterpret_cast(group)); + for (int j = 0; j < objects.length(); j++) { + Object* object = *objects[j]; + if (!object->IsHeapObject()) continue; + + HeapObject* hobj = HeapObject::cast(object); + int id = GetObjId(hobj); + if (id != 0) { + PrintF(f, " @%d:", id); + } else { + PrintF(f, " :"); + } + + char buffer[512]; + GenerateObjectDesc(hobj, buffer, sizeof(buffer)); + PrintF(f, " %s", buffer); + if (hobj == obj2) { + PrintF(f, " <==="); + } + PrintF(f, "\n"); + } + PrintF(f, "}\n"); + } + } + } + + PrintF(f, "path from roots to obj %p\n", reinterpret_cast(obj2)); + Heap::IterateRoots(&tracer, VISIT_ONLY_STRONG); + found = tracer.found(); + + if (!found) { + PrintF(f, " No paths found. Checking symbol tables ...\n"); + SymbolTable* symbol_table = Heap::raw_unchecked_symbol_table(); + tracer.VisitPointers(reinterpret_cast(&symbol_table), + reinterpret_cast(&symbol_table)+1); + found = tracer.found(); + if (!found) { + symbol_table->IteratePrefix(&tracer); + found = tracer.found(); + } + } + + if (!found) { + PrintF(f, " No paths found. Checking weak roots ...\n"); + // Check weak refs next. + GlobalHandles::IterateWeakRoots(&tracer); + found = tracer.found(); + } + + } else { + PrintF(f, "path from obj %p to obj %p:\n", + reinterpret_cast(obj1), reinterpret_cast(obj2)); + tracer.TracePathFrom(reinterpret_cast(&obj1)); + found = tracer.found(); + } + + if (!found) { + PrintF(f, " No paths found\n\n"); + } + } + + // Flush and clean up the dumped file. + Flush(f); + fclose(f); + + // Restore the previous verbosity. + FLAG_use_verbose_printer = prev_verbosity; + + // Create a string from the temp_file. + // Note: the mmapped resource will take care of closing the file. + MemoryMappedExternalResource* resource = + new MemoryMappedExternalResource(temp_filename.start(), true); + if (resource->exists() && !resource->is_empty()) { + ASSERT(resource->IsAscii()); + Handle path_string = + Factory::NewExternalStringFromAscii(resource); + ExternalStringTable::AddString(*path_string); + return *path_string; + } else { + delete resource; + } + return Heap::undefined_value(); +} + + +Object* LiveObjectList::GetPath(int obj_id1, + int obj_id2, + Handle instance_filter) { + HandleScope scope; + + // Get the target object. + HeapObject* obj1 = NULL; + if (obj_id1 != 0) { + obj1 = HeapObject::cast(GetObj(obj_id1)); + if (obj1 == Heap::undefined_value()) { + return obj1; + } + } + + HeapObject* obj2 = HeapObject::cast(GetObj(obj_id2)); + if (obj2 == Heap::undefined_value()) { + return obj2; + } + + return GetPathPrivate(obj1, obj2); +} + + +void LiveObjectList::DoProcessNonLive(HeapObject *obj) { + // We should only be called if we have at least one lol to search. + ASSERT(last() != NULL); + Element* element = last()->Find(obj); + if (element != NULL) { + NullifyNonLivePointer(&element->obj_); + } +} + + +void LiveObjectList::IterateElementsPrivate(ObjectVisitor* v) { + LiveObjectList* lol = last(); + while (lol != NULL) { + Element* elements = lol->elements_; + int count = lol->obj_count_; + for (int i = 0; i < count; i++) { + HeapObject** p = &elements[i].obj_; + v->VisitPointer(reinterpret_cast(p)); + } + lol = lol->prev_; + } +} + + +// Purpose: Called by GCEpilogue to purge duplicates. Not to be called by +// anyone else. +void LiveObjectList::PurgeDuplicates() { + bool is_sorted = false; + LiveObjectList* lol = last(); + if (!lol) { + return; // Nothing to purge. + } + + int total_count = lol->TotalObjCount(); + if (!total_count) { + return; // Nothing to purge. + } + + Element* elements = NewArray(total_count); + int count = 0; + + // Copy all the object elements into a consecutive array. + while (lol) { + memcpy(&elements[count], lol->elements_, lol->obj_count_ * sizeof(Element)); + count += lol->obj_count_; + lol = lol->prev_; + } + qsort(elements, total_count, sizeof(Element), + reinterpret_cast(CompareElement)); + + ASSERT(count == total_count); + + // Iterate over all objects in the consolidated list and check for dups. + total_count--; + for (int i = 0; i < total_count; ) { + Element* curr = &elements[i]; + HeapObject* curr_obj = curr->obj_; + int j = i+1; + bool done = false; + + while (!done && (j < total_count)) { + // Process if the element's object is still live after the current GC. + // Non-live objects will be converted to SMIs i.e. not HeapObjects. + if (curr_obj->IsHeapObject()) { + Element* next = &elements[j]; + HeapObject* next_obj = next->obj_; + if (next_obj->IsHeapObject()) { + if (curr_obj != next_obj) { + done = true; + continue; // Live object but no match. Move on. + } + + // NOTE: we've just GCed the LOLs. Hence, they are no longer sorted. + // Since we detected at least one need to search for entries, we'll + // sort it to enable the use of NullifyMostRecent() below. We only + // need to sort it once (except for one exception ... see below). + if (!is_sorted) { + SortAll(); + is_sorted = true; + } + + // We have a match. Need to nullify the most recent ref to this + // object. We'll keep the oldest ref: + // Note: we will nullify the element record in the LOL + // database, not in the local sorted copy of the elements. + NullifyMostRecent(curr_obj); + } + } + // Either the object was already marked for purging, or we just marked + // it. Either way, if there's more than one dup, then we need to check + // the next element for another possible dup against the current as well + // before we move on. So, here we go. + j++; + } + + // We can move on to checking the match on the next element. + i = j; + } + + DeleteArray(elements); +} + + +// Purpose: Purges dead objects and resorts the LOLs. +void LiveObjectList::GCEpiloguePrivate() { + // Note: During the GC, ConsStrings may be collected and pointers may be + // forwarded to its constituent string. As a result, we may find dupes of + // objects references in the LOL list. + // Another common way we get dups is that free chunks that have been swept + // in the oldGen heap may be kept as ByteArray objects in a free list. + // + // When we promote live objects from the youngGen, the object may be moved + // to the start of these free chunks. Since there is no free or move event + // for the free chunks, their addresses will show up 2 times: once for their + // original free ByteArray selves, and once for the newly promoted youngGen + // object. Hence, we can get a duplicate address in the LOL again. + // + // We need to eliminate these dups because the LOL implementation expects to + // only have at most one unique LOL reference to any object at any time. + PurgeDuplicates(); + + // After the GC, sweep away all free'd Elements and compact. + LiveObjectList *prev = NULL; + LiveObjectList *next = NULL; + + // Iterating from the youngest lol to the oldest lol. + for (LiveObjectList *lol = last(); lol; lol = prev) { + Element* elements = lol->elements_; + prev = lol->prev(); // Save the prev. + + // Remove any references to collected objects. + int i = 0; + while (i < lol->obj_count_) { + Element& element = elements[i]; + if (!element.obj_->IsHeapObject()) { + // If the HeapObject address was converted into a SMI, then this + // is a dead object. Copy the last element over this one. + element = elements[lol->obj_count_ - 1]; + lol->obj_count_--; + // We've just moved the last element into this index. We'll revisit + // this index again. Hence, no need to increment the iterator. + } else { + i++; // Look at the next element next. + } + } + + int new_count = lol->obj_count_; + + // Check if there are any more elements to keep after purging the dead ones. + if (new_count == 0) { + DeleteArray(elements); + lol->elements_ = NULL; + lol->capacity_ = 0; + ASSERT(lol->obj_count_ == 0); + + // If the list is also invisible, the clean up the list as well. + if (lol->id_ == 0) { + // Point the next lol's prev to this lol's prev. + if (next) { + next->prev_ = lol->prev_; + } else { + last_ = lol->prev_; + } + + // Delete this now empty and invisible lol. + delete lol; + + // Don't point the next to this lol since it is now deleted. + // Leave the next pointer pointing to the current lol. + continue; + } + + } else { + // If the obj_count_ is less than the capacity and the difference is + // greater than a specified threshold, then we should shrink the list. + int diff = lol->capacity_ - new_count; + const int kMaxUnusedSpace = 64; + if (diff > kMaxUnusedSpace) { // Threshold for shrinking. + // Shrink the list. + Element *new_elements = NewArray(new_count); + memcpy(new_elements, elements, new_count * sizeof(Element)); + + DeleteArray(elements); + lol->elements_ = new_elements; + lol->capacity_ = new_count; + } + ASSERT(lol->obj_count_ == new_count); + + lol->Sort(); // We've moved objects. Re-sort in case. + } + + // Save the next (for the previous link) in case we need it later. + next = lol; + } + +#ifdef VERIFY_LOL + if (FLAG_verify_lol) { + Verify(); + } +#endif +} + + +#ifdef VERIFY_LOL +void LiveObjectList::Verify(bool match_heap_exactly) { + OS::Print("Verifying the LiveObjectList database:\n"); + + LiveObjectList* lol = last(); + if (lol == NULL) { + OS::Print(" No lol database to verify\n"); + return; + } + + OS::Print(" Preparing the lol database ...\n"); + int total_count = lol->TotalObjCount(); + + Element* elements = NewArray(total_count); + int count = 0; + + // Copy all the object elements into a consecutive array. + OS::Print(" Copying the lol database ...\n"); + while (lol != NULL) { + memcpy(&elements[count], lol->elements_, lol->obj_count_ * sizeof(Element)); + count += lol->obj_count_; + lol = lol->prev_; + } + qsort(elements, total_count, sizeof(Element), + reinterpret_cast(CompareElement)); + + ASSERT(count == total_count); + + // Iterate over all objects in the heap and check for: + // 1. object in LOL but not in heap i.e. error. + // 2. object in heap but not in LOL (possibly not an error). Usually + // just means that we don't have the a capture of the latest heap. + // That is unless we did this verify immediately after a capture, + // and specified match_heap_exactly = true. + + int number_of_heap_objects = 0; + int number_of_matches = 0; + int number_not_in_heap = total_count; + int number_not_in_lol = 0; + + OS::Print(" Start verify ...\n"); + OS::Print(" Verifying ..."); + Flush(); + HeapIterator iterator(HeapIterator::kFilterFreeListNodes); + HeapObject* heap_obj = NULL; + while ((heap_obj = iterator.next()) != NULL) { + number_of_heap_objects++; + + // Check if the heap_obj is in the lol. + Element key; + key.obj_ = heap_obj; + + Element* result = reinterpret_cast( + bsearch(&key, elements, total_count, sizeof(Element), + reinterpret_cast(CompareElement))); + + if (result != NULL) { + number_of_matches++; + number_not_in_heap--; + // Mark it as found by changing it into a SMI (mask off low bit). + // Note: we cannot use HeapObject::cast() here because it asserts that + // the HeapObject bit is set on the address, but we're unsetting it on + // purpose here for our marking. + result->obj_ = reinterpret_cast(heap_obj->address()); + + } else { + number_not_in_lol++; + if (match_heap_exactly) { + OS::Print("heap object %p NOT in lol database\n", heap_obj); + } + } + // Show some sign of life. + if (number_of_heap_objects % 1000 == 0) { + OS::Print("."); + fflush(stdout); + } + } + OS::Print("\n"); + + // Reporting lol objects not found in the heap. + if (number_not_in_heap) { + int found = 0; + for (int i = 0; (i < total_count) && (found < number_not_in_heap); i++) { + Element& element = elements[i]; + if (element.obj_->IsHeapObject()) { + OS::Print("lol database object [%d of %d] %p NOT in heap\n", + i, total_count, element.obj_); + found++; + } + } + } + + DeleteArray(elements); + + OS::Print("number of objects in lol database %d\n", total_count); + OS::Print("number of heap objects .......... %d\n", number_of_heap_objects); + OS::Print("number of matches ............... %d\n", number_of_matches); + OS::Print("number NOT in heap .............. %d\n", number_not_in_heap); + OS::Print("number NOT in lol database ...... %d\n", number_not_in_lol); + + if (number_of_matches != total_count) { + OS::Print(" *** ERROR: " + "NOT all lol database objects match heap objects.\n"); + } + if (number_not_in_heap != 0) { + OS::Print(" *** ERROR: %d lol database objects not found in heap.\n", + number_not_in_heap); + } + if (match_heap_exactly) { + if (!(number_not_in_lol == 0)) { + OS::Print(" *** ERROR: %d heap objects NOT found in lol database.\n", + number_not_in_lol); + } + } + + ASSERT(number_of_matches == total_count); + ASSERT(number_not_in_heap == 0); + ASSERT(number_not_in_lol == (number_of_heap_objects - total_count)); + if (match_heap_exactly) { + ASSERT(total_count == number_of_heap_objects); + ASSERT(number_not_in_lol == 0); + } + + OS::Print(" Verify the lol database is sorted ...\n"); + lol = last(); + while (lol != NULL) { + Element* elements = lol->elements_; + for (int i = 0; i < lol->obj_count_ - 1; i++) { + if (elements[i].obj_ >= elements[i+1].obj_) { + OS::Print(" *** ERROR: lol %p obj[%d] %p > obj[%d] %p\n", + lol, i, elements[i].obj_, i+1, elements[i+1].obj_); + } + } + lol = lol->prev_; + } + + OS::Print(" DONE verifying.\n\n\n"); +} + + +void LiveObjectList::VerifyNotInFromSpace() { + OS::Print("VerifyNotInFromSpace() ...\n"); + LolIterator it(NULL, last()); + int i = 0; + for (it.Init(); !it.Done(); it.Next()) { + HeapObject* heap_obj = it.Obj(); + if (Heap::InFromSpace(heap_obj)) { + OS::Print(" ERROR: VerifyNotInFromSpace: [%d] obj %p in From space %p\n", + i++, heap_obj, Heap::new_space()->FromSpaceLow()); + } + } +} +#endif // VERIFY_LOL + } } // namespace v8::internal diff --git a/deps/v8/src/liveobjectlist.h b/deps/v8/src/liveobjectlist.h index 11f5c45178..423f8f0d74 100644 --- a/deps/v8/src/liveobjectlist.h +++ b/deps/v8/src/liveobjectlist.h @@ -40,54 +40,225 @@ namespace internal { #ifdef LIVE_OBJECT_LIST +#ifdef DEBUG +// The following symbol when defined enables thorough verification of lol data. +// FLAG_verify_lol will also need to set to true to enable the verification. +#define VERIFY_LOL +#endif -// Temporary stubbed out LiveObjectList implementation. + +typedef int LiveObjectType; +class LolFilter; +class LiveObjectSummary; +class DumpWriter; +class SummaryWriter; + + +// The LiveObjectList is both a mechanism for tracking a live capture of +// objects in the JS heap, as well as is the data structure which represents +// each of those captures. Unlike a snapshot, the lol is live. For example, +// if an object in a captured lol dies and is collected by the GC, the lol +// will reflect that the object is no longer available. The term +// LiveObjectList (and lol) is used to describe both the mechanism and the +// data structure depending on context of use. +// +// In captured lols, objects are tracked using their address and an object id. +// The object id is unique. Once assigned to an object, the object id can never +// be assigned to another object. That is unless all captured lols are deleted +// which allows the user to start over with a fresh set of lols and object ids. +// The uniqueness of the object ids allows the user to track specific objects +// and inspect its longevity while debugging JS code in execution. +// +// The lol comes with utility functions to capture, dump, summarize, and diff +// captured lols amongst other functionality. These functionality are +// accessible via the v8 debugger interface. class LiveObjectList { public: - inline static void GCEpilogue() {} - inline static void GCPrologue() {} - inline static void IterateElements(ObjectVisitor* v) {} - inline static void ProcessNonLive(HeapObject *obj) {} - inline static void UpdateReferencesForScavengeGC() {} + inline static void GCEpilogue(); + inline static void GCPrologue(); + inline static void IterateElements(ObjectVisitor* v); + inline static void ProcessNonLive(HeapObject *obj); + inline static void UpdateReferencesForScavengeGC(); + + // Note: LOLs can be listed by calling Dump(0, ), and 2 LOLs can be + // compared/diff'ed using Dump(, , ...). This will yield + // a verbose dump of all the objects in the resultant lists. + // Similarly, a summarized result of a LOL listing or a diff can be + // attained using the Summarize(0, ) and Summarize(, ...) respectively. - static MaybeObject* Capture() { return Heap::undefined_value(); } - static bool Delete(int id) { return false; } + static MaybeObject* Capture(); + static bool Delete(int id); static MaybeObject* Dump(int id1, int id2, int start_idx, int dump_limit, - Handle filter_obj) { - return Heap::undefined_value(); - } - static MaybeObject* Info(int start_idx, int dump_limit) { - return Heap::undefined_value(); - } - static MaybeObject* Summarize(int id1, - int id2, - Handle filter_obj) { - return Heap::undefined_value(); - } + Handle filter_obj); + static MaybeObject* Info(int start_idx, int dump_limit); + static MaybeObject* Summarize(int id1, int id2, Handle filter_obj); - static void Reset() {} - static Object* GetObj(int obj_id) { return Heap::undefined_value(); } - static Object* GetObjId(Handle address) { - return Heap::undefined_value(); - } + static void Reset(); + static Object* GetObj(int obj_id); + static int GetObjId(Object* obj); + static Object* GetObjId(Handle address); static MaybeObject* GetObjRetainers(int obj_id, Handle instance_filter, bool verbose, int start, int count, - Handle filter_obj) { - return Heap::undefined_value(); - } + Handle filter_obj); static Object* GetPath(int obj_id1, int obj_id2, - Handle instance_filter) { - return Heap::undefined_value(); + Handle instance_filter); + static Object* PrintObj(int obj_id); + + private: + + struct Element { + int id_; + HeapObject* obj_; + }; + + explicit LiveObjectList(LiveObjectList* prev, int capacity); + ~LiveObjectList(); + + static void GCEpiloguePrivate(); + static void IterateElementsPrivate(ObjectVisitor* v); + + static void DoProcessNonLive(HeapObject *obj); + + static int CompareElement(const Element* a, const Element* b); + + static Object* GetPathPrivate(HeapObject* obj1, HeapObject* obj2); + + static int GetRetainers(Handle target, + Handle instance_filter, + Handle retainers_arr, + int start, + int dump_limit, + int* total_count, + LolFilter* filter, + LiveObjectSummary *summary, + JSFunction* arguments_function, + Handle error); + + static MaybeObject* DumpPrivate(DumpWriter* writer, + int start, + int dump_limit, + LolFilter* filter); + static MaybeObject* SummarizePrivate(SummaryWriter* writer, + LolFilter* filter, + bool is_tracking_roots); + + static bool NeedLOLProcessing() { return (last() != NULL); } + static void NullifyNonLivePointer(HeapObject **p) { + // Mask out the low bit that marks this as a heap object. We'll use this + // cleared bit as an indicator that this pointer needs to be collected. + // + // Meanwhile, we still preserve its approximate value so that we don't + // have to resort the elements list all the time. + // + // Note: Doing so also makes this HeapObject* look like an SMI. Hence, + // GC pointer updater will ignore it when it gets scanned. + *p = reinterpret_cast((*p)->address()); + } + + LiveObjectList* prev() { return prev_; } + LiveObjectList* next() { return next_; } + int id() { return id_; } + + static int list_count() { return list_count_; } + static LiveObjectList* last() { return last_; } + + inline static LiveObjectList* FindLolForId(int id, LiveObjectList* start_lol); + int TotalObjCount() { return GetTotalObjCountAndSize(NULL); } + int GetTotalObjCountAndSize(int* size_p); + + bool Add(HeapObject* obj); + Element* Find(HeapObject* obj); + static void NullifyMostRecent(HeapObject* obj); + void Sort(); + static void SortAll(); + + static void PurgeDuplicates(); // Only to be called by GCEpilogue. + +#ifdef VERIFY_LOL + static void Verify(bool match_heap_exactly = false); + static void VerifyNotInFromSpace(); +#endif + + // Iterates the elements in every lol and returns the one that matches the + // specified key. If no matching element is found, then it returns NULL. + template + inline static LiveObjectList::Element* + FindElementFor(T (*GetValue)(LiveObjectList::Element*), T key); + + inline static int GetElementId(Element* element); + inline static HeapObject* GetElementObj(Element* element); + + // Instance fields. + LiveObjectList* prev_; + LiveObjectList* next_; + int id_; + int capacity_; + int obj_count_; + Element *elements_; + + // Statics for managing all the lists. + static uint32_t next_element_id_; + static int list_count_; + static int last_id_; + static LiveObjectList* first_; + static LiveObjectList* last_; + + friend class LolIterator; + friend class LolForwardIterator; + friend class LolDumpWriter; + friend class RetainersDumpWriter; + friend class RetainersSummaryWriter; + friend class UpdateLiveObjectListVisitor; +}; + + +// Helper class for updating the LiveObjectList HeapObject pointers. +class UpdateLiveObjectListVisitor: public ObjectVisitor { + public: + + void VisitPointer(Object** p) { UpdatePointer(p); } + + void VisitPointers(Object** start, Object** end) { + // Copy all HeapObject pointers in [start, end). + for (Object** p = start; p < end; p++) UpdatePointer(p); + } + + private: + // Based on Heap::ScavengeObject() but only does forwarding of pointers + // to live new space objects, and not actually keep them alive. + void UpdatePointer(Object** p) { + Object* object = *p; + if (!Heap::InNewSpace(object)) return; + + HeapObject* heap_obj = HeapObject::cast(object); + ASSERT(Heap::InFromSpace(heap_obj)); + + // We use the first word (where the map pointer usually is) of a heap + // object to record the forwarding pointer. A forwarding pointer can + // point to an old space, the code space, or the to space of the new + // generation. + MapWord first_word = heap_obj->map_word(); + + // If the first word is a forwarding address, the object has already been + // copied. + if (first_word.IsForwardingAddress()) { + *p = first_word.ToForwardingAddress(); + return; + + // Else, it's a dead object. + } else { + LiveObjectList::NullifyNonLivePointer(reinterpret_cast(p)); + } } - static Object* PrintObj(int obj_id) { return Heap::undefined_value(); } }; @@ -96,11 +267,50 @@ class LiveObjectList { class LiveObjectList { public: - static void GCEpilogue() {} - static void GCPrologue() {} - static void IterateElements(ObjectVisitor* v) {} - static void ProcessNonLive(HeapObject *obj) {} - static void UpdateReferencesForScavengeGC() {} + inline static void GCEpilogue() {} + inline static void GCPrologue() {} + inline static void IterateElements(ObjectVisitor* v) {} + inline static void ProcessNonLive(HeapObject* obj) {} + inline static void UpdateReferencesForScavengeGC() {} + + inline static MaybeObject* Capture() { return Heap::undefined_value(); } + inline static bool Delete(int id) { return false; } + inline static MaybeObject* Dump(int id1, + int id2, + int start_idx, + int dump_limit, + Handle filter_obj) { + return Heap::undefined_value(); + } + inline static MaybeObject* Info(int start_idx, int dump_limit) { + return Heap::undefined_value(); + } + inline static MaybeObject* Summarize(int id1, + int id2, + Handle filter_obj) { + return Heap::undefined_value(); + } + + inline static void Reset() {} + inline static Object* GetObj(int obj_id) { return Heap::undefined_value(); } + inline static Object* GetObjId(Handle address) { + return Heap::undefined_value(); + } + inline static MaybeObject* GetObjRetainers(int obj_id, + Handle instance_filter, + bool verbose, + int start, + int count, + Handle filter_obj) { + return Heap::undefined_value(); + } + + inline static Object* GetPath(int obj_id1, + int obj_id2, + Handle instance_filter) { + return Heap::undefined_value(); + } + inline static Object* PrintObj(int obj_id) { return Heap::undefined_value(); } }; diff --git a/deps/v8/src/mark-compact.cc b/deps/v8/src/mark-compact.cc index a3b769a8bd..a4c782c59e 100644 --- a/deps/v8/src/mark-compact.cc +++ b/deps/v8/src/mark-compact.cc @@ -1353,6 +1353,9 @@ void MarkCompactCollector::MarkLiveObjects() { // Flush code from collected candidates. FlushCode::ProcessCandidates(); + + // Clean up dead objects from the runtime profiler. + RuntimeProfiler::RemoveDeadSamples(); } @@ -1937,6 +1940,9 @@ static void SweepNewSpace(NewSpace* space) { // All pointers were updated. Update auxiliary allocation info. Heap::IncrementYoungSurvivorsCounter(survivors_size); space->set_age_mark(space->top()); + + // Update JSFunction pointers from the runtime profiler. + RuntimeProfiler::UpdateSamplesAfterScavenge(); } @@ -2535,6 +2541,7 @@ void MarkCompactCollector::UpdatePointers() { state_ = UPDATE_POINTERS; #endif UpdatingVisitor updating_visitor; + RuntimeProfiler::UpdateSamplesAfterCompact(&updating_visitor); Heap::IterateRoots(&updating_visitor, VISIT_ONLY_STRONG); GlobalHandles::IterateWeakRoots(&updating_visitor); diff --git a/deps/v8/src/messages.js b/deps/v8/src/messages.js index b7e57aa228..2c94912fdf 100644 --- a/deps/v8/src/messages.js +++ b/deps/v8/src/messages.js @@ -226,6 +226,10 @@ function FormatMessage(message) { strict_reserved_word: ["Use of future reserved word in strict mode"], strict_delete: ["Delete of an unqualified identifier in strict mode."], strict_delete_property: ["Cannot delete property '", "%0", "' of ", "%1"], + strict_const: ["Use of const in strict mode."], + strict_function: ["In strict mode code, functions can only be declared at top level or immediately within another function." ], + strict_read_only_property: ["Cannot assign to read only property '", "%0", "' of ", "%1"], + strict_cannot_assign: ["Cannot assign to read only '", "%0", "' in strict mode"], }; } var message_type = %MessageGetType(message); @@ -1059,8 +1063,8 @@ function errorToString() { } } -%FunctionSetName(errorToString, 'toString'); -%SetProperty($Error.prototype, 'toString', errorToString, DONT_ENUM); + +InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); // Boilerplate for exceptions for stack overflows. Used from // Top::StackOverflow(). diff --git a/deps/v8/src/objects-inl.h b/deps/v8/src/objects-inl.h index 24887a0efb..dedb199568 100644 --- a/deps/v8/src/objects-inl.h +++ b/deps/v8/src/objects-inl.h @@ -769,6 +769,10 @@ bool Object::HasSpecificClassOf(String* name) { MaybeObject* Object::GetElement(uint32_t index) { + // GetElement can trigger a getter which can cause allocation. + // This was not always the case. This ASSERT is here to catch + // leftover incorrect uses. + ASSERT(Heap::IsAllocationAllowed()); return GetElementWithReceiver(this, index); } @@ -2615,7 +2619,8 @@ Code::Flags Code::ComputeFlags(Kind kind, ASSERT(extra_ic_state == kNoExtraICState || (kind == CALL_IC && (ic_state == MONOMORPHIC || ic_state == MONOMORPHIC_PROTOTYPE_FAILURE)) || - (kind == STORE_IC)); + (kind == STORE_IC) || + (kind == KEYED_STORE_IC)); // Compute the bit mask. int bits = kind << kFlagsKindShift; if (in_loop) bits |= kFlagsICInLoopMask; @@ -3737,7 +3742,8 @@ MaybeObject* JSObject::SetHiddenPropertiesObject(Object* hidden_obj) { ASSERT(!IsJSGlobalProxy()); return SetPropertyPostInterceptor(Heap::hidden_symbol(), hidden_obj, - DONT_ENUM); + DONT_ENUM, + kNonStrictMode); } diff --git a/deps/v8/src/objects.cc b/deps/v8/src/objects.cc index 2d100529ea..0b7f60a908 100644 --- a/deps/v8/src/objects.cc +++ b/deps/v8/src/objects.cc @@ -1444,14 +1444,15 @@ MaybeObject* JSObject::AddProperty(String* name, MaybeObject* JSObject::SetPropertyPostInterceptor( String* name, Object* value, - PropertyAttributes attributes) { + PropertyAttributes attributes, + StrictModeFlag strict) { // Check local property, ignore interceptor. LookupResult result; LocalLookupRealNamedProperty(name, &result); if (result.IsFound()) { // An existing property, a map transition or a null descriptor was // found. Use set property to handle all these cases. - return SetProperty(&result, name, value, attributes); + return SetProperty(&result, name, value, attributes, strict); } // Add a new real property. return AddProperty(name, value, attributes); @@ -1576,7 +1577,8 @@ MaybeObject* JSObject::ConvertDescriptorToField(String* name, MaybeObject* JSObject::SetPropertyWithInterceptor( String* name, Object* value, - PropertyAttributes attributes) { + PropertyAttributes attributes, + StrictModeFlag strict) { HandleScope scope; Handle this_handle(this); Handle name_handle(name); @@ -1605,7 +1607,8 @@ MaybeObject* JSObject::SetPropertyWithInterceptor( MaybeObject* raw_result = this_handle->SetPropertyPostInterceptor(*name_handle, *value_handle, - attributes); + attributes, + strict); RETURN_IF_SCHEDULED_EXCEPTION(); return raw_result; } @@ -1613,10 +1616,11 @@ MaybeObject* JSObject::SetPropertyWithInterceptor( MaybeObject* JSObject::SetProperty(String* name, Object* value, - PropertyAttributes attributes) { + PropertyAttributes attributes, + StrictModeFlag strict) { LookupResult result; LocalLookup(name, &result); - return SetProperty(&result, name, value, attributes); + return SetProperty(&result, name, value, attributes, strict); } @@ -1896,7 +1900,8 @@ MaybeObject* JSObject::SetPropertyWithFailedAccessCheck(LookupResult* result, MaybeObject* JSObject::SetProperty(LookupResult* result, String* name, Object* value, - PropertyAttributes attributes) { + PropertyAttributes attributes, + StrictModeFlag strict) { // Make sure that the top context does not change when doing callbacks or // interceptor calls. AssertNoContextChange ncc; @@ -1923,7 +1928,8 @@ MaybeObject* JSObject::SetProperty(LookupResult* result, Object* proto = GetPrototype(); if (proto->IsNull()) return value; ASSERT(proto->IsJSGlobalObject()); - return JSObject::cast(proto)->SetProperty(result, name, value, attributes); + return JSObject::cast(proto)->SetProperty( + result, name, value, attributes, strict); } if (!result->IsProperty() && !IsJSContextExtensionObject()) { @@ -1942,7 +1948,19 @@ MaybeObject* JSObject::SetProperty(LookupResult* result, // Neither properties nor transitions found. return AddProperty(name, value, attributes); } - if (result->IsReadOnly() && result->IsProperty()) return value; + if (result->IsReadOnly() && result->IsProperty()) { + if (strict == kStrictMode) { + HandleScope scope; + Handle key(name); + Handle holder(this); + Handle args[2] = { key, holder }; + return Top::Throw(*Factory::NewTypeError("strict_read_only_property", + HandleVector(args, 2))); + + } else { + return value; + } + } // This is a real property that is not read-only, or it is a // transition or null descriptor and there are no setters in the prototypes. switch (result->type()) { @@ -1970,7 +1988,7 @@ MaybeObject* JSObject::SetProperty(LookupResult* result, value, result->holder()); case INTERCEPTOR: - return SetPropertyWithInterceptor(name, value, attributes); + return SetPropertyWithInterceptor(name, value, attributes, strict); case CONSTANT_TRANSITION: { // If the same constant function is being added we can simply // transition to the target map. @@ -5476,9 +5494,11 @@ uint32_t JSFunction::SourceHash() { bool JSFunction::IsInlineable() { if (IsBuiltin()) return false; + SharedFunctionInfo* shared_info = shared(); // Check that the function has a script associated with it. - if (!shared()->script()->IsScript()) return false; - Code* code = shared()->code(); + if (!shared_info->script()->IsScript()) return false; + if (shared_info->optimization_disabled()) return false; + Code* code = shared_info->code(); if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; // If we never ran this (unlikely) then lets try to optimize it. if (code->kind() != Code::FUNCTION) return true; @@ -6285,7 +6305,8 @@ void Code::PrintExtraICState(FILE* out, Kind kind, ExtraICState extra) { } break; case STORE_IC: - if (extra == StoreIC::kStoreICStrict) { + case KEYED_STORE_IC: + if (extra == kStrictMode) { name = "STRICT"; } break; @@ -7277,8 +7298,10 @@ MaybeObject* JSObject::GetElementPostInterceptor(Object* receiver, case EXTERNAL_INT_ELEMENTS: case EXTERNAL_UNSIGNED_INT_ELEMENTS: case EXTERNAL_FLOAT_ELEMENTS: { - MaybeObject* value = GetExternalElement(index); - if (!value->ToObjectUnchecked()->IsUndefined()) return value; + MaybeObject* maybe_value = GetExternalElement(index); + Object* value; + if (!maybe_value->ToObject(&value)) return maybe_value; + if (!value->IsUndefined()) return value; break; } case DICTIONARY_ELEMENTS: { @@ -7374,8 +7397,10 @@ MaybeObject* JSObject::GetElementWithReceiver(Object* receiver, case EXTERNAL_INT_ELEMENTS: case EXTERNAL_UNSIGNED_INT_ELEMENTS: case EXTERNAL_FLOAT_ELEMENTS: { - MaybeObject* value = GetExternalElement(index); - if (!value->ToObjectUnchecked()->IsUndefined()) return value; + MaybeObject* maybe_value = GetExternalElement(index); + Object* value; + if (!maybe_value->ToObject(&value)) return maybe_value; + if (!value->IsUndefined()) return value; break; } case DICTIONARY_ELEMENTS: { diff --git a/deps/v8/src/objects.h b/deps/v8/src/objects.h index fbfc5fdc25..de15a7398d 100644 --- a/deps/v8/src/objects.h +++ b/deps/v8/src/objects.h @@ -1361,11 +1361,13 @@ class JSObject: public HeapObject { MUST_USE_RESULT MaybeObject* SetProperty(String* key, Object* value, - PropertyAttributes attributes); + PropertyAttributes attributes, + StrictModeFlag strict); MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, String* key, Object* value, - PropertyAttributes attributes); + PropertyAttributes attributes, + StrictModeFlag strict); MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( LookupResult* result, String* name, @@ -1380,11 +1382,13 @@ class JSObject: public HeapObject { MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( String* name, Object* value, - PropertyAttributes attributes); + PropertyAttributes attributes, + StrictModeFlag strict); MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( String* name, Object* value, - PropertyAttributes attributes); + PropertyAttributes attributes, + StrictModeFlag strict); MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( String* key, Object* value, diff --git a/deps/v8/src/parser.cc b/deps/v8/src/parser.cc index 249c9ced35..8560310702 100644 --- a/deps/v8/src/parser.cc +++ b/deps/v8/src/parser.cc @@ -1106,7 +1106,20 @@ void* Parser::ParseSourceElements(ZoneList* processor, } Scanner::Location token_loc = scanner().peek_location(); - Statement* stat = ParseStatement(NULL, CHECK_OK); + + Statement* stat; + if (peek() == Token::FUNCTION) { + // FunctionDeclaration is only allowed in the context of SourceElements + // (Ecma 262 5th Edition, clause 14): + // SourceElement: + // Statement + // FunctionDeclaration + // Common language extension is to allow function declaration in place + // of any statement. This language extension is disabled in strict mode. + stat = ParseFunctionDeclaration(CHECK_OK); + } else { + stat = ParseStatement(NULL, CHECK_OK); + } if (stat == NULL || stat->IsEmpty()) { directive_prologue = false; // End of directive prologue. @@ -1263,8 +1276,17 @@ Statement* Parser::ParseStatement(ZoneStringList* labels, bool* ok) { return result; } - case Token::FUNCTION: + case Token::FUNCTION: { + // In strict mode, FunctionDeclaration is only allowed in the context + // of SourceElements. + if (temp_scope_->StrictMode()) { + ReportMessageAt(scanner().peek_location(), "strict_function", + Vector::empty()); + *ok = false; + return NULL; + } return ParseFunctionDeclaration(ok); + } case Token::NATIVE: return ParseNativeDeclaration(ok); @@ -1515,6 +1537,11 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN, Consume(Token::VAR); } else if (peek() == Token::CONST) { Consume(Token::CONST); + if (temp_scope_->StrictMode()) { + ReportMessage("strict_const", Vector::empty()); + *ok = false; + return NULL; + } mode = Variable::CONST; is_const = true; } else { @@ -1634,34 +1661,49 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN, if (top_scope_->is_global_scope()) { // Compute the arguments for the runtime call. - ZoneList* arguments = new ZoneList(2); - // Be careful not to assign a value to the global variable if - // we're in a with. The initialization value should not - // necessarily be stored in the global object in that case, - // which is why we need to generate a separate assignment node. + ZoneList* arguments = new ZoneList(3); arguments->Add(new Literal(name)); // we have at least 1 parameter - if (is_const || (value != NULL && !inside_with())) { - arguments->Add(value); - value = NULL; // zap the value to avoid the unnecessary assignment - } - // Construct the call to Runtime::DeclareGlobal{Variable,Const}Locally - // and add it to the initialization statement block. Note that - // this function does different things depending on if we have - // 1 or 2 parameters. CallRuntime* initialize; + if (is_const) { + arguments->Add(value); + value = NULL; // zap the value to avoid the unnecessary assignment + + // Construct the call to Runtime_InitializeConstGlobal + // and add it to the initialization statement block. + // Note that the function does different things depending on + // the number of arguments (1 or 2). initialize = - new CallRuntime( - Factory::InitializeConstGlobal_symbol(), - Runtime::FunctionForId(Runtime::kInitializeConstGlobal), - arguments); + new CallRuntime( + Factory::InitializeConstGlobal_symbol(), + Runtime::FunctionForId(Runtime::kInitializeConstGlobal), + arguments); } else { + // Add strict mode. + // We may want to pass singleton to avoid Literal allocations. + arguments->Add(NewNumberLiteral( + temp_scope_->StrictMode() ? kStrictMode : kNonStrictMode)); + + // Be careful not to assign a value to the global variable if + // we're in a with. The initialization value should not + // necessarily be stored in the global object in that case, + // which is why we need to generate a separate assignment node. + if (value != NULL && !inside_with()) { + arguments->Add(value); + value = NULL; // zap the value to avoid the unnecessary assignment + } + + // Construct the call to Runtime_InitializeVarGlobal + // and add it to the initialization statement block. + // Note that the function does different things depending on + // the number of arguments (2 or 3). initialize = - new CallRuntime( - Factory::InitializeVarGlobal_symbol(), - Runtime::FunctionForId(Runtime::kInitializeVarGlobal), - arguments); + new CallRuntime( + Factory::InitializeVarGlobal_symbol(), + Runtime::FunctionForId(Runtime::kInitializeVarGlobal), + arguments); } + block->AddStatement(new ExpressionStatement(initialize)); } diff --git a/deps/v8/src/platform-solaris.cc b/deps/v8/src/platform-solaris.cc index ebe0475f4d..6051fb0c4f 100644 --- a/deps/v8/src/platform-solaris.cc +++ b/deps/v8/src/platform-solaris.cc @@ -45,7 +45,7 @@ #include #include // finite() #include // sigemptyset(), etc -#include +#include #undef MAP_TYPE @@ -612,11 +612,16 @@ static Sampler* active_sampler_ = NULL; static pthread_t vm_tid_ = 0; +static pthread_t GetThreadID() { + return pthread_self(); +} + + static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { USE(info); if (signal != SIGPROF) return; if (active_sampler_ == NULL || !active_sampler_->IsActive()) return; - if (vm_tid_ != pthread_self()) return; + if (vm_tid_ != GetThreadID()) return; TickSample sample_obj; TickSample* sample = CpuProfiler::TickSampleEvent(); @@ -627,17 +632,10 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { mcontext_t& mcontext = ucontext->uc_mcontext; sample->state = Top::current_vm_state(); -#if V8_HOST_ARCH_IA32 - sample->pc = reinterpret_cast
(mcontext.gregs[KDIREG_EIP]); - sample->sp = reinterpret_cast
(mcontext.gregs[KDIREG_ESP]); - sample->fp = reinterpret_cast
(mcontext.gregs[KDIREG_EBP]); -#elif V8_HOST_ARCH_X64 - sample->pc = reinterpret_cast
(mcontext.gregs[KDIREG_RIP]); - sample->sp = reinterpret_cast
(mcontext.gregs[KDIREG_RSP]); - sample->fp = reinterpret_cast
(mcontext.gregs[KDIREG_RBP]); -#else - UNIMPLEMENTED(); -#endif + sample->pc = reinterpret_cast
(mcontext.gregs[REG_PC]); + sample->sp = reinterpret_cast
(mcontext.gregs[REG_SP]); + sample->fp = reinterpret_cast
(mcontext.gregs[REG_FP]); + active_sampler_->SampleStack(sample); active_sampler_->Tick(sample); } @@ -645,26 +643,86 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { class Sampler::PlatformData : public Malloced { public: - PlatformData() { - signal_handler_installed_ = false; + enum SleepInterval { + FULL_INTERVAL, + HALF_INTERVAL + }; + + explicit PlatformData(Sampler* sampler) + : sampler_(sampler), + signal_handler_installed_(false), + vm_tgid_(getpid()), + signal_sender_launched_(false) { + } + + void SignalSender() { + while (sampler_->IsActive()) { + if (rate_limiter_.SuspendIfNecessary()) continue; + if (sampler_->IsProfiling() && RuntimeProfiler::IsEnabled()) { + SendProfilingSignal(); + Sleep(HALF_INTERVAL); + RuntimeProfiler::NotifyTick(); + Sleep(HALF_INTERVAL); + } else { + if (sampler_->IsProfiling()) SendProfilingSignal(); + if (RuntimeProfiler::IsEnabled()) RuntimeProfiler::NotifyTick(); + Sleep(FULL_INTERVAL); + } + } + } + + void SendProfilingSignal() { + if (!signal_handler_installed_) return; + pthread_kill(vm_tid_, SIGPROF); + } + + void Sleep(SleepInterval full_or_half) { + // Convert ms to us and subtract 100 us to compensate delays + // occuring during signal delivery. + useconds_t interval = sampler_->interval_ * 1000 - 100; + if (full_or_half == HALF_INTERVAL) interval /= 2; + int result = usleep(interval); +#ifdef DEBUG + if (result != 0 && errno != EINTR) { + fprintf(stderr, + "SignalSender usleep error; interval = %u, errno = %d\n", + interval, + errno); + ASSERT(result == 0 || errno == EINTR); + } +#endif + USE(result); } + Sampler* sampler_; bool signal_handler_installed_; struct sigaction old_signal_handler_; - struct itimerval old_timer_value_; + int vm_tgid_; + bool signal_sender_launched_; + pthread_t signal_sender_thread_; + RuntimeProfilerRateLimiter rate_limiter_; }; +static void* SenderEntry(void* arg) { + Sampler::PlatformData* data = + reinterpret_cast(arg); + data->SignalSender(); + return 0; +} + + Sampler::Sampler(int interval) : interval_(interval), profiling_(false), active_(false), samples_taken_(0) { - data_ = new PlatformData(); + data_ = new PlatformData(this); } Sampler::~Sampler() { + ASSERT(!data_->signal_sender_launched_); delete data_; } @@ -672,43 +730,53 @@ Sampler::~Sampler() { void Sampler::Start() { // There can only be one active sampler at the time on POSIX // platforms. - if (active_sampler_ != NULL) return; + ASSERT(!IsActive()); + vm_tid_ = GetThreadID(); // Request profiling signals. struct sigaction sa; sa.sa_sigaction = ProfilerSignalHandler; sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_SIGINFO; - if (sigaction(SIGPROF, &sa, &data_->old_signal_handler_) != 0) return; - data_->signal_handler_installed_ = true; - - // Set the itimer to generate a tick for each interval. - itimerval itimer; - itimer.it_interval.tv_sec = interval_ / 1000; - itimer.it_interval.tv_usec = (interval_ % 1000) * 1000; - itimer.it_value.tv_sec = itimer.it_interval.tv_sec; - itimer.it_value.tv_usec = itimer.it_interval.tv_usec; - setitimer(ITIMER_PROF, &itimer, &data_->old_timer_value_); + sa.sa_flags = SA_RESTART | SA_SIGINFO; + data_->signal_handler_installed_ = + sigaction(SIGPROF, &sa, &data_->old_signal_handler_) == 0; + + // Start a thread that sends SIGPROF signal to VM thread. + // Sending the signal ourselves instead of relying on itimer provides + // much better accuracy. + SetActive(true); + if (pthread_create( + &data_->signal_sender_thread_, NULL, SenderEntry, data_) == 0) { + data_->signal_sender_launched_ = true; + } // Set this sampler as the active sampler. active_sampler_ = this; - active_ = true; } void Sampler::Stop() { + SetActive(false); + + // Wait for signal sender termination (it will exit after setting + // active_ to false). + if (data_->signal_sender_launched_) { + Top::WakeUpRuntimeProfilerThreadBeforeShutdown(); + pthread_join(data_->signal_sender_thread_, NULL); + data_->signal_sender_launched_ = false; + } + // Restore old signal handler if (data_->signal_handler_installed_) { - setitimer(ITIMER_PROF, &data_->old_timer_value_, NULL); sigaction(SIGPROF, &data_->old_signal_handler_, 0); data_->signal_handler_installed_ = false; } // This sampler is no longer the active sampler. active_sampler_ = NULL; - active_ = false; } + #endif // ENABLE_LOGGING_AND_PROFILING } } // namespace v8::internal diff --git a/deps/v8/src/profile-generator-inl.h b/deps/v8/src/profile-generator-inl.h index 4bcfa9b1ec..747e5c7271 100644 --- a/deps/v8/src/profile-generator-inl.h +++ b/deps/v8/src/profile-generator-inl.h @@ -121,34 +121,6 @@ uint64_t HeapEntry::id() { return id_adaptor.returned_id; } - -template -void HeapEntriesMap::UpdateEntries(Visitor* visitor) { - for (HashMap::Entry* p = entries_.Start(); - p != NULL; - p = entries_.Next(p)) { - EntryInfo* entry_info = reinterpret_cast(p->value); - entry_info->entry = visitor->GetEntry( - reinterpret_cast(p->key), - entry_info->children_count, - entry_info->retainers_count); - entry_info->children_count = 0; - entry_info->retainers_count = 0; - } -} - - -bool HeapSnapshotGenerator::ReportProgress(bool force) { - const int kProgressReportGranularity = 10000; - if (control_ != NULL - && (force || progress_counter_ % kProgressReportGranularity == 0)) { - return - control_->ReportProgressValue(progress_counter_, progress_total_) == - v8::ActivityControl::kContinue; - } - return true; -} - } } // namespace v8::internal #endif // ENABLE_LOGGING_AND_PROFILING diff --git a/deps/v8/src/profile-generator.cc b/deps/v8/src/profile-generator.cc index 261b3d6ff0..7612eab993 100644 --- a/deps/v8/src/profile-generator.cc +++ b/deps/v8/src/profile-generator.cc @@ -1177,12 +1177,6 @@ void HeapGraphPath::Print() { } -HeapObject *const HeapSnapshot::kInternalRootObject = - reinterpret_cast(1); -HeapObject *const HeapSnapshot::kGcRootsObject = - reinterpret_cast(2); - - // It is very important to keep objects that form a heap snapshot // as small as possible. namespace { // Avoid littering the global namespace. @@ -1253,96 +1247,6 @@ void HeapSnapshot::AllocateEntries(int entries_count, } -HeapEntry* HeapSnapshot::AddEntry(HeapObject* object, - int children_count, - int retainers_count) { - if (object == kInternalRootObject) { - ASSERT(root_entry_ == NULL); - ASSERT(retainers_count == 0); - return (root_entry_ = AddEntry(HeapEntry::kObject, - "", - HeapObjectsMap::kInternalRootObjectId, - 0, - children_count, - retainers_count)); - } else if (object == kGcRootsObject) { - ASSERT(gc_roots_entry_ == NULL); - return (gc_roots_entry_ = AddEntry(HeapEntry::kObject, - "(GC roots)", - HeapObjectsMap::kGcRootsObjectId, - 0, - children_count, - retainers_count)); - } else if (object->IsJSFunction()) { - JSFunction* func = JSFunction::cast(object); - SharedFunctionInfo* shared = func->shared(); - return AddEntry(object, - HeapEntry::kClosure, - collection_->GetName(String::cast(shared->name())), - children_count, - retainers_count); - } else if (object->IsJSRegExp()) { - JSRegExp* re = JSRegExp::cast(object); - return AddEntry(object, - HeapEntry::kRegExp, - collection_->GetName(re->Pattern()), - children_count, - retainers_count); - } else if (object->IsJSObject()) { - return AddEntry(object, - HeapEntry::kObject, - collection_->GetName(GetConstructorNameForHeapProfile( - JSObject::cast(object))), - children_count, - retainers_count); - } else if (object->IsString()) { - return AddEntry(object, - HeapEntry::kString, - collection_->GetName(String::cast(object)), - children_count, - retainers_count); - } else if (object->IsCode()) { - return AddEntry(object, - HeapEntry::kCode, - "", - children_count, - retainers_count); - } else if (object->IsSharedFunctionInfo()) { - SharedFunctionInfo* shared = SharedFunctionInfo::cast(object); - return AddEntry(object, - HeapEntry::kCode, - collection_->GetName(String::cast(shared->name())), - children_count, - retainers_count); - } else if (object->IsScript()) { - Script* script = Script::cast(object); - return AddEntry(object, - HeapEntry::kCode, - script->name()->IsString() ? - collection_->GetName(String::cast(script->name())) : "", - children_count, - retainers_count); - } else if (object->IsFixedArray()) { - return AddEntry(object, - HeapEntry::kArray, - "", - children_count, - retainers_count); - } else if (object->IsHeapNumber()) { - return AddEntry(object, - HeapEntry::kHeapNumber, - "number", - children_count, - retainers_count); - } - return AddEntry(object, - HeapEntry::kHidden, - "system", - children_count, - retainers_count); -} - - static void HeapEntryClearPaint(HeapEntry** entry_ptr) { (*entry_ptr)->clear_paint(); } @@ -1352,17 +1256,26 @@ void HeapSnapshot::ClearPaint() { } -HeapEntry* HeapSnapshot::AddEntry(HeapObject* object, - HeapEntry::Type type, - const char* name, - int children_count, - int retainers_count) { - return AddEntry(type, - name, - collection_->GetObjectId(object->address()), - object->Size(), - children_count, - retainers_count); +HeapEntry* HeapSnapshot::AddRootEntry(int children_count) { + ASSERT(root_entry_ == NULL); + return (root_entry_ = AddEntry(HeapEntry::kObject, + "", + HeapObjectsMap::kInternalRootObjectId, + 0, + children_count, + 0)); +} + + +HeapEntry* HeapSnapshot::AddGcRootsEntry(int children_count, + int retainers_count) { + ASSERT(gc_roots_entry_ == NULL); + return (gc_roots_entry_ = AddEntry(HeapEntry::kObject, + "(GC roots)", + HeapObjectsMap::kGcRootsObjectId, + 0, + children_count, + retainers_count)); } @@ -1615,7 +1528,7 @@ HeapEntry *const HeapEntriesMap::kHeapEntryPlaceholder = reinterpret_cast(1); HeapEntriesMap::HeapEntriesMap() - : entries_(HeapObjectsMatch), + : entries_(HeapThingsMatch), entries_count_(0), total_children_count_(0), total_retainers_count_(0) { @@ -1629,8 +1542,23 @@ HeapEntriesMap::~HeapEntriesMap() { } -HeapEntry* HeapEntriesMap::Map(HeapObject* object) { - HashMap::Entry* cache_entry = entries_.Lookup(object, Hash(object), false); +void HeapEntriesMap::AllocateEntries() { + for (HashMap::Entry* p = entries_.Start(); + p != NULL; + p = entries_.Next(p)) { + EntryInfo* entry_info = reinterpret_cast(p->value); + entry_info->entry = entry_info->allocator->AllocateEntry( + p->key, + entry_info->children_count, + entry_info->retainers_count); + entry_info->children_count = 0; + entry_info->retainers_count = 0; + } +} + + +HeapEntry* HeapEntriesMap::Map(HeapThing thing) { + HashMap::Entry* cache_entry = entries_.Lookup(thing, Hash(thing), false); if (cache_entry != NULL) { EntryInfo* entry_info = reinterpret_cast(cache_entry->value); return entry_info->entry; @@ -1640,15 +1568,16 @@ HeapEntry* HeapEntriesMap::Map(HeapObject* object) { } -void HeapEntriesMap::Pair(HeapObject* object, HeapEntry* entry) { - HashMap::Entry* cache_entry = entries_.Lookup(object, Hash(object), true); +void HeapEntriesMap::Pair( + HeapThing thing, HeapEntriesAllocator* allocator, HeapEntry* entry) { + HashMap::Entry* cache_entry = entries_.Lookup(thing, Hash(thing), true); ASSERT(cache_entry->value == NULL); - cache_entry->value = new EntryInfo(entry); + cache_entry->value = new EntryInfo(entry, allocator); ++entries_count_; } -void HeapEntriesMap::CountReference(HeapObject* from, HeapObject* to, +void HeapEntriesMap::CountReference(HeapThing from, HeapThing to, int* prev_children_count, int* prev_retainers_count) { HashMap::Entry* from_cache_entry = entries_.Lookup(from, Hash(from), false); @@ -1671,7 +1600,7 @@ void HeapEntriesMap::CountReference(HeapObject* from, HeapObject* to, HeapObjectsSet::HeapObjectsSet() - : entries_(HeapEntriesMap::HeapObjectsMatch) { + : entries_(HeapEntriesMap::HeapThingsMatch) { } @@ -1700,206 +1629,144 @@ void HeapObjectsSet::Insert(Object* obj) { } -HeapSnapshotGenerator::HeapSnapshotGenerator(HeapSnapshot* snapshot, - v8::ActivityControl* control) +HeapObject *const V8HeapExplorer::kInternalRootObject = + reinterpret_cast(1); +HeapObject *const V8HeapExplorer::kGcRootsObject = + reinterpret_cast(2); + + +V8HeapExplorer::V8HeapExplorer( + HeapSnapshot* snapshot, + SnapshottingProgressReportingInterface* progress) : snapshot_(snapshot), - control_(control), - collection_(snapshot->collection()), + collection_(snapshot_->collection()), + progress_(progress), filler_(NULL) { } -class SnapshotCounter : public HeapSnapshotGenerator::SnapshotFillerInterface { - public: - explicit SnapshotCounter(HeapEntriesMap* entries) - : entries_(entries) { } - HeapEntry* AddEntry(HeapObject* obj) { - entries_->Pair(obj, HeapEntriesMap::kHeapEntryPlaceholder); - return HeapEntriesMap::kHeapEntryPlaceholder; - } - void SetIndexedReference(HeapGraphEdge::Type, - HeapObject* parent_obj, - HeapEntry*, - int, - Object* child_obj, - HeapEntry*) { - entries_->CountReference(parent_obj, HeapObject::cast(child_obj)); - } - void SetNamedReference(HeapGraphEdge::Type, - HeapObject* parent_obj, - HeapEntry*, - const char*, - Object* child_obj, - HeapEntry*) { - entries_->CountReference(parent_obj, HeapObject::cast(child_obj)); - } - void SetRootShortcutReference(Object* child_obj, HeapEntry*) { - entries_->CountReference( - HeapSnapshot::kInternalRootObject, HeapObject::cast(child_obj)); - } - void SetRootGcRootsReference() { - entries_->CountReference( - HeapSnapshot::kInternalRootObject, HeapSnapshot::kGcRootsObject); - } - void SetStrongRootReference(Object* child_obj, HeapEntry*) { - entries_->CountReference( - HeapSnapshot::kGcRootsObject, HeapObject::cast(child_obj)); - } - private: - HeapEntriesMap* entries_; -}; - - -class SnapshotFiller : public HeapSnapshotGenerator::SnapshotFillerInterface { - public: - explicit SnapshotFiller(HeapSnapshot* snapshot, HeapEntriesMap* entries) - : snapshot_(snapshot), - collection_(snapshot->collection()), - entries_(entries) { } - HeapEntry* AddEntry(HeapObject* obj) { - UNREACHABLE(); - return NULL; - } - void SetIndexedReference(HeapGraphEdge::Type type, - HeapObject* parent_obj, - HeapEntry* parent_entry, - int index, - Object* child_obj, - HeapEntry* child_entry) { - int child_index, retainer_index; - entries_->CountReference(parent_obj, - HeapObject::cast(child_obj), - &child_index, - &retainer_index); - parent_entry->SetIndexedReference( - type, child_index, index, child_entry, retainer_index); - } - void SetNamedReference(HeapGraphEdge::Type type, - HeapObject* parent_obj, - HeapEntry* parent_entry, - const char* reference_name, - Object* child_obj, - HeapEntry* child_entry) { - int child_index, retainer_index; - entries_->CountReference(parent_obj, HeapObject::cast(child_obj), - &child_index, &retainer_index); - parent_entry->SetNamedReference(type, - child_index, - reference_name, - child_entry, - retainer_index); - } - void SetRootGcRootsReference() { - int child_index, retainer_index; - entries_->CountReference(HeapSnapshot::kInternalRootObject, - HeapSnapshot::kGcRootsObject, - &child_index, - &retainer_index); - snapshot_->root()->SetIndexedReference(HeapGraphEdge::kElement, - child_index, - child_index + 1, - snapshot_->gc_roots(), - retainer_index); - } - void SetRootShortcutReference(Object* child_obj, - HeapEntry* child_entry) { - int child_index, retainer_index; - entries_->CountReference(HeapSnapshot::kInternalRootObject, - HeapObject::cast(child_obj), - &child_index, - &retainer_index); - snapshot_->root()->SetNamedReference(HeapGraphEdge::kShortcut, - child_index, - collection_->GetName(child_index + 1), - child_entry, - retainer_index); - } - void SetStrongRootReference(Object* child_obj, - HeapEntry* child_entry) { - int child_index, retainer_index; - entries_->CountReference(HeapSnapshot::kGcRootsObject, - HeapObject::cast(child_obj), - &child_index, - &retainer_index); - snapshot_->gc_roots()->SetIndexedReference(HeapGraphEdge::kElement, - child_index, - child_index + 1, - child_entry, - retainer_index); - } - private: - HeapSnapshot* snapshot_; - HeapSnapshotsCollection* collection_; - HeapEntriesMap* entries_; -}; -class SnapshotAllocator { - public: - explicit SnapshotAllocator(HeapSnapshot* snapshot) - : snapshot_(snapshot) { } - HeapEntry* GetEntry( - HeapObject* obj, int children_count, int retainers_count) { - HeapEntry* entry = - snapshot_->AddEntry(obj, children_count, retainers_count); - ASSERT(entry != NULL); - return entry; - } - private: - HeapSnapshot* snapshot_; -}; - -class RootsReferencesExtractor : public ObjectVisitor { - public: - explicit RootsReferencesExtractor(HeapSnapshotGenerator* generator) - : generator_(generator) { - } - void VisitPointers(Object** start, Object** end) { - for (Object** p = start; p < end; p++) generator_->SetGcRootsReference(*p); - } - private: - HeapSnapshotGenerator* generator_; -}; +V8HeapExplorer::~V8HeapExplorer() { +} -bool HeapSnapshotGenerator::GenerateSnapshot() { - AssertNoAllocation no_alloc; +HeapEntry* V8HeapExplorer::AllocateEntry( + HeapThing ptr, int children_count, int retainers_count) { + return AddEntry( + reinterpret_cast(ptr), children_count, retainers_count); +} - SetProgressTotal(4); // 2 passes + dominators + sizes. - // Pass 1. Iterate heap contents to count entries and references. - if (!CountEntriesAndReferences()) return false; +HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object, + int children_count, + int retainers_count) { + if (object == kInternalRootObject) { + ASSERT(retainers_count == 0); + return snapshot_->AddRootEntry(children_count); + } else if (object == kGcRootsObject) { + return snapshot_->AddGcRootsEntry(children_count, retainers_count); + } else if (object->IsJSFunction()) { + JSFunction* func = JSFunction::cast(object); + SharedFunctionInfo* shared = func->shared(); + return AddEntry(object, + HeapEntry::kClosure, + collection_->GetName(String::cast(shared->name())), + children_count, + retainers_count); + } else if (object->IsJSRegExp()) { + JSRegExp* re = JSRegExp::cast(object); + return AddEntry(object, + HeapEntry::kRegExp, + collection_->GetName(re->Pattern()), + children_count, + retainers_count); + } else if (object->IsJSObject()) { + return AddEntry(object, + HeapEntry::kObject, + collection_->GetName(GetConstructorNameForHeapProfile( + JSObject::cast(object))), + children_count, + retainers_count); + } else if (object->IsString()) { + return AddEntry(object, + HeapEntry::kString, + collection_->GetName(String::cast(object)), + children_count, + retainers_count); + } else if (object->IsCode()) { + return AddEntry(object, + HeapEntry::kCode, + "", + children_count, + retainers_count); + } else if (object->IsSharedFunctionInfo()) { + SharedFunctionInfo* shared = SharedFunctionInfo::cast(object); + return AddEntry(object, + HeapEntry::kCode, + collection_->GetName(String::cast(shared->name())), + children_count, + retainers_count); + } else if (object->IsScript()) { + Script* script = Script::cast(object); + return AddEntry(object, + HeapEntry::kCode, + script->name()->IsString() ? + collection_->GetName(String::cast(script->name())) : "", + children_count, + retainers_count); + } else if (object->IsFixedArray()) { + return AddEntry(object, + HeapEntry::kArray, + "", + children_count, + retainers_count); + } else if (object->IsHeapNumber()) { + return AddEntry(object, + HeapEntry::kHeapNumber, + "number", + children_count, + retainers_count); + } + return AddEntry(object, + HeapEntry::kHidden, + "system", + children_count, + retainers_count); +} - // Allocate and fill entries in the snapshot, allocate references. - snapshot_->AllocateEntries(entries_.entries_count(), - entries_.total_children_count(), - entries_.total_retainers_count()); - SnapshotAllocator allocator(snapshot_); - entries_.UpdateEntries(&allocator); - // Pass 2. Fill references. - if (!FillReferences()) return false; +HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object, + HeapEntry::Type type, + const char* name, + int children_count, + int retainers_count) { + return snapshot_->AddEntry(type, + name, + collection_->GetObjectId(object->address()), + object->Size(), + children_count, + retainers_count); +} - if (!SetEntriesDominators()) return false; - if (!ApproximateRetainedSizes()) return false; - progress_counter_ = progress_total_; - if (!ReportProgress(true)) return false; - return true; +void V8HeapExplorer::AddRootEntries(SnapshotFillerInterface* filler) { + filler->AddEntry(kInternalRootObject); + filler->AddEntry(kGcRootsObject); } -HeapEntry* HeapSnapshotGenerator::GetEntry(Object* obj) { - if (!obj->IsHeapObject()) return NULL; - HeapObject* object = HeapObject::cast(obj); - HeapEntry* entry = entries_.Map(object); - // A new entry. - if (entry == NULL) entry = filler_->AddEntry(object); - return entry; +int V8HeapExplorer::EstimateObjectsCount() { + HeapIterator iterator(HeapIterator::kFilterUnreachable); + int objects_count = 0; + for (HeapObject* obj = iterator.next(); + obj != NULL; + obj = iterator.next(), ++objects_count) {} + return objects_count; } class IndexedReferencesExtractor : public ObjectVisitor { public: - IndexedReferencesExtractor(HeapSnapshotGenerator* generator, + IndexedReferencesExtractor(V8HeapExplorer* generator, HeapObject* parent_obj, HeapEntry* parent_entry, HeapObjectsSet* known_references = NULL) @@ -1917,7 +1784,7 @@ class IndexedReferencesExtractor : public ObjectVisitor { } } private: - HeapSnapshotGenerator* generator_; + V8HeapExplorer* generator_; HeapObject* parent_obj_; HeapEntry* parent_; HeapObjectsSet* known_references_; @@ -1925,7 +1792,7 @@ class IndexedReferencesExtractor : public ObjectVisitor { }; -void HeapSnapshotGenerator::ExtractReferences(HeapObject* obj) { +void V8HeapExplorer::ExtractReferences(HeapObject* obj) { HeapEntry* entry = GetEntry(obj); if (entry == NULL) return; // No interest in this object. @@ -1969,8 +1836,8 @@ void HeapSnapshotGenerator::ExtractReferences(HeapObject* obj) { } -void HeapSnapshotGenerator::ExtractClosureReferences(JSObject* js_obj, - HeapEntry* entry) { +void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, + HeapEntry* entry) { if (js_obj->IsJSFunction()) { HandleScope hs; JSFunction* func = JSFunction::cast(js_obj); @@ -1992,8 +1859,8 @@ void HeapSnapshotGenerator::ExtractClosureReferences(JSObject* js_obj, } -void HeapSnapshotGenerator::ExtractPropertyReferences(JSObject* js_obj, - HeapEntry* entry) { +void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, + HeapEntry* entry) { if (js_obj->HasFastProperties()) { DescriptorArray* descs = js_obj->map()->instance_descriptors(); for (int i = 0; i < descs->number_of_descriptors(); i++) { @@ -2034,8 +1901,8 @@ void HeapSnapshotGenerator::ExtractPropertyReferences(JSObject* js_obj, } -void HeapSnapshotGenerator::ExtractElementReferences(JSObject* js_obj, - HeapEntry* entry) { +void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, + HeapEntry* entry) { if (js_obj->HasFastElements()) { FixedArray* elements = FixedArray::cast(js_obj->elements()); int length = js_obj->IsJSArray() ? @@ -2061,8 +1928,8 @@ void HeapSnapshotGenerator::ExtractElementReferences(JSObject* js_obj, } -void HeapSnapshotGenerator::ExtractInternalReferences(JSObject* js_obj, - HeapEntry* entry) { +void V8HeapExplorer::ExtractInternalReferences(JSObject* js_obj, + HeapEntry* entry) { int length = js_obj->GetInternalFieldCount(); for (int i = 0; i < length; ++i) { Object* o = js_obj->GetInternalField(i); @@ -2071,10 +1938,55 @@ void HeapSnapshotGenerator::ExtractInternalReferences(JSObject* js_obj, } -void HeapSnapshotGenerator::SetClosureReference(HeapObject* parent_obj, - HeapEntry* parent_entry, - String* reference_name, - Object* child_obj) { +HeapEntry* V8HeapExplorer::GetEntry(Object* obj) { + if (!obj->IsHeapObject()) return NULL; + return filler_->FindOrAddEntry(obj); +} + + +class RootsReferencesExtractor : public ObjectVisitor { + public: + explicit RootsReferencesExtractor(V8HeapExplorer* explorer) + : explorer_(explorer) { + } + void VisitPointers(Object** start, Object** end) { + for (Object** p = start; p < end; p++) explorer_->SetGcRootsReference(*p); + } + private: + V8HeapExplorer* explorer_; +}; + + +bool V8HeapExplorer::IterateAndExtractReferences( + SnapshotFillerInterface* filler) { + filler_ = filler; + HeapIterator iterator(HeapIterator::kFilterUnreachable); + bool interrupted = false; + // Heap iteration with filtering must be finished in any case. + for (HeapObject* obj = iterator.next(); + obj != NULL; + obj = iterator.next(), progress_->ProgressStep()) { + if (!interrupted) { + ExtractReferences(obj); + if (!progress_->ProgressReport(false)) interrupted = true; + } + } + if (interrupted) { + filler_ = NULL; + return false; + } + SetRootGcRootsReference(); + RootsReferencesExtractor extractor(this); + Heap::IterateRoots(&extractor, VISIT_ALL); + filler_ = NULL; + return progress_->ProgressReport(false); +} + + +void V8HeapExplorer::SetClosureReference(HeapObject* parent_obj, + HeapEntry* parent_entry, + String* reference_name, + Object* child_obj) { HeapEntry* child_entry = GetEntry(child_obj); if (child_entry != NULL) { filler_->SetNamedReference(HeapGraphEdge::kContextVariable, @@ -2088,10 +2000,10 @@ void HeapSnapshotGenerator::SetClosureReference(HeapObject* parent_obj, } -void HeapSnapshotGenerator::SetElementReference(HeapObject* parent_obj, - HeapEntry* parent_entry, - int index, - Object* child_obj) { +void V8HeapExplorer::SetElementReference(HeapObject* parent_obj, + HeapEntry* parent_entry, + int index, + Object* child_obj) { HeapEntry* child_entry = GetEntry(child_obj); if (child_entry != NULL) { filler_->SetIndexedReference(HeapGraphEdge::kElement, @@ -2105,10 +2017,10 @@ void HeapSnapshotGenerator::SetElementReference(HeapObject* parent_obj, } -void HeapSnapshotGenerator::SetInternalReference(HeapObject* parent_obj, - HeapEntry* parent_entry, - const char* reference_name, - Object* child_obj) { +void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj, + HeapEntry* parent_entry, + const char* reference_name, + Object* child_obj) { HeapEntry* child_entry = GetEntry(child_obj); if (child_entry != NULL) { filler_->SetNamedReference(HeapGraphEdge::kInternal, @@ -2122,10 +2034,10 @@ void HeapSnapshotGenerator::SetInternalReference(HeapObject* parent_obj, } -void HeapSnapshotGenerator::SetInternalReference(HeapObject* parent_obj, - HeapEntry* parent_entry, - int index, - Object* child_obj) { +void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj, + HeapEntry* parent_entry, + int index, + Object* child_obj) { HeapEntry* child_entry = GetEntry(child_obj); if (child_entry != NULL) { filler_->SetNamedReference(HeapGraphEdge::kInternal, @@ -2139,10 +2051,10 @@ void HeapSnapshotGenerator::SetInternalReference(HeapObject* parent_obj, } -void HeapSnapshotGenerator::SetHiddenReference(HeapObject* parent_obj, - HeapEntry* parent_entry, - int index, - Object* child_obj) { +void V8HeapExplorer::SetHiddenReference(HeapObject* parent_obj, + HeapEntry* parent_entry, + int index, + Object* child_obj) { HeapEntry* child_entry = GetEntry(child_obj); if (child_entry != NULL) { filler_->SetIndexedReference(HeapGraphEdge::kHidden, @@ -2155,10 +2067,10 @@ void HeapSnapshotGenerator::SetHiddenReference(HeapObject* parent_obj, } -void HeapSnapshotGenerator::SetPropertyReference(HeapObject* parent_obj, - HeapEntry* parent_entry, - String* reference_name, - Object* child_obj) { +void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj, + HeapEntry* parent_entry, + String* reference_name, + Object* child_obj) { HeapEntry* child_entry = GetEntry(child_obj); if (child_entry != NULL) { HeapGraphEdge::Type type = reference_name->length() > 0 ? @@ -2174,7 +2086,7 @@ void HeapSnapshotGenerator::SetPropertyReference(HeapObject* parent_obj, } -void HeapSnapshotGenerator::SetPropertyShortcutReference( +void V8HeapExplorer::SetPropertyShortcutReference( HeapObject* parent_obj, HeapEntry* parent_entry, String* reference_name, @@ -2191,52 +2103,221 @@ void HeapSnapshotGenerator::SetPropertyShortcutReference( } -void HeapSnapshotGenerator::SetRootGcRootsReference() { - filler_->SetRootGcRootsReference(); +void V8HeapExplorer::SetRootGcRootsReference() { + filler_->SetIndexedAutoIndexReference( + HeapGraphEdge::kElement, + kInternalRootObject, snapshot_->root(), + kGcRootsObject, snapshot_->gc_roots()); } -void HeapSnapshotGenerator::SetRootShortcutReference(Object* child_obj) { +void V8HeapExplorer::SetRootShortcutReference(Object* child_obj) { HeapEntry* child_entry = GetEntry(child_obj); ASSERT(child_entry != NULL); - filler_->SetRootShortcutReference(child_obj, child_entry); + filler_->SetNamedAutoIndexReference( + HeapGraphEdge::kShortcut, + kInternalRootObject, snapshot_->root(), + child_obj, child_entry); } -void HeapSnapshotGenerator::SetGcRootsReference(Object* child_obj) { +void V8HeapExplorer::SetGcRootsReference(Object* child_obj) { HeapEntry* child_entry = GetEntry(child_obj); if (child_entry != NULL) { - filler_->SetStrongRootReference(child_obj, child_entry); + filler_->SetIndexedAutoIndexReference( + HeapGraphEdge::kElement, + kGcRootsObject, snapshot_->gc_roots(), + child_obj, child_entry); } } +HeapSnapshotGenerator::HeapSnapshotGenerator(HeapSnapshot* snapshot, + v8::ActivityControl* control) + : snapshot_(snapshot), + control_(control), + v8_heap_explorer_(snapshot_, this) { +} + + +class SnapshotCounter : public SnapshotFillerInterface { + public: + SnapshotCounter(HeapEntriesAllocator* allocator, HeapEntriesMap* entries) + : allocator_(allocator), entries_(entries) { } + HeapEntry* AddEntry(HeapThing ptr) { + entries_->Pair(ptr, allocator_, HeapEntriesMap::kHeapEntryPlaceholder); + return HeapEntriesMap::kHeapEntryPlaceholder; + } + HeapEntry* FindOrAddEntry(HeapThing ptr) { + HeapEntry* entry = entries_->Map(ptr); + return entry != NULL ? entry : AddEntry(ptr); + } + void SetIndexedReference(HeapGraphEdge::Type, + HeapThing parent_ptr, + HeapEntry*, + int, + HeapThing child_ptr, + HeapEntry*) { + entries_->CountReference(parent_ptr, child_ptr); + } + void SetIndexedAutoIndexReference(HeapGraphEdge::Type, + HeapThing parent_ptr, + HeapEntry*, + HeapThing child_ptr, + HeapEntry*) { + entries_->CountReference(parent_ptr, child_ptr); + } + void SetNamedReference(HeapGraphEdge::Type, + HeapThing parent_ptr, + HeapEntry*, + const char*, + HeapThing child_ptr, + HeapEntry*) { + entries_->CountReference(parent_ptr, child_ptr); + } + void SetNamedAutoIndexReference(HeapGraphEdge::Type, + HeapThing parent_ptr, + HeapEntry*, + HeapThing child_ptr, + HeapEntry*) { + entries_->CountReference(parent_ptr, child_ptr); + } + private: + HeapEntriesAllocator* allocator_; + HeapEntriesMap* entries_; +}; + + +class SnapshotFiller : public SnapshotFillerInterface { + public: + explicit SnapshotFiller(HeapSnapshot* snapshot, HeapEntriesMap* entries) + : snapshot_(snapshot), + collection_(snapshot->collection()), + entries_(entries) { } + HeapEntry* AddEntry(HeapThing ptr) { + UNREACHABLE(); + return NULL; + } + HeapEntry* FindOrAddEntry(HeapThing ptr) { + HeapEntry* entry = entries_->Map(ptr); + return entry != NULL ? entry : AddEntry(ptr); + } + void SetIndexedReference(HeapGraphEdge::Type type, + HeapThing parent_ptr, + HeapEntry* parent_entry, + int index, + HeapThing child_ptr, + HeapEntry* child_entry) { + int child_index, retainer_index; + entries_->CountReference( + parent_ptr, child_ptr, &child_index, &retainer_index); + parent_entry->SetIndexedReference( + type, child_index, index, child_entry, retainer_index); + } + void SetIndexedAutoIndexReference(HeapGraphEdge::Type type, + HeapThing parent_ptr, + HeapEntry* parent_entry, + HeapThing child_ptr, + HeapEntry* child_entry) { + int child_index, retainer_index; + entries_->CountReference( + parent_ptr, child_ptr, &child_index, &retainer_index); + parent_entry->SetIndexedReference( + type, child_index, child_index + 1, child_entry, retainer_index); + } + void SetNamedReference(HeapGraphEdge::Type type, + HeapThing parent_ptr, + HeapEntry* parent_entry, + const char* reference_name, + HeapThing child_ptr, + HeapEntry* child_entry) { + int child_index, retainer_index; + entries_->CountReference( + parent_ptr, child_ptr, &child_index, &retainer_index); + parent_entry->SetNamedReference( + type, child_index, reference_name, child_entry, retainer_index); + } + void SetNamedAutoIndexReference(HeapGraphEdge::Type type, + HeapThing parent_ptr, + HeapEntry* parent_entry, + HeapThing child_ptr, + HeapEntry* child_entry) { + int child_index, retainer_index; + entries_->CountReference( + parent_ptr, child_ptr, &child_index, &retainer_index); + parent_entry->SetNamedReference(type, + child_index, + collection_->GetName(child_index + 1), + child_entry, + retainer_index); + } + private: + HeapSnapshot* snapshot_; + HeapSnapshotsCollection* collection_; + HeapEntriesMap* entries_; +}; + + +bool HeapSnapshotGenerator::GenerateSnapshot() { + AssertNoAllocation no_alloc; + + SetProgressTotal(4); // 2 passes + dominators + sizes. + + // Pass 1. Iterate heap contents to count entries and references. + if (!CountEntriesAndReferences()) return false; + + // Allocate and fill entries in the snapshot, allocate references. + snapshot_->AllocateEntries(entries_.entries_count(), + entries_.total_children_count(), + entries_.total_retainers_count()); + entries_.AllocateEntries(); + + // Pass 2. Fill references. + if (!FillReferences()) return false; + + if (!SetEntriesDominators()) return false; + if (!ApproximateRetainedSizes()) return false; + + progress_counter_ = progress_total_; + if (!ProgressReport(true)) return false; + return true; +} + + +void HeapSnapshotGenerator::ProgressStep() { + ++progress_counter_; +} + + +bool HeapSnapshotGenerator::ProgressReport(bool force) { + const int kProgressReportGranularity = 10000; + if (control_ != NULL + && (force || progress_counter_ % kProgressReportGranularity == 0)) { + return + control_->ReportProgressValue(progress_counter_, progress_total_) == + v8::ActivityControl::kContinue; + } + return true; +} + + void HeapSnapshotGenerator::SetProgressTotal(int iterations_count) { if (control_ == NULL) return; - - HeapIterator iterator(HeapIterator::kFilterUnreachable); - int objects_count = 0; - for (HeapObject* obj = iterator.next(); - obj != NULL; - obj = iterator.next(), ++objects_count) {} - progress_total_ = objects_count * iterations_count; + progress_total_ = v8_heap_explorer_.EstimateObjectsCount() * iterations_count; progress_counter_ = 0; } bool HeapSnapshotGenerator::CountEntriesAndReferences() { - SnapshotCounter counter(&entries_); - filler_ = &counter; - filler_->AddEntry(HeapSnapshot::kInternalRootObject); - filler_->AddEntry(HeapSnapshot::kGcRootsObject); - return IterateAndExtractReferences(); + SnapshotCounter counter(&v8_heap_explorer_, &entries_); + v8_heap_explorer_.AddRootEntries(&counter); + return v8_heap_explorer_.IterateAndExtractReferences(&counter); } bool HeapSnapshotGenerator::FillReferences() { SnapshotFiller filler(snapshot_, &entries_); - filler_ = &filler; - return IterateAndExtractReferences(); + return v8_heap_explorer_.IterateAndExtractReferences(&filler); } @@ -2322,7 +2403,7 @@ bool HeapSnapshotGenerator::BuildDominatorTree( int remaining = entries_length - changed; if (remaining < 0) remaining = 0; progress_counter_ = base_progress_counter + remaining; - if (!ReportProgress(true)) return false; + if (!ProgressReport(true)) return false; } return true; } @@ -2352,7 +2433,7 @@ bool HeapSnapshotGenerator::ApproximateRetainedSizes() { } for (int i = 0; i < snapshot_->entries()->length(); - ++i, IncProgressCounter()) { + ++i, ProgressStep()) { HeapEntry* entry = snapshot_->entries()->at(i); int entry_size = entry->self_size(); for (HeapEntry* dominator = entry->dominator(); @@ -2360,32 +2441,12 @@ bool HeapSnapshotGenerator::ApproximateRetainedSizes() { entry = dominator, dominator = entry->dominator()) { dominator->add_retained_size(entry_size); } - if (!ReportProgress()) return false; + if (!ProgressReport()) return false; } return true; } -bool HeapSnapshotGenerator::IterateAndExtractReferences() { - HeapIterator iterator(HeapIterator::kFilterUnreachable); - bool interrupted = false; - // Heap iteration with filtering must be finished in any case. - for (HeapObject* obj = iterator.next(); - obj != NULL; - obj = iterator.next(), IncProgressCounter()) { - if (!interrupted) { - ExtractReferences(obj); - if (!ReportProgress()) interrupted = true; - } - } - if (interrupted) return false; - SetRootGcRootsReference(); - RootsReferencesExtractor extractor(this); - Heap::IterateRoots(&extractor, VISIT_ALL); - return ReportProgress(); -} - - void HeapSnapshotsDiff::CreateRoots(int additions_count, int deletions_count) { raw_additions_root_ = NewArray(HeapEntry::EntriesSize(1, additions_count, 0)); diff --git a/deps/v8/src/profile-generator.h b/deps/v8/src/profile-generator.h index 748714dc4d..4762eb6342 100644 --- a/deps/v8/src/profile-generator.h +++ b/deps/v8/src/profile-generator.h @@ -681,14 +681,14 @@ class HeapSnapshot { void AllocateEntries( int entries_count, int children_count, int retainers_count); - HeapEntry* AddEntry( - HeapObject* object, int children_count, int retainers_count); HeapEntry* AddEntry(HeapEntry::Type type, const char* name, uint64_t id, int size, int children_count, int retainers_count); + HeapEntry* AddRootEntry(int children_count); + HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); void ClearPaint(); HeapSnapshotsDiff* CompareWith(HeapSnapshot* snapshot); HeapEntry* GetEntryById(uint64_t id); @@ -701,15 +701,7 @@ class HeapSnapshot { void Print(int max_depth); void PrintEntriesSize(); - static HeapObject* const kInternalRootObject; - static HeapObject* const kGcRootsObject; - private: - HeapEntry* AddEntry(HeapObject* object, - HeapEntry::Type type, - const char* name, - int children_count, - int retainers_count); HeapEntry* GetNextEntryToInit(); HeapSnapshotsCollection* collection_; @@ -873,6 +865,20 @@ class HeapSnapshotsCollection { }; +// A typedef for referencing anything that can be snapshotted living +// in any kind of heap memory. +typedef void* HeapThing; + + +// An interface that creates HeapEntries by HeapThings. +class HeapEntriesAllocator { + public: + virtual ~HeapEntriesAllocator() { } + virtual HeapEntry* AllocateEntry( + HeapThing ptr, int children_count, int retainers_count) = 0; +}; + + // The HeapEntriesMap instance is used to track a mapping between // real heap objects and their representations in heap snapshots. class HeapEntriesMap { @@ -880,13 +886,12 @@ class HeapEntriesMap { HeapEntriesMap(); ~HeapEntriesMap(); - HeapEntry* Map(HeapObject* object); - void Pair(HeapObject* object, HeapEntry* entry); - void CountReference(HeapObject* from, HeapObject* to, + void AllocateEntries(); + HeapEntry* Map(HeapThing thing); + void Pair(HeapThing thing, HeapEntriesAllocator* allocator, HeapEntry* entry); + void CountReference(HeapThing from, HeapThing to, int* prev_children_count = NULL, int* prev_retainers_count = NULL); - template - void UpdateEntries(Visitor* visitor); int entries_count() { return entries_count_; } int total_children_count() { return total_children_count_; } @@ -896,18 +901,25 @@ class HeapEntriesMap { private: struct EntryInfo { - explicit EntryInfo(HeapEntry* entry) - : entry(entry), children_count(0), retainers_count(0) { } + EntryInfo(HeapEntry* entry, HeapEntriesAllocator* allocator) + : entry(entry), + allocator(allocator), + children_count(0), + retainers_count(0) { + } HeapEntry* entry; + HeapEntriesAllocator* allocator; int children_count; int retainers_count; }; - static uint32_t Hash(HeapObject* object) { + static uint32_t Hash(HeapThing thing) { return ComputeIntegerHash( - static_cast(reinterpret_cast(object))); + static_cast(reinterpret_cast(thing))); + } + static bool HeapThingsMatch(HeapThing key1, HeapThing key2) { + return key1 == key2; } - static bool HeapObjectsMatch(void* key1, void* key2) { return key1 == key2; } HashMap entries_; int entries_count_; @@ -934,52 +946,70 @@ class HeapObjectsSet { }; -class HeapSnapshotGenerator { +// An interface used to populate a snapshot with nodes and edges. +class SnapshotFillerInterface { public: - class SnapshotFillerInterface { - public: - virtual ~SnapshotFillerInterface() { } - virtual HeapEntry* AddEntry(HeapObject* obj) = 0; - virtual void SetIndexedReference(HeapGraphEdge::Type type, - HeapObject* parent_obj, - HeapEntry* parent_entry, - int index, - Object* child_obj, - HeapEntry* child_entry) = 0; - virtual void SetNamedReference(HeapGraphEdge::Type type, - HeapObject* parent_obj, + virtual ~SnapshotFillerInterface() { } + virtual HeapEntry* AddEntry(HeapThing ptr) = 0; + virtual HeapEntry* FindOrAddEntry(HeapThing ptr) = 0; + virtual void SetIndexedReference(HeapGraphEdge::Type type, + HeapThing parent_ptr, HeapEntry* parent_entry, - const char* reference_name, - Object* child_obj, + int index, + HeapThing child_ptr, HeapEntry* child_entry) = 0; - virtual void SetRootGcRootsReference() = 0; - virtual void SetRootShortcutReference(Object* child_obj, + virtual void SetIndexedAutoIndexReference(HeapGraphEdge::Type type, + HeapThing parent_ptr, + HeapEntry* parent_entry, + HeapThing child_ptr, + HeapEntry* child_entry) = 0; + virtual void SetNamedReference(HeapGraphEdge::Type type, + HeapThing parent_ptr, + HeapEntry* parent_entry, + const char* reference_name, + HeapThing child_ptr, + HeapEntry* child_entry) = 0; + virtual void SetNamedAutoIndexReference(HeapGraphEdge::Type type, + HeapThing parent_ptr, + HeapEntry* parent_entry, + HeapThing child_ptr, HeapEntry* child_entry) = 0; - virtual void SetStrongRootReference(Object* child_obj, - HeapEntry* child_entry) = 0; - }; +}; - HeapSnapshotGenerator(HeapSnapshot* snapshot, - v8::ActivityControl* control); - bool GenerateSnapshot(); + +class SnapshottingProgressReportingInterface { + public: + virtual ~SnapshottingProgressReportingInterface() { } + virtual void ProgressStep() = 0; + virtual bool ProgressReport(bool force) = 0; +}; + + +// An implementation of V8 heap graph extractor. +class V8HeapExplorer : public HeapEntriesAllocator { + public: + V8HeapExplorer(HeapSnapshot* snapshot, + SnapshottingProgressReportingInterface* progress); + ~V8HeapExplorer(); + virtual HeapEntry* AllocateEntry( + HeapThing ptr, int children_count, int retainers_count); + void AddRootEntries(SnapshotFillerInterface* filler); + int EstimateObjectsCount(); + bool IterateAndExtractReferences(SnapshotFillerInterface* filler); private: - bool ApproximateRetainedSizes(); - bool BuildDominatorTree(const Vector& entries, - Vector* dominators); - bool CountEntriesAndReferences(); - HeapEntry* GetEntry(Object* obj); - void IncProgressCounter() { ++progress_counter_; } + HeapEntry* AddEntry( + HeapObject* object, int children_count, int retainers_count); + HeapEntry* AddEntry(HeapObject* object, + HeapEntry::Type type, + const char* name, + int children_count, + int retainers_count); void ExtractReferences(HeapObject* obj); void ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry); void ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entry); void ExtractElementReferences(JSObject* js_obj, HeapEntry* entry); void ExtractInternalReferences(JSObject* js_obj, HeapEntry* entry); - bool FillReferences(); - void FillReversePostorderIndexes(Vector* entries); - bool IterateAndExtractReferences(); - inline bool ReportProgress(bool force = false); - bool SetEntriesDominators(); void SetClosureReference(HeapObject* parent_obj, HeapEntry* parent, String* reference_name, @@ -1011,24 +1041,54 @@ class HeapSnapshotGenerator { void SetRootShortcutReference(Object* child); void SetRootGcRootsReference(); void SetGcRootsReference(Object* child); - void SetProgressTotal(int iterations_count); + + HeapEntry* GetEntry(Object* obj); HeapSnapshot* snapshot_; - v8::ActivityControl* control_; HeapSnapshotsCollection* collection_; - // Mapping from HeapObject* pointers to HeapEntry* pointers. - HeapEntriesMap entries_; - SnapshotFillerInterface* filler_; + SnapshottingProgressReportingInterface* progress_; // Used during references extraction to mark heap objects that // are references via non-hidden properties. HeapObjectsSet known_references_; - // Used during snapshot generation. - int progress_counter_; - int progress_total_; + SnapshotFillerInterface* filler_; + + static HeapObject* const kInternalRootObject; + static HeapObject* const kGcRootsObject; friend class IndexedReferencesExtractor; friend class RootsReferencesExtractor; + DISALLOW_COPY_AND_ASSIGN(V8HeapExplorer); +}; + + +class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { + public: + HeapSnapshotGenerator(HeapSnapshot* snapshot, + v8::ActivityControl* control); + bool GenerateSnapshot(); + + private: + bool ApproximateRetainedSizes(); + bool BuildDominatorTree(const Vector& entries, + Vector* dominators); + bool CountEntriesAndReferences(); + bool FillReferences(); + void FillReversePostorderIndexes(Vector* entries); + void ProgressStep(); + bool ProgressReport(bool force = false); + bool SetEntriesDominators(); + void SetProgressTotal(int iterations_count); + + HeapSnapshot* snapshot_; + v8::ActivityControl* control_; + V8HeapExplorer v8_heap_explorer_; + // Mapping from HeapThing pointers to HeapEntry* pointers. + HeapEntriesMap entries_; + // Used during snapshot generation. + int progress_counter_; + int progress_total_; + DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator); }; diff --git a/deps/v8/src/runtime-profiler.cc b/deps/v8/src/runtime-profiler.cc index 3406cdc250..df6471e9d5 100644 --- a/deps/v8/src/runtime-profiler.cc +++ b/deps/v8/src/runtime-profiler.cc @@ -35,6 +35,7 @@ #include "deoptimizer.h" #include "execution.h" #include "global-handles.h" +#include "mark-compact.h" #include "scopeinfo.h" #include "top.h" @@ -100,11 +101,6 @@ static int sampler_ticks_until_threshold_adjustment = // The ratio of ticks spent in JS code in percent. static Atomic32 js_ratio; -// The JSFunctions in the sampler window are not GC safe. Old-space -// pointers are not cleared during mark-sweep collection and therefore -// the window might contain stale pointers. The window is updated on -// scavenges and (parts of it) cleared on mark-sweep and -// mark-sweep-compact. static Object* sampler_window[kSamplerWindowSize] = { NULL, }; static int sampler_window_position = 0; static int sampler_window_weight[kSamplerWindowSize] = { 0, }; @@ -134,7 +130,6 @@ void PendingListNode::WeakCallback(v8::Persistent, void* data) { static bool IsOptimizable(JSFunction* function) { - if (Heap::InNewSpace(function)) return false; Code* code = function->code(); return code->kind() == Code::FUNCTION && code->optimizable(); } @@ -208,16 +203,6 @@ static void ClearSampleBuffer() { } -static void ClearSampleBufferNewSpaceEntries() { - for (int i = 0; i < kSamplerWindowSize; i++) { - if (Heap::InNewSpace(sampler_window[i])) { - sampler_window[i] = NULL; - sampler_window_weight[i] = 0; - } - } -} - - static int LookupSample(JSFunction* function) { int weight = 0; for (int i = 0; i < kSamplerWindowSize; i++) { @@ -372,24 +357,6 @@ void RuntimeProfiler::NotifyTick() { } -void RuntimeProfiler::MarkCompactPrologue(bool is_compacting) { - if (is_compacting) { - // Clear all samples before mark-sweep-compact because every - // function might move. - ClearSampleBuffer(); - } else { - // Clear only new space entries on mark-sweep since none of the - // old-space functions will move. - ClearSampleBufferNewSpaceEntries(); - } -} - - -bool IsEqual(void* first, void* second) { - return first == second; -} - - void RuntimeProfiler::Setup() { ClearSampleBuffer(); // If the ticker hasn't already started, make sure to do so to get @@ -411,13 +378,41 @@ void RuntimeProfiler::TearDown() { } -Object** RuntimeProfiler::SamplerWindowAddress() { - return sampler_window; +int RuntimeProfiler::SamplerWindowSize() { + return kSamplerWindowSize; } -int RuntimeProfiler::SamplerWindowSize() { - return kSamplerWindowSize; +// Update the pointers in the sampler window after a GC. +void RuntimeProfiler::UpdateSamplesAfterScavenge() { + for (int i = 0; i < kSamplerWindowSize; i++) { + Object* function = sampler_window[i]; + if (function != NULL && Heap::InNewSpace(function)) { + MapWord map_word = HeapObject::cast(function)->map_word(); + if (map_word.IsForwardingAddress()) { + sampler_window[i] = map_word.ToForwardingAddress(); + } else { + sampler_window[i] = NULL; + } + } + } +} + + +void RuntimeProfiler::RemoveDeadSamples() { + for (int i = 0; i < kSamplerWindowSize; i++) { + Object* function = sampler_window[i]; + if (function != NULL && !HeapObject::cast(function)->IsMarked()) { + sampler_window[i] = NULL; + } + } +} + + +void RuntimeProfiler::UpdateSamplesAfterCompact(ObjectVisitor* visitor) { + for (int i = 0; i < kSamplerWindowSize; i++) { + visitor->VisitPointer(&sampler_window[i]); + } } diff --git a/deps/v8/src/runtime-profiler.h b/deps/v8/src/runtime-profiler.h index e041c059b6..02defc9b2c 100644 --- a/deps/v8/src/runtime-profiler.h +++ b/deps/v8/src/runtime-profiler.h @@ -47,9 +47,10 @@ class RuntimeProfiler : public AllStatic { static void Reset(); static void TearDown(); - static void MarkCompactPrologue(bool is_compacting); - static Object** SamplerWindowAddress(); static int SamplerWindowSize(); + static void UpdateSamplesAfterScavenge(); + static void RemoveDeadSamples(); + static void UpdateSamplesAfterCompact(ObjectVisitor* visitor); }; diff --git a/deps/v8/src/runtime.cc b/deps/v8/src/runtime.cc index 5a443efc3d..0c15f60f30 100644 --- a/deps/v8/src/runtime.cc +++ b/deps/v8/src/runtime.cc @@ -40,8 +40,10 @@ #include "debug.h" #include "deoptimizer.h" #include "execution.h" +#include "global-handles.h" #include "jsregexp.h" #include "liveedit.h" +#include "liveobjectlist-inl.h" #include "parser.h" #include "platform.h" #include "runtime.h" @@ -160,7 +162,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(JSObject* boilerplate) { if (!maybe_result->ToObject(&result)) return maybe_result; } { MaybeObject* maybe_result = - copy->SetProperty(key_string, result, NONE); + // Creating object copy for literals. No strict mode needed. + copy->SetProperty(key_string, result, NONE, kNonStrictMode); if (!maybe_result->ToObject(&result)) return maybe_result; } } @@ -546,7 +549,9 @@ static MaybeObject* Runtime_CreateCatchExtensionObject(Arguments args) { // Assign the exception value to the catch variable and make sure // that the catch variable is DontDelete. { MaybeObject* maybe_value = - JSObject::cast(object)->SetProperty(key, value, DONT_DELETE); + // Passing non-strict per ECMA-262 5th Ed. 12.14. Catch, bullet #4. + JSObject::cast(object)->SetProperty( + key, value, DONT_DELETE, kNonStrictMode); if (!maybe_value->ToObject(&value)) return maybe_value; } return object; @@ -783,7 +788,8 @@ static MaybeObject* Runtime_GetOwnProperty(Arguments args) { case JSObject::INTERCEPTED_ELEMENT: case JSObject::FAST_ELEMENT: { elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); - elms->set(VALUE_INDEX, *GetElement(obj, index)); + Handle value = GetElement(obj, index); + elms->set(VALUE_INDEX, *value); elms->set(WRITABLE_INDEX, Heap::true_value()); elms->set(ENUMERABLE_INDEX, Heap::true_value()); elms->set(CONFIGURABLE_INDEX, Heap::true_value()); @@ -816,12 +822,14 @@ static MaybeObject* Runtime_GetOwnProperty(Arguments args) { } break; } - case NORMAL: + case NORMAL: { // This is a data property. elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); - elms->set(VALUE_INDEX, *GetElement(obj, index)); + Handle value = GetElement(obj, index); + elms->set(VALUE_INDEX, *value); elms->set(WRITABLE_INDEX, Heap::ToBoolean(!details.IsReadOnly())); break; + } default: UNREACHABLE(); break; @@ -994,12 +1002,16 @@ static Failure* ThrowRedeclarationError(const char* type, Handle name) { static MaybeObject* Runtime_DeclareGlobals(Arguments args) { + ASSERT(args.length() == 4); HandleScope scope; Handle global = Handle(Top::context()->global()); Handle context = args.at(0); CONVERT_ARG_CHECKED(FixedArray, pairs, 1); bool is_eval = Smi::cast(args[2])->value() == 1; + StrictModeFlag strict_mode = + static_cast(Smi::cast(args[3])->value()); + ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode); // Compute the property attributes. According to ECMA-262, section // 13, page 71, the property must be read-only and @@ -1104,12 +1116,21 @@ static MaybeObject* Runtime_DeclareGlobals(Arguments args) { // onload setter in those case and Safari does not. We follow // Safari for compatibility. if (value->IsJSFunction()) { + // Do not change DONT_DELETE to false from true. + if (lookup.IsProperty() && (lookup.type() != INTERCEPTOR)) { + attributes = static_cast( + attributes | (lookup.GetAttributes() & DONT_DELETE)); + } RETURN_IF_EMPTY_HANDLE(SetLocalPropertyIgnoreAttributes(global, name, value, attributes)); } else { - RETURN_IF_EMPTY_HANDLE(SetProperty(global, name, value, attributes)); + RETURN_IF_EMPTY_HANDLE(SetProperty(global, + name, + value, + attributes, + strict_mode)); } } @@ -1170,7 +1191,8 @@ static MaybeObject* Runtime_DeclareContextSlot(Arguments args) { // Slow case: The property is not in the FixedArray part of the context. Handle context_ext = Handle::cast(holder); RETURN_IF_EMPTY_HANDLE( - SetProperty(context_ext, name, initial_value, mode)); + SetProperty(context_ext, name, initial_value, + mode, kNonStrictMode)); } } @@ -1211,7 +1233,8 @@ static MaybeObject* Runtime_DeclareContextSlot(Arguments args) { return ThrowRedeclarationError("const", name); } } - RETURN_IF_EMPTY_HANDLE(SetProperty(context_ext, name, value, mode)); + RETURN_IF_EMPTY_HANDLE(SetProperty(context_ext, name, value, mode, + kNonStrictMode)); } return Heap::undefined_value(); @@ -1220,14 +1243,21 @@ static MaybeObject* Runtime_DeclareContextSlot(Arguments args) { static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) { NoHandleAllocation nha; + // args[0] == name + // args[1] == strict_mode + // args[2] == value (optional) // Determine if we need to assign to the variable if it already // exists (based on the number of arguments). - RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); - bool assign = args.length() == 2; + RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); + bool assign = args.length() == 3; CONVERT_ARG_CHECKED(String, name, 0); GlobalObject* global = Top::context()->global(); + RUNTIME_ASSERT(args[1]->IsSmi()); + StrictModeFlag strict_mode = + static_cast(Smi::cast(args[1])->value()); + ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode); // According to ECMA-262, section 12.2, page 62, the property must // not be deletable. @@ -1283,8 +1313,9 @@ static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) { } // Assign the value (or undefined) to the property. - Object* value = (assign) ? args[1] : Heap::undefined_value(); - return real_holder->SetProperty(&lookup, *name, value, attributes); + Object* value = (assign) ? args[2] : Heap::undefined_value(); + return real_holder->SetProperty( + &lookup, *name, value, attributes, strict_mode); } Object* proto = real_holder->GetPrototype(); @@ -1298,7 +1329,9 @@ static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) { } global = Top::context()->global(); - if (assign) return global->SetProperty(*name, args[1], attributes); + if (assign) { + return global->SetProperty(*name, args[2], attributes, strict_mode); + } return Heap::undefined_value(); } @@ -1357,13 +1390,19 @@ static MaybeObject* Runtime_InitializeConstGlobal(Arguments args) { // BUG 1213575: Handle the case where we have to set a read-only // property through an interceptor and only do it if it's // uninitialized, e.g. the hole. Nirk... - RETURN_IF_EMPTY_HANDLE(SetProperty(global, name, value, attributes)); + // Passing non-strict mode because the property is writable. + RETURN_IF_EMPTY_HANDLE(SetProperty(global, + name, + value, + attributes, + kNonStrictMode)); return *value; } // Set the value, but only we're assigning the initial value to a // constant. For now, we determine this by checking if the // current value is the hole. + // Strict mode handling not needed (const disallowed in strict mode). PropertyType type = lookup.type(); if (type == FIELD) { FixedArray* properties = global->properties(); @@ -1439,7 +1478,9 @@ static MaybeObject* Runtime_InitializeConstContextSlot(Arguments args) { // context. if (attributes == ABSENT) { Handle global = Handle(Top::context()->global()); - RETURN_IF_EMPTY_HANDLE(SetProperty(global, name, value, NONE)); + // Strict mode not needed (const disallowed in strict mode). + RETURN_IF_EMPTY_HANDLE( + SetProperty(global, name, value, NONE, kNonStrictMode)); return *value; } @@ -1476,8 +1517,9 @@ static MaybeObject* Runtime_InitializeConstContextSlot(Arguments args) { // The property was found in a different context extension object. // Set it if it is not a read-only property. if ((attributes & READ_ONLY) == 0) { + // Strict mode not needed (const disallowed in strict mode). RETURN_IF_EMPTY_HANDLE( - SetProperty(context_ext, name, value, attributes)); + SetProperty(context_ext, name, value, attributes, kNonStrictMode)); } } @@ -1643,7 +1685,7 @@ static Handle InstallBuiltin(Handle holder, code, false); optimized->shared()->DontAdaptArguments(); - SetProperty(holder, key, optimized, NONE); + SetProperty(holder, key, optimized, NONE, kStrictMode); return optimized; } @@ -3739,7 +3781,8 @@ static MaybeObject* Runtime_DefineOrRedefineDataProperty(Arguments args) { MaybeObject* Runtime::SetObjectProperty(Handle object, Handle key, Handle value, - PropertyAttributes attr) { + PropertyAttributes attr, + StrictModeFlag strict) { HandleScope scope; if (object->IsUndefined() || object->IsNull()) { @@ -3769,6 +3812,7 @@ MaybeObject* Runtime::SetObjectProperty(Handle object, return *value; } + // TODO(1220): Implement SetElement strict mode. Handle result = SetElement(js_object, index, value); if (result.is_null()) return Failure::Exception(); return *value; @@ -3781,7 +3825,7 @@ MaybeObject* Runtime::SetObjectProperty(Handle object, } else { Handle key_string = Handle::cast(key); key_string->TryFlatten(); - result = SetProperty(js_object, key_string, value, attr); + result = SetProperty(js_object, key_string, value, attr, strict); } if (result.is_null()) return Failure::Exception(); return *value; @@ -3794,9 +3838,10 @@ MaybeObject* Runtime::SetObjectProperty(Handle object, Handle name = Handle::cast(converted); if (name->AsArrayIndex(&index)) { + // TODO(1220): Implement SetElement strict mode. return js_object->SetElement(index, *value); } else { - return js_object->SetProperty(*name, *value, attr); + return js_object->SetProperty(*name, *value, attr, strict); } } @@ -3888,23 +3933,27 @@ MaybeObject* Runtime::ForceDeleteObjectProperty(Handle js_object, static MaybeObject* Runtime_SetProperty(Arguments args) { NoHandleAllocation ha; - RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); + RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); Handle object = args.at(0); Handle key = args.at(1); Handle value = args.at(2); - + CONVERT_SMI_CHECKED(unchecked_attributes, args[3]); + RUNTIME_ASSERT( + (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); // Compute attributes. - PropertyAttributes attributes = NONE; - if (args.length() == 4) { - CONVERT_CHECKED(Smi, value_obj, args[3]); - int unchecked_value = value_obj->value(); - // Only attribute bits should be set. - RUNTIME_ASSERT( - (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); - attributes = static_cast(unchecked_value); + PropertyAttributes attributes = + static_cast(unchecked_attributes); + + StrictModeFlag strict = kNonStrictMode; + if (args.length() == 5) { + CONVERT_SMI_CHECKED(strict_unchecked, args[4]); + RUNTIME_ASSERT(strict_unchecked == kStrictMode || + strict_unchecked == kNonStrictMode); + strict = static_cast(strict_unchecked); } - return Runtime::SetObjectProperty(object, key, value, attributes); + + return Runtime::SetObjectProperty(object, key, value, attributes, strict); } @@ -3938,7 +3987,7 @@ static MaybeObject* Runtime_DeleteProperty(Arguments args) { CONVERT_CHECKED(JSObject, object, args[0]); CONVERT_CHECKED(String, key, args[1]); CONVERT_SMI_CHECKED(strict, args[2]); - return object->DeleteProperty(key, strict == kStrictMode + return object->DeleteProperty(key, (strict == kStrictMode) ? JSObject::STRICT_DELETION : JSObject::NORMAL_DELETION); } @@ -7020,7 +7069,7 @@ static MaybeObject* Runtime_LazyRecompile(Arguments args) { function->ReplaceCode(function->shared()->code()); return function->code(); } - if (CompileOptimized(function, AstNode::kNoNumber)) { + if (CompileOptimized(function, AstNode::kNoNumber, CLEAR_EXCEPTION)) { return function->code(); } if (FLAG_trace_opt) { @@ -7029,7 +7078,7 @@ static MaybeObject* Runtime_LazyRecompile(Arguments args) { PrintF(": optimized compilation failed]\n"); } function->ReplaceCode(function->shared()->code()); - return Failure::Exception(); + return function->code(); } @@ -7189,7 +7238,8 @@ static MaybeObject* Runtime_CompileForOnStackReplacement(Arguments args) { // Try to compile the optimized code. A true return value from // CompileOptimized means that compilation succeeded, not necessarily // that optimization succeeded. - if (CompileOptimized(function, ast_id) && function->IsOptimized()) { + if (CompileOptimized(function, ast_id, CLEAR_EXCEPTION) && + function->IsOptimized()) { DeoptimizationInputData* data = DeoptimizationInputData::cast( function->code()->deoptimization_data()); if (data->OsrPcOffset()->value() >= 0) { @@ -7232,6 +7282,9 @@ static MaybeObject* Runtime_CompileForOnStackReplacement(Arguments args) { ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION); return Smi::FromInt(ast_id); } else { + if (function->IsMarkedForLazyRecompilation()) { + function->ReplaceCode(function->shared()->code()); + } return Smi::FromInt(-1); } } @@ -7482,11 +7535,16 @@ static ObjectPair Runtime_LoadContextSlotNoReferenceError(Arguments args) { static MaybeObject* Runtime_StoreContextSlot(Arguments args) { HandleScope scope; - ASSERT(args.length() == 3); + ASSERT(args.length() == 4); Handle value(args[0]); CONVERT_ARG_CHECKED(Context, context, 1); CONVERT_ARG_CHECKED(String, name, 2); + CONVERT_SMI_CHECKED(strict_unchecked, args[3]); + RUNTIME_ASSERT(strict_unchecked == kStrictMode || + strict_unchecked == kNonStrictMode); + StrictModeFlag strict = static_cast(strict_unchecked); + int index; PropertyAttributes attributes; @@ -7530,7 +7588,12 @@ static MaybeObject* Runtime_StoreContextSlot(Arguments args) { // extension object itself. if ((attributes & READ_ONLY) == 0 || (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) { - RETURN_IF_EMPTY_HANDLE(SetProperty(context_ext, name, value, NONE)); + RETURN_IF_EMPTY_HANDLE(SetProperty(context_ext, name, value, NONE, strict)); + } else if (strict == kStrictMode && (attributes & READ_ONLY) != 0) { + // Setting read only property in strict mode. + Handle error = + Factory::NewTypeError("strict_cannot_assign", HandleVector(&name, 1)); + return Top::Throw(*error); } return *value; } @@ -7859,12 +7922,9 @@ static ObjectPair CompileGlobalEval(Handle source, static ObjectPair Runtime_ResolvePossiblyDirectEval(Arguments args) { ASSERT(args.length() == 4); - if (!args[0]->IsJSFunction()) { - return MakePair(Top::ThrowIllegalOperation(), NULL); - } HandleScope scope; - Handle callee = args.at(0); + Handle callee = args.at(0); Handle receiver; // Will be overwritten. // Compute the calling context. @@ -7932,12 +7992,9 @@ static ObjectPair Runtime_ResolvePossiblyDirectEval(Arguments args) { static ObjectPair Runtime_ResolvePossiblyDirectEvalNoLookup(Arguments args) { ASSERT(args.length() == 4); - if (!args[0]->IsJSFunction()) { - return MakePair(Top::ThrowIllegalOperation(), NULL); - } HandleScope scope; - Handle callee = args.at(0); + Handle callee = args.at(0); // 'eval' is bound in the global context, but it may have been overwritten. // Compare it to the builtin 'GlobalEval' function to make sure. @@ -8028,377 +8085,467 @@ static MaybeObject* Runtime_PushIfAbsent(Arguments args) { class ArrayConcatVisitor { public: ArrayConcatVisitor(Handle storage, - uint32_t index_limit, bool fast_elements) : - storage_(storage), index_limit_(index_limit), - index_offset_(0), fast_elements_(fast_elements) { } + storage_(Handle::cast(GlobalHandles::Create(*storage))), + index_offset_(0u), + fast_elements_(fast_elements) { } + + ~ArrayConcatVisitor() { + clear_storage(); + } void visit(uint32_t i, Handle elm) { - if (i >= index_limit_ - index_offset_) return; + if (i >= JSObject::kMaxElementCount - index_offset_) return; uint32_t index = index_offset_ + i; if (fast_elements_) { - ASSERT(index < static_cast(storage_->length())); - storage_->set(index, *elm); - - } else { - Handle dict = Handle::cast(storage_); - Handle result = - Factory::DictionaryAtNumberPut(dict, index, elm); - if (!result.is_identical_to(dict)) - storage_ = result; + if (index < static_cast(storage_->length())) { + storage_->set(index, *elm); + return; + } + // Our initial estimate of length was foiled, possibly by + // getters on the arrays increasing the length of later arrays + // during iteration. + // This shouldn't happen in anything but pathological cases. + SetDictionaryMode(index); + // Fall-through to dictionary mode. } - } + ASSERT(!fast_elements_); + Handle dict(NumberDictionary::cast(*storage_)); + Handle result = + Factory::DictionaryAtNumberPut(dict, index, elm); + if (!result.is_identical_to(dict)) { + // Dictionary needed to grow. + clear_storage(); + set_storage(*result); + } +} void increase_index_offset(uint32_t delta) { - if (index_limit_ - index_offset_ < delta) { - index_offset_ = index_limit_; + if (JSObject::kMaxElementCount - index_offset_ < delta) { + index_offset_ = JSObject::kMaxElementCount; } else { index_offset_ += delta; } } - Handle storage() { return storage_; } + Handle ToArray() { + Handle array = Factory::NewJSArray(0); + Handle length = + Factory::NewNumber(static_cast(index_offset_)); + Handle map; + if (fast_elements_) { + map = Factory::GetFastElementsMap(Handle(array->map())); + } else { + map = Factory::GetSlowElementsMap(Handle(array->map())); + } + array->set_map(*map); + array->set_length(*length); + array->set_elements(*storage_); + return array; + } private: - Handle storage_; - // Limit on the accepted indices. Elements with indices larger than the - // limit are ignored by the visitor. - uint32_t index_limit_; - // Index after last seen index. Always less than or equal to index_limit_. + // Convert storage to dictionary mode. + void SetDictionaryMode(uint32_t index) { + ASSERT(fast_elements_); + Handle current_storage(*storage_); + Handle slow_storage( + Factory::NewNumberDictionary(current_storage->length())); + uint32_t current_length = static_cast(current_storage->length()); + for (uint32_t i = 0; i < current_length; i++) { + HandleScope loop_scope; + Handle element(current_storage->get(i)); + if (!element->IsTheHole()) { + Handle new_storage = + Factory::DictionaryAtNumberPut(slow_storage, i, element); + if (!new_storage.is_identical_to(slow_storage)) { + slow_storage = loop_scope.CloseAndEscape(new_storage); + } + } + } + clear_storage(); + set_storage(*slow_storage); + fast_elements_ = false; + } + + inline void clear_storage() { + GlobalHandles::Destroy(Handle::cast(storage_).location()); + } + + inline void set_storage(FixedArray* storage) { + storage_ = Handle::cast(GlobalHandles::Create(storage)); + } + + Handle storage_; // Always a global handle. + // Index after last seen index. Always less than or equal to + // JSObject::kMaxElementCount. uint32_t index_offset_; - const bool fast_elements_; + bool fast_elements_; }; +static uint32_t EstimateElementCount(Handle array) { + uint32_t length = static_cast(array->length()->Number()); + int element_count = 0; + switch (array->GetElementsKind()) { + case JSObject::FAST_ELEMENTS: { + // Fast elements can't have lengths that are not representable by + // a 32-bit signed integer. + ASSERT(static_cast(FixedArray::kMaxLength) >= 0); + int fast_length = static_cast(length); + Handle elements(FixedArray::cast(array->elements())); + for (int i = 0; i < fast_length; i++) { + if (!elements->get(i)->IsTheHole()) element_count++; + } + break; + } + case JSObject::DICTIONARY_ELEMENTS: { + Handle dictionary( + NumberDictionary::cast(array->elements())); + int capacity = dictionary->Capacity(); + for (int i = 0; i < capacity; i++) { + Handle key(dictionary->KeyAt(i)); + if (dictionary->IsKey(*key)) { + element_count++; + } + } + break; + } + default: + // External arrays are always dense. + return length; + } + // As an estimate, we assume that the prototype doesn't contain any + // inherited elements. + return element_count; +} + + + template -static uint32_t IterateExternalArrayElements(Handle receiver, - bool elements_are_ints, - bool elements_are_guaranteed_smis, - uint32_t range, - ArrayConcatVisitor* visitor) { +static void IterateExternalArrayElements(Handle receiver, + bool elements_are_ints, + bool elements_are_guaranteed_smis, + ArrayConcatVisitor* visitor) { Handle array( ExternalArrayClass::cast(receiver->elements())); - uint32_t len = Min(static_cast(array->length()), range); + uint32_t len = static_cast(array->length()); - if (visitor != NULL) { - if (elements_are_ints) { - if (elements_are_guaranteed_smis) { - for (uint32_t j = 0; j < len; j++) { - Handle e(Smi::FromInt(static_cast(array->get(j)))); + ASSERT(visitor != NULL); + if (elements_are_ints) { + if (elements_are_guaranteed_smis) { + for (uint32_t j = 0; j < len; j++) { + HandleScope loop_scope; + Handle e(Smi::FromInt(static_cast(array->get(j)))); + visitor->visit(j, e); + } + } else { + for (uint32_t j = 0; j < len; j++) { + HandleScope loop_scope; + int64_t val = static_cast(array->get(j)); + if (Smi::IsValid(static_cast(val))) { + Handle e(Smi::FromInt(static_cast(val))); + visitor->visit(j, e); + } else { + Handle e = + Factory::NewNumber(static_cast(val)); visitor->visit(j, e); } - } else { - for (uint32_t j = 0; j < len; j++) { - int64_t val = static_cast(array->get(j)); - if (Smi::IsValid(static_cast(val))) { - Handle e(Smi::FromInt(static_cast(val))); - visitor->visit(j, e); - } else { - Handle e = - Factory::NewNumber(static_cast(val)); - visitor->visit(j, e); + } + } + } else { + for (uint32_t j = 0; j < len; j++) { + HandleScope loop_scope; + Handle e = Factory::NewNumber(array->get(j)); + visitor->visit(j, e); + } + } +} + + +// Used for sorting indices in a List. +static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { + uint32_t a = *ap; + uint32_t b = *bp; + return (a == b) ? 0 : (a < b) ? -1 : 1; +} + + +static void CollectElementIndices(Handle object, + uint32_t range, + List* indices) { + JSObject::ElementsKind kind = object->GetElementsKind(); + switch (kind) { + case JSObject::FAST_ELEMENTS: { + Handle elements(FixedArray::cast(object->elements())); + uint32_t length = static_cast(elements->length()); + if (range < length) length = range; + for (uint32_t i = 0; i < length; i++) { + if (!elements->get(i)->IsTheHole()) { + indices->Add(i); + } + } + break; + } + case JSObject::DICTIONARY_ELEMENTS: { + Handle dict(NumberDictionary::cast(object->elements())); + uint32_t capacity = dict->Capacity(); + for (uint32_t j = 0; j < capacity; j++) { + HandleScope loop_scope; + Handle k(dict->KeyAt(j)); + if (dict->IsKey(*k)) { + ASSERT(k->IsNumber()); + uint32_t index = static_cast(k->Number()); + if (index < range) { + indices->Add(index); } } } - } else { - for (uint32_t j = 0; j < len; j++) { - Handle e = Factory::NewNumber(array->get(j)); - visitor->visit(j, e); + break; + } + default: { + int dense_elements_length; + switch (kind) { + case JSObject::PIXEL_ELEMENTS: { + dense_elements_length = + PixelArray::cast(object->elements())->length(); + break; + } + case JSObject::EXTERNAL_BYTE_ELEMENTS: { + dense_elements_length = + ExternalByteArray::cast(object->elements())->length(); + break; + } + case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { + dense_elements_length = + ExternalUnsignedByteArray::cast(object->elements())->length(); + break; + } + case JSObject::EXTERNAL_SHORT_ELEMENTS: { + dense_elements_length = + ExternalShortArray::cast(object->elements())->length(); + break; + } + case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { + dense_elements_length = + ExternalUnsignedShortArray::cast(object->elements())->length(); + break; + } + case JSObject::EXTERNAL_INT_ELEMENTS: { + dense_elements_length = + ExternalIntArray::cast(object->elements())->length(); + break; + } + case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: { + dense_elements_length = + ExternalUnsignedIntArray::cast(object->elements())->length(); + break; + } + case JSObject::EXTERNAL_FLOAT_ELEMENTS: { + dense_elements_length = + ExternalFloatArray::cast(object->elements())->length(); + break; + } + default: + UNREACHABLE(); + dense_elements_length = 0; + break; + } + uint32_t length = static_cast(dense_elements_length); + if (range <= length) { + length = range; + // We will add all indices, so we might as well clear it first + // and avoid duplicates. + indices->Clear(); + } + for (uint32_t i = 0; i < length; i++) { + indices->Add(i); } + if (length == range) return; // All indices accounted for already. + break; } } - return len; + Handle prototype(object->GetPrototype()); + if (prototype->IsJSObject()) { + // The prototype will usually have no inherited element indices, + // but we have to check. + CollectElementIndices(Handle::cast(prototype), range, indices); + } } + /** - * A helper function that visits elements of a JSObject. Only elements - * whose index between 0 and range (exclusive) are visited. - * - * If the third parameter, visitor, is not NULL, the visitor is called - * with parameters, 'visitor_index_offset + element index' and the element. + * A helper function that visits elements of a JSArray in numerical + * order. * - * It returns the number of visisted elements. + * The visitor argument called for each existing element in the array + * with the element index and the element's value. + * Afterwards it increments the base-index of the visitor by the array + * length. */ -static uint32_t IterateElements(Handle receiver, - uint32_t range, - ArrayConcatVisitor* visitor) { - uint32_t num_of_elements = 0; - +static void IterateElements(Handle receiver, + ArrayConcatVisitor* visitor) { + uint32_t length = static_cast(receiver->length()->Number()); switch (receiver->GetElementsKind()) { case JSObject::FAST_ELEMENTS: { + // Run through the elements FixedArray and use HasElement and GetElement + // to check the prototype for missing elements. Handle elements(FixedArray::cast(receiver->elements())); - uint32_t len = elements->length(); - if (range < len) { - len = range; - } - - for (uint32_t j = 0; j < len; j++) { - Handle e(elements->get(j)); - if (!e->IsTheHole()) { - num_of_elements++; - if (visitor) { - visitor->visit(j, e); - } + int fast_length = static_cast(length); + ASSERT(fast_length <= elements->length()); + for (int j = 0; j < fast_length; j++) { + HandleScope loop_scope; + Handle element_value(elements->get(j)); + if (!element_value->IsTheHole()) { + visitor->visit(j, element_value); + } else if (receiver->HasElement(j)) { + // Call GetElement on receiver, not its prototype, or getters won't + // have the correct receiver. + element_value = GetElement(receiver, j); + visitor->visit(j, element_value); } } break; } + case JSObject::DICTIONARY_ELEMENTS: { + Handle dict(receiver->element_dictionary()); + List indices(dict->Capacity() / 2); + // Collect all indices in the object and the prototypes less + // than length. This might introduce duplicates in the indices list. + CollectElementIndices(receiver, length, &indices); + indices.Sort(&compareUInt32); + int j = 0; + int n = indices.length(); + while (j < n) { + HandleScope loop_scope; + uint32_t index = indices[j]; + Handle element = GetElement(receiver, index); + visitor->visit(index, element); + // Skip to next different index (i.e., omit duplicates). + do { + j++; + } while (j < n && indices[j] == index); + } + break; + } case JSObject::PIXEL_ELEMENTS: { Handle pixels(PixelArray::cast(receiver->elements())); - uint32_t len = pixels->length(); - if (range < len) { - len = range; - } - - for (uint32_t j = 0; j < len; j++) { - num_of_elements++; - if (visitor != NULL) { - Handle e(Smi::FromInt(pixels->get(j))); - visitor->visit(j, e); - } + for (uint32_t j = 0; j < length; j++) { + Handle e(Smi::FromInt(pixels->get(j))); + visitor->visit(j, e); } break; } case JSObject::EXTERNAL_BYTE_ELEMENTS: { - num_of_elements = - IterateExternalArrayElements( - receiver, true, true, range, visitor); + IterateExternalArrayElements( + receiver, true, true, visitor); break; } case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { - num_of_elements = - IterateExternalArrayElements( - receiver, true, true, range, visitor); + IterateExternalArrayElements( + receiver, true, true, visitor); break; } case JSObject::EXTERNAL_SHORT_ELEMENTS: { - num_of_elements = - IterateExternalArrayElements( - receiver, true, true, range, visitor); + IterateExternalArrayElements( + receiver, true, true, visitor); break; } case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { - num_of_elements = - IterateExternalArrayElements( - receiver, true, true, range, visitor); + IterateExternalArrayElements( + receiver, true, true, visitor); break; } case JSObject::EXTERNAL_INT_ELEMENTS: { - num_of_elements = - IterateExternalArrayElements( - receiver, true, false, range, visitor); + IterateExternalArrayElements( + receiver, true, false, visitor); break; } case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: { - num_of_elements = - IterateExternalArrayElements( - receiver, true, false, range, visitor); + IterateExternalArrayElements( + receiver, true, false, visitor); break; } case JSObject::EXTERNAL_FLOAT_ELEMENTS: { - num_of_elements = - IterateExternalArrayElements( - receiver, false, false, range, visitor); - break; - } - case JSObject::DICTIONARY_ELEMENTS: { - Handle dict(receiver->element_dictionary()); - uint32_t capacity = dict->Capacity(); - for (uint32_t j = 0; j < capacity; j++) { - Handle k(dict->KeyAt(j)); - if (dict->IsKey(*k)) { - ASSERT(k->IsNumber()); - uint32_t index = static_cast(k->Number()); - if (index < range) { - num_of_elements++; - if (visitor) { - visitor->visit(index, Handle(dict->ValueAt(j))); - } - } - } - } + IterateExternalArrayElements( + receiver, false, false, visitor); break; } default: UNREACHABLE(); break; } - - return num_of_elements; -} - - -/** - * A helper function that visits elements of an Array object, and elements - * on its prototypes. - * - * Elements on prototypes are visited first, and only elements whose indices - * less than Array length are visited. - * - * If a ArrayConcatVisitor object is given, the visitor is called with - * parameters, element's index + visitor_index_offset and the element. - * - * The returned number of elements is an upper bound on the actual number - * of elements added. If the same element occurs in more than one object - * in the array's prototype chain, it will be counted more than once, but - * will only occur once in the result. - */ -static uint32_t IterateArrayAndPrototypeElements(Handle array, - ArrayConcatVisitor* visitor) { - uint32_t range = static_cast(array->length()->Number()); - Handle obj = array; - - static const int kEstimatedPrototypes = 3; - List< Handle > objects(kEstimatedPrototypes); - - // Visit prototype first. If an element on the prototype is shadowed by - // the inheritor using the same index, the ArrayConcatVisitor visits - // the prototype element before the shadowing element. - // The visitor can simply overwrite the old value by new value using - // the same index. This follows Array::concat semantics. - while (!obj->IsNull()) { - objects.Add(Handle::cast(obj)); - obj = Handle(obj->GetPrototype()); - } - - uint32_t nof_elements = 0; - for (int i = objects.length() - 1; i >= 0; i--) { - Handle obj = objects[i]; - uint32_t encountered_elements = - IterateElements(Handle::cast(obj), range, visitor); - - if (encountered_elements > JSObject::kMaxElementCount - nof_elements) { - nof_elements = JSObject::kMaxElementCount; - } else { - nof_elements += encountered_elements; - } - } - - return nof_elements; -} - - -/** - * A helper function of Runtime_ArrayConcat. - * - * The first argument is an Array of arrays and objects. It is the - * same as the arguments array of Array::concat JS function. - * - * If an argument is an Array object, the function visits array - * elements. If an argument is not an Array object, the function - * visits the object as if it is an one-element array. - * - * If the result array index overflows 32-bit unsigned integer, the rounded - * non-negative number is used as new length. For example, if one - * array length is 2^32 - 1, second array length is 1, the - * concatenated array length is 0. - * TODO(lrn) Change length behavior to ECMAScript 5 specification (length - * is one more than the last array index to get a value assigned). - */ -static uint32_t IterateArguments(Handle arguments, - ArrayConcatVisitor* visitor) { - uint32_t visited_elements = 0; - uint32_t num_of_args = static_cast(arguments->length()->Number()); - - for (uint32_t i = 0; i < num_of_args; i++) { - Object *element; - MaybeObject* maybe_element = arguments->GetElement(i); - // This if() is not expected to fail, but we have the check in the - // interest of hardening the runtime calls. - if (maybe_element->ToObject(&element)) { - Handle obj(element); - if (obj->IsJSArray()) { - Handle array = Handle::cast(obj); - uint32_t len = static_cast(array->length()->Number()); - uint32_t nof_elements = - IterateArrayAndPrototypeElements(array, visitor); - // Total elements of array and its prototype chain can be more than - // the array length, but ArrayConcat can only concatenate at most - // the array length number of elements. We use the length as an estimate - // for the actual number of elements added. - uint32_t added_elements = (nof_elements > len) ? len : nof_elements; - if (JSArray::kMaxElementCount - visited_elements < added_elements) { - visited_elements = JSArray::kMaxElementCount; - } else { - visited_elements += added_elements; - } - if (visitor) visitor->increase_index_offset(len); - } else { - if (visitor) { - visitor->visit(0, obj); - visitor->increase_index_offset(1); - } - if (visited_elements < JSArray::kMaxElementCount) { - visited_elements++; - } - } - } - } - return visited_elements; + visitor->increase_index_offset(length); } /** * Array::concat implementation. * See ECMAScript 262, 15.4.4.4. - * TODO(lrn): Fix non-compliance for very large concatenations and update to + * TODO(581): Fix non-compliance for very large concatenations and update to * following the ECMAScript 5 specification. */ static MaybeObject* Runtime_ArrayConcat(Arguments args) { ASSERT(args.length() == 1); HandleScope handle_scope; - CONVERT_CHECKED(JSArray, arg_arrays, args[0]); - Handle arguments(arg_arrays); - - // Pass 1: estimate the number of elements of the result - // (it could be more than real numbers if prototype has elements). - uint32_t result_length = 0; - uint32_t num_of_args = static_cast(arguments->length()->Number()); - - { AssertNoAllocation nogc; - for (uint32_t i = 0; i < num_of_args; i++) { - Object* obj; - MaybeObject* maybe_object = arguments->GetElement(i); - // This if() is not expected to fail, but we have the check in the - // interest of hardening the runtime calls. - if (maybe_object->ToObject(&obj)) { - uint32_t length_estimate; - if (obj->IsJSArray()) { - length_estimate = - static_cast(JSArray::cast(obj)->length()->Number()); - } else { - length_estimate = 1; - } - if (JSObject::kMaxElementCount - result_length < length_estimate) { - result_length = JSObject::kMaxElementCount; - break; - } - result_length += length_estimate; + CONVERT_ARG_CHECKED(JSArray, arguments, 0); + int argument_count = static_cast(arguments->length()->Number()); + RUNTIME_ASSERT(arguments->HasFastElements()); + Handle elements(FixedArray::cast(arguments->elements())); + + // Pass 1: estimate the length and number of elements of the result. + // The actual length can be larger if any of the arguments have getters + // that mutate other arguments (but will otherwise be precise). + // The number of elements is precise if there are no inherited elements. + + uint32_t estimate_result_length = 0; + uint32_t estimate_nof_elements = 0; + { + for (int i = 0; i < argument_count; i++) { + HandleScope loop_scope; + Handle obj(elements->get(i)); + uint32_t length_estimate; + uint32_t element_estimate; + if (obj->IsJSArray()) { + Handle array(Handle::cast(obj)); + length_estimate = + static_cast(array->length()->Number()); + element_estimate = + EstimateElementCount(array); + } else { + length_estimate = 1; + element_estimate = 1; + } + // Avoid overflows by capping at kMaxElementCount. + if (JSObject::kMaxElementCount - estimate_result_length < + length_estimate) { + estimate_result_length = JSObject::kMaxElementCount; + } else { + estimate_result_length += length_estimate; + } + if (JSObject::kMaxElementCount - estimate_nof_elements < + element_estimate) { + estimate_nof_elements = JSObject::kMaxElementCount; + } else { + estimate_nof_elements += element_estimate; } } } - // Allocate an empty array, will set map, length, and content later. - Handle result = Factory::NewJSArray(0); - - uint32_t estimate_nof_elements = IterateArguments(arguments, NULL); // If estimated number of elements is more than half of length, a // fixed array (fast case) is more time and space-efficient than a // dictionary. - bool fast_case = (estimate_nof_elements * 2) >= result_length; + bool fast_case = (estimate_nof_elements * 2) >= estimate_result_length; - Handle map; Handle storage; if (fast_case) { // The backing storage array must have non-existing elements to // preserve holes across concat operations. - map = Factory::GetFastElementsMap(Handle(result->map())); - storage = Factory::NewFixedArrayWithHoles(result_length); + storage = Factory::NewFixedArrayWithHoles(estimate_result_length); } else { - map = Factory::GetSlowElementsMap(Handle(result->map())); // TODO(126): move 25% pre-allocation logic into Dictionary::Allocate uint32_t at_least_space_for = estimate_nof_elements + (estimate_nof_elements >> 2); @@ -8406,21 +8553,20 @@ static MaybeObject* Runtime_ArrayConcat(Arguments args) { Factory::NewNumberDictionary(at_least_space_for)); } - Handle len = Factory::NewNumber(static_cast(result_length)); - - ArrayConcatVisitor visitor(storage, result_length, fast_case); - - IterateArguments(arguments, &visitor); + ArrayConcatVisitor visitor(storage, fast_case); - // Please note: - // - the storage might have been changed in the visitor; - // - the map and the storage must be set together to avoid breaking - // the invariant that the map describes the array's elements. - result->set_map(*map); - result->set_length(*len); - result->set_elements(*visitor.storage()); + for (int i = 0; i < argument_count; i++) { + Handle obj(elements->get(i)); + if (obj->IsJSArray()) { + Handle array = Handle::cast(obj); + IterateElements(array, &visitor); + } else { + visitor.visit(0, obj); + visitor.increase_index_offset(1); + } + } - return *result; + return *visitor.ToArray(); } @@ -9192,7 +9338,9 @@ static bool CopyContextLocalsToScopeObject( RETURN_IF_EMPTY_HANDLE_VALUE( SetProperty(scope_object, scope_info.context_slot_name(i), - Handle(context->get(context_index)), NONE), + Handle(context->get(context_index)), + NONE, + kNonStrictMode), false); } } @@ -9218,7 +9366,9 @@ static Handle MaterializeLocalScope(JavaScriptFrame* frame) { RETURN_IF_EMPTY_HANDLE_VALUE( SetProperty(local_scope, scope_info.parameter_name(i), - Handle(frame->GetParameter(i)), NONE), + Handle(frame->GetParameter(i)), + NONE, + kNonStrictMode), Handle()); } @@ -9227,7 +9377,9 @@ static Handle MaterializeLocalScope(JavaScriptFrame* frame) { RETURN_IF_EMPTY_HANDLE_VALUE( SetProperty(local_scope, scope_info.stack_slot_name(i), - Handle(frame->GetExpression(i)), NONE), + Handle(frame->GetExpression(i)), + NONE, + kNonStrictMode), Handle()); } @@ -9251,7 +9403,11 @@ static Handle MaterializeLocalScope(JavaScriptFrame* frame) { ASSERT(keys->get(i)->IsString()); Handle key(String::cast(keys->get(i))); RETURN_IF_EMPTY_HANDLE_VALUE( - SetProperty(local_scope, key, GetProperty(ext, key), NONE), + SetProperty(local_scope, + key, + GetProperty(ext, key), + NONE, + kNonStrictMode), Handle()); } } @@ -9289,7 +9445,8 @@ static Handle MaterializeClosure(Handle context) { SetProperty(closure_scope, scope_info.parameter_name(i), Handle(element), - NONE), + NONE, + kNonStrictMode), Handle()); } } @@ -9310,7 +9467,11 @@ static Handle MaterializeClosure(Handle context) { ASSERT(keys->get(i)->IsString()); Handle key(String::cast(keys->get(i))); RETURN_IF_EMPTY_HANDLE_VALUE( - SetProperty(closure_scope, key, GetProperty(ext, key), NONE), + SetProperty(closure_scope, + key, + GetProperty(ext, key), + NONE, + kNonStrictMode), Handle()); } } @@ -10788,6 +10949,207 @@ static MaybeObject* Runtime_GetHeapUsage(Arguments args) { } return Smi::FromInt(usage); } + + +// Captures a live object list from the present heap. +static MaybeObject* Runtime_HasLOLEnabled(Arguments args) { +#ifdef LIVE_OBJECT_LIST + return Heap::true_value(); +#else + return Heap::false_value(); +#endif +} + + +// Captures a live object list from the present heap. +static MaybeObject* Runtime_CaptureLOL(Arguments args) { +#ifdef LIVE_OBJECT_LIST + return LiveObjectList::Capture(); +#else + return Heap::undefined_value(); +#endif +} + + +// Deletes the specified live object list. +static MaybeObject* Runtime_DeleteLOL(Arguments args) { +#ifdef LIVE_OBJECT_LIST + CONVERT_SMI_CHECKED(id, args[0]); + bool success = LiveObjectList::Delete(id); + return success ? Heap::true_value() : Heap::false_value(); +#else + return Heap::undefined_value(); +#endif +} + + +// Generates the response to a debugger request for a dump of the objects +// contained in the difference between the captured live object lists +// specified by id1 and id2. +// If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be +// dumped. +static MaybeObject* Runtime_DumpLOL(Arguments args) { +#ifdef LIVE_OBJECT_LIST + HandleScope scope; + CONVERT_SMI_CHECKED(id1, args[0]); + CONVERT_SMI_CHECKED(id2, args[1]); + CONVERT_SMI_CHECKED(start, args[2]); + CONVERT_SMI_CHECKED(count, args[3]); + CONVERT_ARG_CHECKED(JSObject, filter_obj, 4); + EnterDebugger enter_debugger; + return LiveObjectList::Dump(id1, id2, start, count, filter_obj); +#else + return Heap::undefined_value(); +#endif +} + + +// Gets the specified object as requested by the debugger. +// This is only used for obj ids shown in live object lists. +static MaybeObject* Runtime_GetLOLObj(Arguments args) { +#ifdef LIVE_OBJECT_LIST + CONVERT_SMI_CHECKED(obj_id, args[0]); + Object* result = LiveObjectList::GetObj(obj_id); + return result; +#else + return Heap::undefined_value(); +#endif +} + + +// Gets the obj id for the specified address if valid. +// This is only used for obj ids shown in live object lists. +static MaybeObject* Runtime_GetLOLObjId(Arguments args) { +#ifdef LIVE_OBJECT_LIST + HandleScope scope; + CONVERT_ARG_CHECKED(String, address, 0); + Object* result = LiveObjectList::GetObjId(address); + return result; +#else + return Heap::undefined_value(); +#endif +} + + +// Gets the retainers that references the specified object alive. +static MaybeObject* Runtime_GetLOLObjRetainers(Arguments args) { +#ifdef LIVE_OBJECT_LIST + HandleScope scope; + CONVERT_SMI_CHECKED(obj_id, args[0]); + RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject()); + RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsBoolean()); + RUNTIME_ASSERT(args[3]->IsUndefined() || args[3]->IsSmi()); + RUNTIME_ASSERT(args[4]->IsUndefined() || args[4]->IsSmi()); + CONVERT_ARG_CHECKED(JSObject, filter_obj, 5); + + Handle instance_filter; + if (args[1]->IsJSObject()) { + instance_filter = args.at(1); + } + bool verbose = false; + if (args[2]->IsBoolean()) { + verbose = args[2]->IsTrue(); + } + int start = 0; + if (args[3]->IsSmi()) { + start = Smi::cast(args[3])->value(); + } + int limit = Smi::kMaxValue; + if (args[4]->IsSmi()) { + limit = Smi::cast(args[4])->value(); + } + + return LiveObjectList::GetObjRetainers(obj_id, + instance_filter, + verbose, + start, + limit, + filter_obj); +#else + return Heap::undefined_value(); +#endif +} + + +// Gets the reference path between 2 objects. +static MaybeObject* Runtime_GetLOLPath(Arguments args) { +#ifdef LIVE_OBJECT_LIST + HandleScope scope; + CONVERT_SMI_CHECKED(obj_id1, args[0]); + CONVERT_SMI_CHECKED(obj_id2, args[1]); + RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsJSObject()); + + Handle instance_filter; + if (args[2]->IsJSObject()) { + instance_filter = args.at(2); + } + + Object* result = + LiveObjectList::GetPath(obj_id1, obj_id2, instance_filter); + return result; +#else + return Heap::undefined_value(); +#endif +} + + +// Generates the response to a debugger request for a list of all +// previously captured live object lists. +static MaybeObject* Runtime_InfoLOL(Arguments args) { +#ifdef LIVE_OBJECT_LIST + CONVERT_SMI_CHECKED(start, args[0]); + CONVERT_SMI_CHECKED(count, args[1]); + return LiveObjectList::Info(start, count); +#else + return Heap::undefined_value(); +#endif +} + + +// Gets a dump of the specified object as requested by the debugger. +// This is only used for obj ids shown in live object lists. +static MaybeObject* Runtime_PrintLOLObj(Arguments args) { +#ifdef LIVE_OBJECT_LIST + HandleScope scope; + CONVERT_SMI_CHECKED(obj_id, args[0]); + Object* result = LiveObjectList::PrintObj(obj_id); + return result; +#else + return Heap::undefined_value(); +#endif +} + + +// Resets and releases all previously captured live object lists. +static MaybeObject* Runtime_ResetLOL(Arguments args) { +#ifdef LIVE_OBJECT_LIST + LiveObjectList::Reset(); + return Heap::undefined_value(); +#else + return Heap::undefined_value(); +#endif +} + + +// Generates the response to a debugger request for a summary of the types +// of objects in the difference between the captured live object lists +// specified by id1 and id2. +// If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be +// summarized. +static MaybeObject* Runtime_SummarizeLOL(Arguments args) { +#ifdef LIVE_OBJECT_LIST + HandleScope scope; + CONVERT_SMI_CHECKED(id1, args[0]); + CONVERT_SMI_CHECKED(id2, args[1]); + CONVERT_ARG_CHECKED(JSObject, filter_obj, 2); + + EnterDebugger enter_debugger; + return LiveObjectList::Summarize(id1, id2, filter_obj); +#else + return Heap::undefined_value(); +#endif +} + #endif // ENABLE_DEBUGGER_SUPPORT diff --git a/deps/v8/src/runtime.h b/deps/v8/src/runtime.h index 06437ef9fb..9dd6eda0a9 100644 --- a/deps/v8/src/runtime.h +++ b/deps/v8/src/runtime.h @@ -241,7 +241,7 @@ namespace internal { F(ResolvePossiblyDirectEval, 4, 2) \ F(ResolvePossiblyDirectEvalNoLookup, 4, 2) \ \ - F(SetProperty, -1 /* 3 or 4 */, 1) \ + F(SetProperty, -1 /* 4 or 5 */, 1) \ F(DefineOrRedefineDataProperty, 4, 1) \ F(DefineOrRedefineAccessorProperty, 5, 1) \ F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \ @@ -288,12 +288,12 @@ namespace internal { F(DeleteContextSlot, 2, 1) \ F(LoadContextSlot, 2, 2) \ F(LoadContextSlotNoReferenceError, 2, 2) \ - F(StoreContextSlot, 3, 1) \ + F(StoreContextSlot, 4, 1) \ \ /* Declarations and initialization */ \ - F(DeclareGlobals, 3, 1) \ + F(DeclareGlobals, 4, 1) \ F(DeclareContextSlot, 4, 1) \ - F(InitializeVarGlobal, -1 /* 1 or 2 */, 1) \ + F(InitializeVarGlobal, -1 /* 2 or 3 */, 1) \ F(InitializeConstGlobal, 2, 1) \ F(InitializeConstContextSlot, 3, 1) \ F(OptimizeObjectForAddingMultipleProperties, 2, 1) \ @@ -376,7 +376,21 @@ namespace internal { \ F(SetFlags, 1, 1) \ F(CollectGarbage, 1, 1) \ - F(GetHeapUsage, 0, 1) + F(GetHeapUsage, 0, 1) \ + \ + /* LiveObjectList support*/ \ + F(HasLOLEnabled, 0, 1) \ + F(CaptureLOL, 0, 1) \ + F(DeleteLOL, 1, 1) \ + F(DumpLOL, 5, 1) \ + F(GetLOLObj, 1, 1) \ + F(GetLOLObjId, 1, 1) \ + F(GetLOLObjRetainers, 6, 1) \ + F(GetLOLPath, 3, 1) \ + F(InfoLOL, 2, 1) \ + F(PrintLOLObj, 1, 1) \ + F(ResetLOL, 0, 1) \ + F(SummarizeLOL, 3, 1) #else #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) @@ -538,7 +552,8 @@ class Runtime : public AllStatic { Handle object, Handle key, Handle value, - PropertyAttributes attr); + PropertyAttributes attr, + StrictModeFlag strict); MUST_USE_RESULT static MaybeObject* ForceSetObjectProperty( Handle object, diff --git a/deps/v8/src/spaces.h b/deps/v8/src/spaces.h index 4f2d07b0c8..6165255fd4 100644 --- a/deps/v8/src/spaces.h +++ b/deps/v8/src/spaces.h @@ -2121,6 +2121,12 @@ class MapSpace : public FixedSpace { accounting_stats_.DeallocateBytes(accounting_stats_.Size()); accounting_stats_.AllocateBytes(new_size); + // Flush allocation watermarks. + for (Page* p = first_page_; p != top_page; p = p->next_page()) { + p->SetAllocationWatermark(p->AllocationTop()); + } + top_page->SetAllocationWatermark(new_top); + #ifdef DEBUG if (FLAG_enable_slow_asserts) { intptr_t actual_size = 0; diff --git a/deps/v8/src/stub-cache.cc b/deps/v8/src/stub-cache.cc index abb26d6ed4..360f0b743e 100644 --- a/deps/v8/src/stub-cache.cc +++ b/deps/v8/src/stub-cache.cc @@ -498,13 +498,13 @@ MaybeObject* StubCache::ComputeStoreField(String* name, JSObject* receiver, int field_index, Map* transition, - Code::ExtraICState extra_ic_state) { + StrictModeFlag strict_mode) { PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; Code::Flags flags = Code::ComputeMonomorphicFlags( - Code::STORE_IC, type, extra_ic_state); + Code::STORE_IC, type, strict_mode); Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { - StoreStubCompiler compiler(extra_ic_state); + StoreStubCompiler compiler(strict_mode); { MaybeObject* maybe_code = compiler.CompileStoreField(receiver, field_index, transition, name); if (!maybe_code->ToObject(&code)) return maybe_code; @@ -521,13 +521,15 @@ MaybeObject* StubCache::ComputeStoreField(String* name, } -MaybeObject* StubCache::ComputeKeyedStoreSpecialized(JSObject* receiver) { +MaybeObject* StubCache::ComputeKeyedStoreSpecialized( + JSObject* receiver, + StrictModeFlag strict_mode) { Code::Flags flags = - Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL); + Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL, strict_mode); String* name = Heap::KeyedStoreSpecialized_symbol(); Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { - KeyedStoreStubCompiler compiler; + KeyedStoreStubCompiler compiler(strict_mode); { MaybeObject* maybe_code = compiler.CompileStoreSpecialized(receiver); if (!maybe_code->ToObject(&code)) return maybe_code; } @@ -542,7 +544,9 @@ MaybeObject* StubCache::ComputeKeyedStoreSpecialized(JSObject* receiver) { } -MaybeObject* StubCache::ComputeKeyedStorePixelArray(JSObject* receiver) { +MaybeObject* StubCache::ComputeKeyedStorePixelArray( + JSObject* receiver, + StrictModeFlag strict_mode) { // Using NORMAL as the PropertyType for array element stores is a misuse. The // generated stub always accesses fast elements, not slow-mode fields, but // some property type is required for the stub lookup. Note that overloading @@ -550,11 +554,11 @@ MaybeObject* StubCache::ComputeKeyedStorePixelArray(JSObject* receiver) { // other keyed field stores. This is guaranteed to be the case since all field // keyed stores that are not array elements go through a generic builtin stub. Code::Flags flags = - Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL); + Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL, strict_mode); String* name = Heap::KeyedStorePixelArray_symbol(); Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { - KeyedStoreStubCompiler compiler; + KeyedStoreStubCompiler compiler(strict_mode); { MaybeObject* maybe_code = compiler.CompileStorePixelArray(receiver); if (!maybe_code->ToObject(&code)) return maybe_code; } @@ -598,11 +602,13 @@ ExternalArrayType ElementsKindToExternalArrayType(JSObject::ElementsKind kind) { MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray( JSObject* receiver, - bool is_store) { + bool is_store, + StrictModeFlag strict_mode) { Code::Flags flags = Code::ComputeMonomorphicFlags( is_store ? Code::KEYED_STORE_IC : Code::KEYED_LOAD_IC, - NORMAL); + NORMAL, + strict_mode); ExternalArrayType array_type = ElementsKindToExternalArrayType(receiver->GetElementsKind()); String* name = @@ -615,9 +621,9 @@ MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray( Object* code = map->FindInCodeCache(name, flags); if (code->IsUndefined()) { ExternalArrayStubCompiler compiler; - { MaybeObject* maybe_code = - is_store ? compiler.CompileKeyedStoreStub(array_type, flags) : - compiler.CompileKeyedLoadStub(array_type, flags); + { MaybeObject* maybe_code = is_store + ? compiler.CompileKeyedStoreStub(array_type, flags) + : compiler.CompileKeyedLoadStub(array_type, flags); if (!maybe_code->ToObject(&code)) return maybe_code; } if (is_store) { @@ -637,8 +643,8 @@ MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray( } -MaybeObject* StubCache::ComputeStoreNormal(Code::ExtraICState extra_ic_state) { - return Builtins::builtin(extra_ic_state == StoreIC::kStoreICStrict +MaybeObject* StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { + return Builtins::builtin((strict_mode == kStrictMode) ? Builtins::StoreIC_Normal_Strict : Builtins::StoreIC_Normal); } @@ -647,12 +653,12 @@ MaybeObject* StubCache::ComputeStoreNormal(Code::ExtraICState extra_ic_state) { MaybeObject* StubCache::ComputeStoreGlobal(String* name, GlobalObject* receiver, JSGlobalPropertyCell* cell, - Code::ExtraICState extra_ic_state) { + StrictModeFlag strict_mode) { Code::Flags flags = Code::ComputeMonomorphicFlags( - Code::STORE_IC, NORMAL, extra_ic_state); + Code::STORE_IC, NORMAL, strict_mode); Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { - StoreStubCompiler compiler(extra_ic_state); + StoreStubCompiler compiler(strict_mode); { MaybeObject* maybe_code = compiler.CompileStoreGlobal(receiver, cell, name); if (!maybe_code->ToObject(&code)) return maybe_code; @@ -673,13 +679,13 @@ MaybeObject* StubCache::ComputeStoreCallback( String* name, JSObject* receiver, AccessorInfo* callback, - Code::ExtraICState extra_ic_state) { + StrictModeFlag strict_mode) { ASSERT(v8::ToCData
(callback->setter()) != 0); Code::Flags flags = Code::ComputeMonomorphicFlags( - Code::STORE_IC, CALLBACKS, extra_ic_state); + Code::STORE_IC, CALLBACKS, strict_mode); Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { - StoreStubCompiler compiler(extra_ic_state); + StoreStubCompiler compiler(strict_mode); { MaybeObject* maybe_code = compiler.CompileStoreCallback(receiver, callback, name); if (!maybe_code->ToObject(&code)) return maybe_code; @@ -699,12 +705,12 @@ MaybeObject* StubCache::ComputeStoreCallback( MaybeObject* StubCache::ComputeStoreInterceptor( String* name, JSObject* receiver, - Code::ExtraICState extra_ic_state) { + StrictModeFlag strict_mode) { Code::Flags flags = Code::ComputeMonomorphicFlags( - Code::STORE_IC, INTERCEPTOR, extra_ic_state); + Code::STORE_IC, INTERCEPTOR, strict_mode); Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { - StoreStubCompiler compiler(extra_ic_state); + StoreStubCompiler compiler(strict_mode); { MaybeObject* maybe_code = compiler.CompileStoreInterceptor(receiver, name); if (!maybe_code->ToObject(&code)) return maybe_code; @@ -724,12 +730,14 @@ MaybeObject* StubCache::ComputeStoreInterceptor( MaybeObject* StubCache::ComputeKeyedStoreField(String* name, JSObject* receiver, int field_index, - Map* transition) { + Map* transition, + StrictModeFlag strict_mode) { PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; - Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); + Code::Flags flags = Code::ComputeMonomorphicFlags( + Code::KEYED_STORE_IC, type, strict_mode); Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { - KeyedStoreStubCompiler compiler; + KeyedStoreStubCompiler compiler(strict_mode); { MaybeObject* maybe_code = compiler.CompileStoreField(receiver, field_index, transition, name); if (!maybe_code->ToObject(&code)) return maybe_code; @@ -1417,12 +1425,17 @@ MaybeObject* LoadPropertyWithInterceptorForCall(Arguments args) { MaybeObject* StoreInterceptorProperty(Arguments args) { + ASSERT(args.length() == 4); JSObject* recv = JSObject::cast(args[0]); String* name = String::cast(args[1]); Object* value = args[2]; + StrictModeFlag strict = + static_cast(Smi::cast(args[3])->value()); + ASSERT(strict == kStrictMode || strict == kNonStrictMode); ASSERT(recv->HasNamedInterceptor()); PropertyAttributes attr = NONE; - MaybeObject* result = recv->SetPropertyWithInterceptor(name, value, attr); + MaybeObject* result = recv->SetPropertyWithInterceptor( + name, value, attr, strict); return result; } @@ -1675,8 +1688,8 @@ MaybeObject* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) { MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { - Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type, - extra_ic_state_); + Code::Flags flags = Code::ComputeMonomorphicFlags( + Code::STORE_IC, type, strict_mode_); MaybeObject* result = GetCodeWithFlags(flags, name); if (!result->IsFailure()) { PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, @@ -1691,7 +1704,8 @@ MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { - Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); + Code::Flags flags = Code::ComputeMonomorphicFlags( + Code::KEYED_STORE_IC, type, strict_mode_); MaybeObject* result = GetCodeWithFlags(flags, name); if (!result->IsFailure()) { PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, diff --git a/deps/v8/src/stub-cache.h b/deps/v8/src/stub-cache.h index 4638da2ad7..6927076c16 100644 --- a/deps/v8/src/stub-cache.h +++ b/deps/v8/src/stub-cache.h @@ -143,27 +143,27 @@ class StubCache : public AllStatic { JSObject* receiver, int field_index, Map* transition, - Code::ExtraICState extra_ic_state); + StrictModeFlag strict_mode); MUST_USE_RESULT static MaybeObject* ComputeStoreNormal( - Code::ExtraICState extra_ic_state); + StrictModeFlag strict_mode); MUST_USE_RESULT static MaybeObject* ComputeStoreGlobal( String* name, GlobalObject* receiver, JSGlobalPropertyCell* cell, - Code::ExtraICState extra_ic_state); + StrictModeFlag strict_mode); MUST_USE_RESULT static MaybeObject* ComputeStoreCallback( String* name, JSObject* receiver, AccessorInfo* callback, - Code::ExtraICState extra_ic_state); + StrictModeFlag strict_mode); MUST_USE_RESULT static MaybeObject* ComputeStoreInterceptor( String* name, JSObject* receiver, - Code::ExtraICState extra_ic_state); + StrictModeFlag strict_mode); // --- @@ -171,17 +171,21 @@ class StubCache : public AllStatic { String* name, JSObject* receiver, int field_index, - Map* transition = NULL); + Map* transition, + StrictModeFlag strict_mode); MUST_USE_RESULT static MaybeObject* ComputeKeyedStoreSpecialized( - JSObject* receiver); + JSObject* receiver, + StrictModeFlag strict_mode); MUST_USE_RESULT static MaybeObject* ComputeKeyedStorePixelArray( - JSObject* receiver); + JSObject* receiver, + StrictModeFlag strict_mode); MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadOrStoreExternalArray( JSObject* receiver, - bool is_store); + bool is_store, + StrictModeFlag strict_mode); // --- @@ -628,8 +632,8 @@ class KeyedLoadStubCompiler: public StubCompiler { class StoreStubCompiler: public StubCompiler { public: - explicit StoreStubCompiler(Code::ExtraICState extra_ic_state) - : extra_ic_state_(extra_ic_state) { } + explicit StoreStubCompiler(StrictModeFlag strict_mode) + : strict_mode_(strict_mode) { } MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, int index, @@ -649,12 +653,15 @@ class StoreStubCompiler: public StubCompiler { private: MaybeObject* GetCode(PropertyType type, String* name); - Code::ExtraICState extra_ic_state_; + StrictModeFlag strict_mode_; }; class KeyedStoreStubCompiler: public StubCompiler { public: + explicit KeyedStoreStubCompiler(StrictModeFlag strict_mode) + : strict_mode_(strict_mode) { } + MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, int index, Map* transition, @@ -666,6 +673,8 @@ class KeyedStoreStubCompiler: public StubCompiler { private: MaybeObject* GetCode(PropertyType type, String* name); + + StrictModeFlag strict_mode_; }; diff --git a/deps/v8/src/version.cc b/deps/v8/src/version.cc index 59824863d2..391addcbad 100644 --- a/deps/v8/src/version.cc +++ b/deps/v8/src/version.cc @@ -34,7 +34,7 @@ // cannot be changed without changing the SCons build script. #define MAJOR_VERSION 3 #define MINOR_VERSION 1 -#define BUILD_NUMBER 6 +#define BUILD_NUMBER 8 #define PATCH_LEVEL 0 #define CANDIDATE_VERSION false diff --git a/deps/v8/src/virtual-frame-heavy-inl.h b/deps/v8/src/virtual-frame-heavy-inl.h index 2755eee648..cf12eca623 100644 --- a/deps/v8/src/virtual-frame-heavy-inl.h +++ b/deps/v8/src/virtual-frame-heavy-inl.h @@ -82,10 +82,8 @@ void VirtualFrame::Push(Register reg, TypeInfo info) { } -void VirtualFrame::Push(Handle value) { - FrameElement element = - FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED); - elements_.Add(element); +bool VirtualFrame::ConstantPoolOverflowed() { + return FrameElement::ConstantPoolOverflowed(); } diff --git a/deps/v8/src/x64/assembler-x64-inl.h b/deps/v8/src/x64/assembler-x64-inl.h index 285c07812f..b082624f44 100644 --- a/deps/v8/src/x64/assembler-x64-inl.h +++ b/deps/v8/src/x64/assembler-x64-inl.h @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/assembler-x64.cc b/deps/v8/src/x64/assembler-x64.cc index ea41a202d5..41111a7780 100644 --- a/deps/v8/src/x64/assembler-x64.cc +++ b/deps/v8/src/x64/assembler-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -2995,6 +2995,28 @@ void Assembler::divsd(XMMRegister dst, XMMRegister src) { } +void Assembler::andpd(XMMRegister dst, XMMRegister src) { + EnsureSpace ensure_space(this); + last_pc_ = pc_; + emit(0x66); + emit_optional_rex_32(dst, src); + emit(0x0F); + emit(0x54); + emit_sse_operand(dst, src); +} + + +void Assembler::orpd(XMMRegister dst, XMMRegister src) { + EnsureSpace ensure_space(this); + last_pc_ = pc_; + emit(0x66); + emit_optional_rex_32(dst, src); + emit(0x0F); + emit(0x56); + emit_sse_operand(dst, src); +} + + void Assembler::xorpd(XMMRegister dst, XMMRegister src) { EnsureSpace ensure_space(this); last_pc_ = pc_; diff --git a/deps/v8/src/x64/assembler-x64.h b/deps/v8/src/x64/assembler-x64.h index 553fbe4220..f6cd570936 100644 --- a/deps/v8/src/x64/assembler-x64.h +++ b/deps/v8/src/x64/assembler-x64.h @@ -30,7 +30,7 @@ // The original source code covered by the above license above has been // modified significantly by Google Inc. -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // A lightweight X64 Assembler. @@ -1284,6 +1284,8 @@ class Assembler : public Malloced { void mulsd(XMMRegister dst, XMMRegister src); void divsd(XMMRegister dst, XMMRegister src); + void andpd(XMMRegister dst, XMMRegister src); + void orpd(XMMRegister dst, XMMRegister src); void xorpd(XMMRegister dst, XMMRegister src); void sqrtsd(XMMRegister dst, XMMRegister src); diff --git a/deps/v8/src/x64/builtins-x64.cc b/deps/v8/src/x64/builtins-x64.cc index c362f7b79f..a2dd6cd42a 100644 --- a/deps/v8/src/x64/builtins-x64.cc +++ b/deps/v8/src/x64/builtins-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/code-stubs-x64.cc b/deps/v8/src/x64/code-stubs-x64.cc index 240087e177..42373e3deb 100644 --- a/deps/v8/src/x64/code-stubs-x64.cc +++ b/deps/v8/src/x64/code-stubs-x64.cc @@ -1506,40 +1506,59 @@ void TypeRecordingBinaryOpStub::GenerateRegisterArgsPush(MacroAssembler* masm) { void TranscendentalCacheStub::Generate(MacroAssembler* masm) { - // Input on stack: - // rsp[8]: argument (should be number). - // rsp[0]: return address. + // TAGGED case: + // Input: + // rsp[8]: argument (should be number). + // rsp[0]: return address. + // Output: + // rax: tagged double result. + // UNTAGGED case: + // Input:: + // rsp[0]: return address. + // xmm1: untagged double input argument + // Output: + // xmm1: untagged double result. + Label runtime_call; Label runtime_call_clear_stack; - Label input_not_smi; - NearLabel loaded; - // Test that rax is a number. - __ movq(rax, Operand(rsp, kPointerSize)); - __ JumpIfNotSmi(rax, &input_not_smi); - // Input is a smi. Untag and load it onto the FPU stack. - // Then load the bits of the double into rbx. - __ SmiToInteger32(rax, rax); - __ subq(rsp, Immediate(kPointerSize)); - __ cvtlsi2sd(xmm1, rax); - __ movsd(Operand(rsp, 0), xmm1); - __ movq(rbx, xmm1); - __ movq(rdx, xmm1); - __ fld_d(Operand(rsp, 0)); - __ addq(rsp, Immediate(kPointerSize)); - __ jmp(&loaded); - - __ bind(&input_not_smi); - // Check if input is a HeapNumber. - __ Move(rbx, Factory::heap_number_map()); - __ cmpq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); - __ j(not_equal, &runtime_call); - // Input is a HeapNumber. Push it on the FPU stack and load its - // bits into rbx. - __ fld_d(FieldOperand(rax, HeapNumber::kValueOffset)); - __ movq(rbx, FieldOperand(rax, HeapNumber::kValueOffset)); - __ movq(rdx, rbx); - __ bind(&loaded); - // ST[0] == double value + Label skip_cache; + const bool tagged = (argument_type_ == TAGGED); + if (tagged) { + NearLabel input_not_smi; + NearLabel loaded; + // Test that rax is a number. + __ movq(rax, Operand(rsp, kPointerSize)); + __ JumpIfNotSmi(rax, &input_not_smi); + // Input is a smi. Untag and load it onto the FPU stack. + // Then load the bits of the double into rbx. + __ SmiToInteger32(rax, rax); + __ subq(rsp, Immediate(kDoubleSize)); + __ cvtlsi2sd(xmm1, rax); + __ movsd(Operand(rsp, 0), xmm1); + __ movq(rbx, xmm1); + __ movq(rdx, xmm1); + __ fld_d(Operand(rsp, 0)); + __ addq(rsp, Immediate(kDoubleSize)); + __ jmp(&loaded); + + __ bind(&input_not_smi); + // Check if input is a HeapNumber. + __ LoadRoot(rbx, Heap::kHeapNumberMapRootIndex); + __ cmpq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); + __ j(not_equal, &runtime_call); + // Input is a HeapNumber. Push it on the FPU stack and load its + // bits into rbx. + __ fld_d(FieldOperand(rax, HeapNumber::kValueOffset)); + __ movq(rbx, FieldOperand(rax, HeapNumber::kValueOffset)); + __ movq(rdx, rbx); + + __ bind(&loaded); + } else { // UNTAGGED. + __ movq(rbx, xmm1); + __ movq(rdx, xmm1); + } + + // ST[0] == double value, if TAGGED. // rbx = bits of double value. // rdx = also bits of double value. // Compute hash (h is 32 bits, bits are 64 and the shifts are arithmetic): @@ -1571,7 +1590,7 @@ void TranscendentalCacheStub::Generate(MacroAssembler* masm) { // rax points to the cache for the type type_. // If NULL, the cache hasn't been initialized yet, so go through runtime. __ testq(rax, rax); - __ j(zero, &runtime_call_clear_stack); + __ j(zero, &runtime_call_clear_stack); // Only clears stack if TAGGED. #ifdef DEBUG // Check that the layout of cache elements match expectations. { // NOLINT - doesn't like a single brace on a line. @@ -1597,30 +1616,70 @@ void TranscendentalCacheStub::Generate(MacroAssembler* masm) { __ j(not_equal, &cache_miss); // Cache hit! __ movq(rax, Operand(rcx, 2 * kIntSize)); - __ fstp(0); // Clear FPU stack. - __ ret(kPointerSize); + if (tagged) { + __ fstp(0); // Clear FPU stack. + __ ret(kPointerSize); + } else { // UNTAGGED. + __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset)); + __ Ret(); + } __ bind(&cache_miss); // Update cache with new value. - Label nan_result; - GenerateOperation(masm, &nan_result); + if (tagged) { __ AllocateHeapNumber(rax, rdi, &runtime_call_clear_stack); + } else { // UNTAGGED. + __ AllocateHeapNumber(rax, rdi, &skip_cache); + __ movsd(FieldOperand(rax, HeapNumber::kValueOffset), xmm1); + __ fld_d(FieldOperand(rax, HeapNumber::kValueOffset)); + } + GenerateOperation(masm); __ movq(Operand(rcx, 0), rbx); __ movq(Operand(rcx, 2 * kIntSize), rax); __ fstp_d(FieldOperand(rax, HeapNumber::kValueOffset)); - __ ret(kPointerSize); - - __ bind(&runtime_call_clear_stack); - __ fstp(0); - __ bind(&runtime_call); - __ TailCallExternalReference(ExternalReference(RuntimeFunction()), 1, 1); + if (tagged) { + __ ret(kPointerSize); + } else { // UNTAGGED. + __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset)); + __ Ret(); + + // Skip cache and return answer directly, only in untagged case. + __ bind(&skip_cache); + __ subq(rsp, Immediate(kDoubleSize)); + __ movsd(Operand(rsp, 0), xmm1); + __ fld_d(Operand(rsp, 0)); + GenerateOperation(masm); + __ fstp_d(Operand(rsp, 0)); + __ movsd(xmm1, Operand(rsp, 0)); + __ addq(rsp, Immediate(kDoubleSize)); + // We return the value in xmm1 without adding it to the cache, but + // we cause a scavenging GC so that future allocations will succeed. + __ EnterInternalFrame(); + // Allocate an unused object bigger than a HeapNumber. + __ Push(Smi::FromInt(2 * kDoubleSize)); + __ CallRuntimeSaveDoubles(Runtime::kAllocateInNewSpace); + __ LeaveInternalFrame(); + __ Ret(); + } - __ bind(&nan_result); - __ fstp(0); // Remove argument from FPU stack. - __ LoadRoot(rax, Heap::kNanValueRootIndex); - __ movq(Operand(rcx, 0), rbx); - __ movq(Operand(rcx, 2 * kIntSize), rax); - __ ret(kPointerSize); + // Call runtime, doing whatever allocation and cleanup is necessary. + if (tagged) { + __ bind(&runtime_call_clear_stack); + __ fstp(0); + __ bind(&runtime_call); + __ TailCallExternalReference(ExternalReference(RuntimeFunction()), 1, 1); + } else { // UNTAGGED. + __ bind(&runtime_call_clear_stack); + __ bind(&runtime_call); + __ AllocateHeapNumber(rax, rdi, &skip_cache); + __ movsd(FieldOperand(rax, HeapNumber::kValueOffset), xmm1); + __ EnterInternalFrame(); + __ push(rax); + __ CallRuntime(RuntimeFunction(), 1); + __ LeaveInternalFrame(); + __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset)); + __ Ret(); + } } @@ -1637,9 +1696,9 @@ Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() { } -void TranscendentalCacheStub::GenerateOperation(MacroAssembler* masm, - Label* on_nan_result) { +void TranscendentalCacheStub::GenerateOperation(MacroAssembler* masm) { // Registers: + // rax: Newly allocated HeapNumber, which must be preserved. // rbx: Bits of input double. Must be preserved. // rcx: Pointer to cache entry. Must be preserved. // st(0): Input double @@ -1661,9 +1720,18 @@ void TranscendentalCacheStub::GenerateOperation(MacroAssembler* masm, __ j(below, &in_range); // Check for infinity and NaN. Both return NaN for sin. __ cmpl(rdi, Immediate(0x7ff)); - __ j(equal, on_nan_result); + NearLabel non_nan_result; + __ j(not_equal, &non_nan_result); + // Input is +/-Infinity or NaN. Result is NaN. + __ fstp(0); + __ LoadRoot(kScratchRegister, Heap::kNanValueRootIndex); + __ fld_d(FieldOperand(kScratchRegister, HeapNumber::kValueOffset)); + __ jmp(&done); + + __ bind(&non_nan_result); // Use fpmod to restrict argument to the range +/-2*PI. + __ movq(rdi, rax); // Save rax before using fnstsw_ax. __ fldpi(); __ fadd(0); __ fld(1); @@ -1696,6 +1764,7 @@ void TranscendentalCacheStub::GenerateOperation(MacroAssembler* masm, // FPU Stack: input % 2*pi, 2*pi, __ fstp(0); // FPU Stack: input % 2*pi + __ movq(rax, rdi); // Restore rax, pointer to the new HeapNumber. __ bind(&in_range); switch (type_) { case TranscendentalCache::SIN: @@ -1948,8 +2017,8 @@ void GenericUnaryOpStub::Generate(MacroAssembler* masm) { __ AbortIfSmi(rax); } - __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); - __ CompareRoot(rdx, Heap::kHeapNumberMapRootIndex); + __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), + Heap::kHeapNumberMapRootIndex); __ j(not_equal, &slow); // Operand is a float, negate its value by flipping sign bit. __ movq(rdx, FieldOperand(rax, HeapNumber::kValueOffset)); @@ -1978,8 +2047,8 @@ void GenericUnaryOpStub::Generate(MacroAssembler* masm) { } // Check if the operand is a heap number. - __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); - __ CompareRoot(rdx, Heap::kHeapNumberMapRootIndex); + __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), + Heap::kHeapNumberMapRootIndex); __ j(not_equal, &slow); // Convert the heap number in rax to an untagged integer in rcx. @@ -2012,6 +2081,157 @@ void GenericUnaryOpStub::Generate(MacroAssembler* masm) { } +void MathPowStub::Generate(MacroAssembler* masm) { + // Registers are used as follows: + // rdx = base + // rax = exponent + // rcx = temporary, result + + Label allocate_return, call_runtime; + + // Load input parameters. + __ movq(rdx, Operand(rsp, 2 * kPointerSize)); + __ movq(rax, Operand(rsp, 1 * kPointerSize)); + + // Save 1 in xmm3 - we need this several times later on. + __ movl(rcx, Immediate(1)); + __ cvtlsi2sd(xmm3, rcx); + + Label exponent_nonsmi; + Label base_nonsmi; + // If the exponent is a heap number go to that specific case. + __ JumpIfNotSmi(rax, &exponent_nonsmi); + __ JumpIfNotSmi(rdx, &base_nonsmi); + + // Optimized version when both exponent and base are smis. + Label powi; + __ SmiToInteger32(rdx, rdx); + __ cvtlsi2sd(xmm0, rdx); + __ jmp(&powi); + // Exponent is a smi and base is a heapnumber. + __ bind(&base_nonsmi); + __ CompareRoot(FieldOperand(rdx, HeapObject::kMapOffset), + Heap::kHeapNumberMapRootIndex); + __ j(not_equal, &call_runtime); + + __ movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); + + // Optimized version of pow if exponent is a smi. + // xmm0 contains the base. + __ bind(&powi); + __ SmiToInteger32(rax, rax); + + // Save exponent in base as we need to check if exponent is negative later. + // We know that base and exponent are in different registers. + __ movq(rdx, rax); + + // Get absolute value of exponent. + NearLabel no_neg; + __ cmpl(rax, Immediate(0)); + __ j(greater_equal, &no_neg); + __ negl(rax); + __ bind(&no_neg); + + // Load xmm1 with 1. + __ movsd(xmm1, xmm3); + NearLabel while_true; + NearLabel no_multiply; + + __ bind(&while_true); + __ shrl(rax, Immediate(1)); + __ j(not_carry, &no_multiply); + __ mulsd(xmm1, xmm0); + __ bind(&no_multiply); + __ mulsd(xmm0, xmm0); + __ j(not_zero, &while_true); + + // Base has the original value of the exponent - if the exponent is + // negative return 1/result. + __ testl(rdx, rdx); + __ j(positive, &allocate_return); + // Special case if xmm1 has reached infinity. + __ divsd(xmm3, xmm1); + __ movsd(xmm1, xmm3); + __ xorpd(xmm0, xmm0); + __ ucomisd(xmm0, xmm1); + __ j(equal, &call_runtime); + + __ jmp(&allocate_return); + + // Exponent (or both) is a heapnumber - no matter what we should now work + // on doubles. + __ bind(&exponent_nonsmi); + __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), + Heap::kHeapNumberMapRootIndex); + __ j(not_equal, &call_runtime); + __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset)); + // Test if exponent is nan. + __ ucomisd(xmm1, xmm1); + __ j(parity_even, &call_runtime); + + NearLabel base_not_smi; + NearLabel handle_special_cases; + __ JumpIfNotSmi(rdx, &base_not_smi); + __ SmiToInteger32(rdx, rdx); + __ cvtlsi2sd(xmm0, rdx); + __ jmp(&handle_special_cases); + + __ bind(&base_not_smi); + __ CompareRoot(FieldOperand(rdx, HeapObject::kMapOffset), + Heap::kHeapNumberMapRootIndex); + __ j(not_equal, &call_runtime); + __ movl(rcx, FieldOperand(rdx, HeapNumber::kExponentOffset)); + __ andl(rcx, Immediate(HeapNumber::kExponentMask)); + __ cmpl(rcx, Immediate(HeapNumber::kExponentMask)); + // base is NaN or +/-Infinity + __ j(greater_equal, &call_runtime); + __ movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); + + // base is in xmm0 and exponent is in xmm1. + __ bind(&handle_special_cases); + NearLabel not_minus_half; + // Test for -0.5. + // Load xmm2 with -0.5. + __ movq(rcx, V8_UINT64_C(0xBFE0000000000000), RelocInfo::NONE); + __ movq(xmm2, rcx); + // xmm2 now has -0.5. + __ ucomisd(xmm2, xmm1); + __ j(not_equal, ¬_minus_half); + + // Calculates reciprocal of square root. + // sqrtsd returns -0 when input is -0. ECMA spec requires +0. + __ xorpd(xmm1, xmm1); + __ addsd(xmm1, xmm0); + __ sqrtsd(xmm1, xmm1); + __ divsd(xmm3, xmm1); + __ movsd(xmm1, xmm3); + __ jmp(&allocate_return); + + // Test for 0.5. + __ bind(¬_minus_half); + // Load xmm2 with 0.5. + // Since xmm3 is 1 and xmm2 is -0.5 this is simply xmm2 + xmm3. + __ addsd(xmm2, xmm3); + // xmm2 now has 0.5. + __ ucomisd(xmm2, xmm1); + __ j(not_equal, &call_runtime); + // Calculates square root. + // sqrtsd returns -0 when input is -0. ECMA spec requires +0. + __ xorpd(xmm1, xmm1); + __ addsd(xmm1, xmm0); + __ sqrtsd(xmm1, xmm1); + + __ bind(&allocate_return); + __ AllocateHeapNumber(rcx, rax, &call_runtime); + __ movsd(FieldOperand(rcx, HeapNumber::kValueOffset), xmm1); + __ movq(rax, rcx); + __ ret(2 * kPointerSize); + + __ bind(&call_runtime); + __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); +} + + void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { // The key is in rdx and the parameter count is in rax. @@ -4613,6 +4833,61 @@ void StringCompareStub::Generate(MacroAssembler* masm) { __ TailCallRuntime(Runtime::kStringCompare, 2, 1); } + +void StringCharAtStub::Generate(MacroAssembler* masm) { + // Expects two arguments (object, index) on the stack: + + // Stack frame on entry. + // rsp[0]: return address + // rsp[8]: index + // rsp[16]: object + + Register object = rbx; + Register index = rax; + Register scratch1 = rcx; + Register scratch2 = rdx; + Register result = rax; + + __ pop(scratch1); // Return address. + __ pop(index); + __ pop(object); + __ push(scratch1); + + Label need_conversion; + Label index_out_of_range; + Label done; + StringCharAtGenerator generator(object, + index, + scratch1, + scratch2, + result, + &need_conversion, + &need_conversion, + &index_out_of_range, + STRING_INDEX_IS_NUMBER); + generator.GenerateFast(masm); + __ jmp(&done); + + __ bind(&index_out_of_range); + // When the index is out of range, the spec requires us to return + // the empty string. + __ Move(result, Factory::empty_string()); + __ jmp(&done); + + __ bind(&need_conversion); + // Move smi zero into the result register, which will trigger + // conversion. + __ Move(result, Smi::FromInt(0)); + __ jmp(&done); + + StubRuntimeCallHelper call_helper; + generator.GenerateSlow(masm, call_helper); + + __ bind(&done); + __ ret(0); +} + + void ICCompareStub::GenerateSmis(MacroAssembler* masm) { ASSERT(state_ == CompareIC::SMIS); NearLabel miss; diff --git a/deps/v8/src/x64/code-stubs-x64.h b/deps/v8/src/x64/code-stubs-x64.h index 1e6fc65140..32a37b215d 100644 --- a/deps/v8/src/x64/code-stubs-x64.h +++ b/deps/v8/src/x64/code-stubs-x64.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -39,15 +39,23 @@ namespace internal { // TranscendentalCache runtime function. class TranscendentalCacheStub: public CodeStub { public: - explicit TranscendentalCacheStub(TranscendentalCache::Type type) - : type_(type) {} + enum ArgumentType { + TAGGED = 0, + UNTAGGED = 1 << TranscendentalCache::kTranscendentalTypeBits + }; + + explicit TranscendentalCacheStub(TranscendentalCache::Type type, + ArgumentType argument_type) + : type_(type), argument_type_(argument_type) {} void Generate(MacroAssembler* masm); private: TranscendentalCache::Type type_; + ArgumentType argument_type_; + Major MajorKey() { return TranscendentalCache; } - int MinorKey() { return type_; } + int MinorKey() { return type_ | argument_type_; } Runtime::FunctionId RuntimeFunction(); - void GenerateOperation(MacroAssembler* masm, Label* on_nan_result); + void GenerateOperation(MacroAssembler* masm); }; diff --git a/deps/v8/src/x64/codegen-x64-inl.h b/deps/v8/src/x64/codegen-x64-inl.h index 60e9ab03ab..53caf91975 100644 --- a/deps/v8/src/x64/codegen-x64-inl.h +++ b/deps/v8/src/x64/codegen-x64-inl.h @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2010 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/codegen-x64.cc b/deps/v8/src/x64/codegen-x64.cc index c07bcf9044..ad114c2431 100644 --- a/deps/v8/src/x64/codegen-x64.cc +++ b/deps/v8/src/x64/codegen-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -2747,7 +2747,8 @@ void CodeGenerator::DeclareGlobals(Handle pairs) { frame_->EmitPush(rsi); // The context is the first argument. frame_->EmitPush(kScratchRegister); frame_->EmitPush(Smi::FromInt(is_eval() ? 1 : 0)); - Result ignored = frame_->CallRuntime(Runtime::kDeclareGlobals, 3); + frame_->EmitPush(Smi::FromInt(strict_mode_flag())); + Result ignored = frame_->CallRuntime(Runtime::kDeclareGlobals, 4); // Return value is ignored. } @@ -4605,7 +4606,8 @@ void CodeGenerator::StoreToSlot(Slot* slot, InitState init_state) { // by initialization. value = frame_->CallRuntime(Runtime::kInitializeConstContextSlot, 3); } else { - value = frame_->CallRuntime(Runtime::kStoreContextSlot, 3); + frame_->Push(Smi::FromInt(strict_mode_flag())); + value = frame_->CallRuntime(Runtime::kStoreContextSlot, 4); } // Storing a variable must keep the (new) value on the expression // stack. This is necessary for compiling chained assignment @@ -4914,8 +4916,9 @@ void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { Load(property->key()); Load(property->value()); if (property->emit_store()) { + frame_->Push(Smi::FromInt(NONE)); // PropertyAttributes // Ignore the result. - Result ignored = frame_->CallRuntime(Runtime::kSetProperty, 3); + Result ignored = frame_->CallRuntime(Runtime::kSetProperty, 4); } else { frame_->Drop(3); } @@ -7030,7 +7033,8 @@ void CodeGenerator::GenerateMathPow(ZoneList* args) { void CodeGenerator::GenerateMathSin(ZoneList* args) { ASSERT_EQ(args->length(), 1); Load(args->at(0)); - TranscendentalCacheStub stub(TranscendentalCache::SIN); + TranscendentalCacheStub stub(TranscendentalCache::SIN, + TranscendentalCacheStub::TAGGED); Result result = frame_->CallStub(&stub, 1); frame_->Push(&result); } @@ -7039,7 +7043,8 @@ void CodeGenerator::GenerateMathSin(ZoneList* args) { void CodeGenerator::GenerateMathCos(ZoneList* args) { ASSERT_EQ(args->length(), 1); Load(args->at(0)); - TranscendentalCacheStub stub(TranscendentalCache::COS); + TranscendentalCacheStub stub(TranscendentalCache::COS, + TranscendentalCacheStub::TAGGED); Result result = frame_->CallStub(&stub, 1); frame_->Push(&result); } @@ -7048,7 +7053,8 @@ void CodeGenerator::GenerateMathCos(ZoneList* args) { void CodeGenerator::GenerateMathLog(ZoneList* args) { ASSERT_EQ(args->length(), 1); Load(args->at(0)); - TranscendentalCacheStub stub(TranscendentalCache::LOG); + TranscendentalCacheStub stub(TranscendentalCache::LOG, + TranscendentalCacheStub::TAGGED); Result result = frame_->CallStub(&stub, 1); frame_->Push(&result); } @@ -8072,8 +8078,12 @@ class DeferredReferenceSetKeyedValue: public DeferredCode { public: DeferredReferenceSetKeyedValue(Register value, Register key, - Register receiver) - : value_(value), key_(key), receiver_(receiver) { + Register receiver, + StrictModeFlag strict_mode) + : value_(value), + key_(key), + receiver_(receiver), + strict_mode_(strict_mode) { set_comment("[ DeferredReferenceSetKeyedValue"); } @@ -8086,6 +8096,7 @@ class DeferredReferenceSetKeyedValue: public DeferredCode { Register key_; Register receiver_; Label patch_site_; + StrictModeFlag strict_mode_; }; @@ -8137,7 +8148,9 @@ void DeferredReferenceSetKeyedValue::Generate() { } // Call the IC stub. - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + (strict_mode_ == kStrictMode) ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); __ Call(ic, RelocInfo::CODE_TARGET); // The delta from the start of the map-compare instructions (initial movq) // to the test instruction. We use masm_-> directly here instead of the @@ -8478,7 +8491,8 @@ Result CodeGenerator::EmitKeyedStore(StaticType* key_type) { DeferredReferenceSetKeyedValue* deferred = new DeferredReferenceSetKeyedValue(result.reg(), key.reg(), - receiver.reg()); + receiver.reg(), + strict_mode_flag()); // Check that the receiver is not a smi. __ JumpIfSmi(receiver.reg(), deferred->entry_label()); @@ -8540,7 +8554,7 @@ Result CodeGenerator::EmitKeyedStore(StaticType* key_type) { deferred->BindExit(); } else { - result = frame()->CallKeyedStoreIC(); + result = frame()->CallKeyedStoreIC(strict_mode_flag()); // Make sure that we do not have a test instruction after the // call. A test instruction after the call is used to // indicate that we have generated an inline version of the diff --git a/deps/v8/src/x64/codegen-x64.h b/deps/v8/src/x64/codegen-x64.h index c283db3a07..4392829195 100644 --- a/deps/v8/src/x64/codegen-x64.h +++ b/deps/v8/src/x64/codegen-x64.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/cpu-x64.cc b/deps/v8/src/x64/cpu-x64.cc index 513c52286e..3ff292e82b 100644 --- a/deps/v8/src/x64/cpu-x64.cc +++ b/deps/v8/src/x64/cpu-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/debug-x64.cc b/deps/v8/src/x64/debug-x64.cc index 4218647f33..2c50ddd14e 100644 --- a/deps/v8/src/x64/debug-x64.cc +++ b/deps/v8/src/x64/debug-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/deoptimizer-x64.cc b/deps/v8/src/x64/deoptimizer-x64.cc index 595dedc474..6278142858 100644 --- a/deps/v8/src/x64/deoptimizer-x64.cc +++ b/deps/v8/src/x64/deoptimizer-x64.cc @@ -224,7 +224,7 @@ void Deoptimizer::PatchStackCheckCodeAt(Address pc_after, // ok: // ASSERT(*(call_target_address - 3) == 0x73 && // jae - *(call_target_address - 2) == 0x05 && // offset + *(call_target_address - 2) == 0x07 && // offset *(call_target_address - 1) == 0xe8); // call *(call_target_address - 3) = 0x90; // nop *(call_target_address - 2) = 0x90; // nop @@ -245,14 +245,154 @@ void Deoptimizer::RevertStackCheckCodeAt(Address pc_after, *(call_target_address - 2) == 0x90 && // nop *(call_target_address - 1) == 0xe8); // call *(call_target_address - 3) = 0x73; // jae - *(call_target_address - 2) = 0x05; // offset + *(call_target_address - 2) = 0x07; // offset Assembler::set_target_address_at(call_target_address, check_code->entry()); } +static int LookupBailoutId(DeoptimizationInputData* data, unsigned ast_id) { + ByteArray* translations = data->TranslationByteArray(); + int length = data->DeoptCount(); + for (int i = 0; i < length; i++) { + if (static_cast(data->AstId(i)->value()) == ast_id) { + TranslationIterator it(translations, data->TranslationIndex(i)->value()); + int value = it.Next(); + ASSERT(Translation::BEGIN == static_cast(value)); + // Read the number of frames. + value = it.Next(); + if (value == 1) return i; + } + } + UNREACHABLE(); + return -1; +} + + void Deoptimizer::DoComputeOsrOutputFrame() { - UNIMPLEMENTED(); + DeoptimizationInputData* data = DeoptimizationInputData::cast( + optimized_code_->deoptimization_data()); + unsigned ast_id = data->OsrAstId()->value(); + // TODO(kasperl): This should not be the bailout_id_. It should be + // the ast id. Confusing. + ASSERT(bailout_id_ == ast_id); + + int bailout_id = LookupBailoutId(data, ast_id); + unsigned translation_index = data->TranslationIndex(bailout_id)->value(); + ByteArray* translations = data->TranslationByteArray(); + + TranslationIterator iterator(translations, translation_index); + Translation::Opcode opcode = + static_cast(iterator.Next()); + ASSERT(Translation::BEGIN == opcode); + USE(opcode); + int count = iterator.Next(); + ASSERT(count == 1); + USE(count); + + opcode = static_cast(iterator.Next()); + USE(opcode); + ASSERT(Translation::FRAME == opcode); + unsigned node_id = iterator.Next(); + USE(node_id); + ASSERT(node_id == ast_id); + JSFunction* function = JSFunction::cast(ComputeLiteral(iterator.Next())); + USE(function); + ASSERT(function == function_); + unsigned height = iterator.Next(); + unsigned height_in_bytes = height * kPointerSize; + USE(height_in_bytes); + + unsigned fixed_size = ComputeFixedSize(function_); + unsigned input_frame_size = static_cast(input_->GetFrameSize()); + ASSERT(fixed_size + height_in_bytes == input_frame_size); + + unsigned stack_slot_size = optimized_code_->stack_slots() * kPointerSize; + unsigned outgoing_height = data->ArgumentsStackHeight(bailout_id)->value(); + unsigned outgoing_size = outgoing_height * kPointerSize; + unsigned output_frame_size = fixed_size + stack_slot_size + outgoing_size; + ASSERT(outgoing_size == 0); // OSR does not happen in the middle of a call. + + if (FLAG_trace_osr) { + PrintF("[on-stack replacement: begin 0x%08" V8PRIxPTR " ", + reinterpret_cast(function_)); + function_->PrintName(); + PrintF(" => node=%u, frame=%d->%d]\n", + ast_id, + input_frame_size, + output_frame_size); + } + + // There's only one output frame in the OSR case. + output_count_ = 1; + output_ = new FrameDescription*[1]; + output_[0] = new(output_frame_size) FrameDescription( + output_frame_size, function_); + + // Clear the incoming parameters in the optimized frame to avoid + // confusing the garbage collector. + unsigned output_offset = output_frame_size - kPointerSize; + int parameter_count = function_->shared()->formal_parameter_count() + 1; + for (int i = 0; i < parameter_count; ++i) { + output_[0]->SetFrameSlot(output_offset, 0); + output_offset -= kPointerSize; + } + + // Translate the incoming parameters. This may overwrite some of the + // incoming argument slots we've just cleared. + int input_offset = input_frame_size - kPointerSize; + bool ok = true; + int limit = input_offset - (parameter_count * kPointerSize); + while (ok && input_offset > limit) { + ok = DoOsrTranslateCommand(&iterator, &input_offset); + } + + // There are no translation commands for the caller's pc and fp, the + // context, and the function. Set them up explicitly. + for (int i = 0; ok && i < 4; i++) { + intptr_t input_value = input_->GetFrameSlot(input_offset); + if (FLAG_trace_osr) { + PrintF(" [esp + %d] <- 0x%08" V8PRIxPTR " ; [esp + %d] (fixed part)\n", + output_offset, + input_value, + input_offset); + } + output_[0]->SetFrameSlot(output_offset, input_->GetFrameSlot(input_offset)); + input_offset -= kPointerSize; + output_offset -= kPointerSize; + } + + // Translate the rest of the frame. + while (ok && input_offset >= 0) { + ok = DoOsrTranslateCommand(&iterator, &input_offset); + } + + // If translation of any command failed, continue using the input frame. + if (!ok) { + delete output_[0]; + output_[0] = input_; + output_[0]->SetPc(reinterpret_cast(from_)); + } else { + // Setup the frame pointer and the context pointer. + output_[0]->SetRegister(rbp.code(), input_->GetRegister(rbp.code())); + output_[0]->SetRegister(rsi.code(), input_->GetRegister(rsi.code())); + + unsigned pc_offset = data->OsrPcOffset()->value(); + intptr_t pc = reinterpret_cast( + optimized_code_->entry() + pc_offset); + output_[0]->SetPc(pc); + } + Code* continuation = Builtins::builtin(Builtins::NotifyOSR); + output_[0]->SetContinuation( + reinterpret_cast(continuation->entry())); + + if (FLAG_trace_osr) { + PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", + ok ? "finished" : "aborted", + reinterpret_cast(function)); + function->PrintName(); + PrintF(" => pc=0x%0" V8PRIxPTR "]\n", output_[0]->GetPc()); + } } diff --git a/deps/v8/src/x64/disasm-x64.cc b/deps/v8/src/x64/disasm-x64.cc index f73f94845a..21a100f59a 100644 --- a/deps/v8/src/x64/disasm-x64.cc +++ b/deps/v8/src/x64/disasm-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -1040,14 +1040,18 @@ int DisassemblerX64::TwoByteOpcodeInstruction(byte* data) { AppendToBuffer(", %s", NameOfXMMRegister(regop)); } else { const char* mnemonic = "?"; - if (opcode == 0x57) { + if (opcode == 0x50) { + mnemonic = "movmskpd"; + } else if (opcode == 0x54) { + mnemonic = "andpd"; + } else if (opcode == 0x56) { + mnemonic = "orpd"; + } else if (opcode == 0x57) { mnemonic = "xorpd"; } else if (opcode == 0x2E) { mnemonic = "ucomisd"; } else if (opcode == 0x2F) { mnemonic = "comisd"; - } else if (opcode == 0x50) { - mnemonic = "movmskpd"; } else { UnimplementedInstruction(); } diff --git a/deps/v8/src/x64/frames-x64.cc b/deps/v8/src/x64/frames-x64.cc index 9c960478aa..6c58bc9e0c 100644 --- a/deps/v8/src/x64/frames-x64.cc +++ b/deps/v8/src/x64/frames-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2010 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/frames-x64.h b/deps/v8/src/x64/frames-x64.h index 998b3e9fc9..81be819196 100644 --- a/deps/v8/src/x64/frames-x64.h +++ b/deps/v8/src/x64/frames-x64.h @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2010 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/full-codegen-x64.cc b/deps/v8/src/x64/full-codegen-x64.cc index 8711f42384..0ad6ec2376 100644 --- a/deps/v8/src/x64/full-codegen-x64.cc +++ b/deps/v8/src/x64/full-codegen-x64.cc @@ -207,43 +207,45 @@ void FullCodeGenerator::Generate(CompilationInfo* info) { Move(dot_arguments_slot, rcx, rbx, rdx); } - { Comment cmnt(masm_, "[ Declarations"); - // For named function expressions, declare the function name as a - // constant. - if (scope()->is_function_scope() && scope()->function() != NULL) { - EmitDeclaration(scope()->function(), Variable::CONST, NULL); - } - // Visit all the explicit declarations unless there is an illegal - // redeclaration. - if (scope()->HasIllegalRedeclaration()) { - scope()->VisitIllegalRedeclaration(this); - } else { - VisitDeclarations(scope()->declarations()); - } - } - if (FLAG_trace) { __ CallRuntime(Runtime::kTraceEnter, 0); } - { Comment cmnt(masm_, "[ Stack check"); - PrepareForBailout(info->function(), NO_REGISTERS); - NearLabel ok; - __ CompareRoot(rsp, Heap::kStackLimitRootIndex); - __ j(above_equal, &ok); - StackCheckStub stub; - __ CallStub(&stub); - __ bind(&ok); - } + // Visit the declarations and body unless there is an illegal + // redeclaration. + if (scope()->HasIllegalRedeclaration()) { + Comment cmnt(masm_, "[ Declarations"); + scope()->VisitIllegalRedeclaration(this); + } else { + { Comment cmnt(masm_, "[ Declarations"); + // For named function expressions, declare the function name as a + // constant. + if (scope()->is_function_scope() && scope()->function() != NULL) { + EmitDeclaration(scope()->function(), Variable::CONST, NULL); + } + VisitDeclarations(scope()->declarations()); + } - { Comment cmnt(masm_, "[ Body"); - ASSERT(loop_depth() == 0); - VisitStatements(function()->body()); - ASSERT(loop_depth() == 0); + { Comment cmnt(masm_, "[ Stack check"); + PrepareForBailout(info->function(), NO_REGISTERS); + NearLabel ok; + __ CompareRoot(rsp, Heap::kStackLimitRootIndex); + __ j(above_equal, &ok); + StackCheckStub stub; + __ CallStub(&stub); + __ bind(&ok); + } + + { Comment cmnt(masm_, "[ Body"); + ASSERT(loop_depth() == 0); + VisitStatements(function()->body()); + ASSERT(loop_depth() == 0); + } } + // Always emit a 'return undefined' in case control fell off the end of + // the body. { Comment cmnt(masm_, "[ return ;"); - // Emit a 'return undefined' in case control fell off the end of the body. __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); EmitReturnSequence(); } @@ -267,6 +269,13 @@ void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt) { // the deoptimization input data found in the optimized code. RecordStackCheck(stmt->OsrEntryId()); + // Loop stack checks can be patched to perform on-stack replacement. In + // order to decide whether or not to perform OSR we embed the loop depth + // in a test instruction after the call so we can extract it from the OSR + // builtin. + ASSERT(loop_depth() > 0); + __ testl(rax, Immediate(Min(loop_depth(), Code::kMaxLoopNestingMarker))); + __ bind(&ok); PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); // Record a mapping of the OSR id to this PC. This is used if the OSR @@ -318,13 +327,6 @@ void FullCodeGenerator::EmitReturnSequence() { } -FullCodeGenerator::ConstantOperand FullCodeGenerator::GetConstantOperand( - Token::Value op, Expression* left, Expression* right) { - ASSERT(ShouldInlineSmiCase(op)); - return kNoConstants; -} - - void FullCodeGenerator::EffectContext::Plug(Slot* slot) const { } @@ -543,7 +545,7 @@ void FullCodeGenerator::DoTest(Label* if_true, __ j(equal, if_true); __ CompareRoot(result_register(), Heap::kFalseValueRootIndex); __ j(equal, if_false); - ASSERT_EQ(0, kSmiTag); + STATIC_ASSERT(kSmiTag == 0); __ SmiCompare(result_register(), Smi::FromInt(0)); __ j(equal, if_false); Condition is_smi = masm_->CheckSmi(result_register()); @@ -733,7 +735,9 @@ void FullCodeGenerator::EmitDeclaration(Variable* variable, prop->key()->AsLiteral()->handle()->IsSmi()); __ Move(rcx, prop->key()->AsLiteral()->handle()); - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin(is_strict() + ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); } } @@ -750,7 +754,8 @@ void FullCodeGenerator::DeclareGlobals(Handle pairs) { __ push(rsi); // The context is the first argument. __ Push(pairs); __ Push(Smi::FromInt(is_eval() ? 1 : 0)); - __ CallRuntime(Runtime::kDeclareGlobals, 3); + __ Push(Smi::FromInt(strict_mode_flag())); + __ CallRuntime(Runtime::kDeclareGlobals, 4); // Return value is ignored. } @@ -851,7 +856,9 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { VisitForAccumulatorValue(stmt->enumerable()); __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); __ j(equal, &exit); - __ CompareRoot(rax, Heap::kNullValueRootIndex); + Register null_value = rdi; + __ LoadRoot(null_value, Heap::kNullValueRootIndex); + __ cmpq(rax, null_value); __ j(equal, &exit); // Convert the object to a JS object. @@ -865,12 +872,61 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { __ bind(&done_convert); __ push(rax); - // BUG(867): Check cache validity in generated code. This is a fast - // case for the JSObject::IsSimpleEnum cache validity checks. If we - // cannot guarantee cache validity, call the runtime system to check - // cache validity or get the property names in a fixed array. + // Check cache validity in generated code. This is a fast case for + // the JSObject::IsSimpleEnum cache validity checks. If we cannot + // guarantee cache validity, call the runtime system to check cache + // validity or get the property names in a fixed array. + Label next, call_runtime; + Register empty_fixed_array_value = r8; + __ LoadRoot(empty_fixed_array_value, Heap::kEmptyFixedArrayRootIndex); + Register empty_descriptor_array_value = r9; + __ LoadRoot(empty_descriptor_array_value, + Heap::kEmptyDescriptorArrayRootIndex); + __ movq(rcx, rax); + __ bind(&next); + + // Check that there are no elements. Register rcx contains the + // current JS object we've reached through the prototype chain. + __ cmpq(empty_fixed_array_value, + FieldOperand(rcx, JSObject::kElementsOffset)); + __ j(not_equal, &call_runtime); + + // Check that instance descriptors are not empty so that we can + // check for an enum cache. Leave the map in rbx for the subsequent + // prototype load. + __ movq(rbx, FieldOperand(rcx, HeapObject::kMapOffset)); + __ movq(rdx, FieldOperand(rbx, Map::kInstanceDescriptorsOffset)); + __ cmpq(rdx, empty_descriptor_array_value); + __ j(equal, &call_runtime); + + // Check that there is an enum cache in the non-empty instance + // descriptors (rdx). This is the case if the next enumeration + // index field does not contain a smi. + __ movq(rdx, FieldOperand(rdx, DescriptorArray::kEnumerationIndexOffset)); + __ JumpIfSmi(rdx, &call_runtime); + + // For all objects but the receiver, check that the cache is empty. + NearLabel check_prototype; + __ cmpq(rcx, rax); + __ j(equal, &check_prototype); + __ movq(rdx, FieldOperand(rdx, DescriptorArray::kEnumCacheBridgeCacheOffset)); + __ cmpq(rdx, empty_fixed_array_value); + __ j(not_equal, &call_runtime); + + // Load the prototype from the map and loop if non-null. + __ bind(&check_prototype); + __ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); + __ cmpq(rcx, null_value); + __ j(not_equal, &next); + + // The enum cache is valid. Load the map of the object being + // iterated over and use the cache for the iteration. + NearLabel use_cache; + __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset)); + __ jmp(&use_cache); // Get the set of properties to enumerate. + __ bind(&call_runtime); __ push(rax); // Duplicate the enumerable object on the stack. __ CallRuntime(Runtime::kGetPropertyNamesFast, 1); @@ -883,6 +939,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { __ j(not_equal, &fixed_array); // We got a map in register rax. Get the enumeration cache from it. + __ bind(&use_cache); __ movq(rcx, FieldOperand(rax, Map::kInstanceDescriptorsOffset)); __ movq(rcx, FieldOperand(rcx, DescriptorArray::kEnumerationIndexOffset)); __ movq(rdx, FieldOperand(rcx, DescriptorArray::kEnumCacheBridgeCacheOffset)); @@ -971,8 +1028,14 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { void FullCodeGenerator::EmitNewClosure(Handle info, bool pretenure) { // Use the fast case closure allocation code that allocates in new - // space for nested functions that don't need literals cloning. - if (scope()->is_function_scope() && + // space for nested functions that don't need literals cloning. If + // we're running with the --always-opt or the --prepare-always-opt + // flag, we need to use the runtime function so that the new function + // we are creating here gets a chance to have its code optimized and + // doesn't just get a copy of the existing unoptimized code. + if (!FLAG_always_opt && + !FLAG_prepare_always_opt && + scope()->is_function_scope() && info->num_literals() == 0 && !pretenure) { FastNewClosureStub stub; @@ -1082,8 +1145,11 @@ MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions( // Check that last extension is NULL. __ cmpq(ContextOperand(context, Context::EXTENSION_INDEX), Immediate(0)); __ j(not_equal, slow); - __ movq(temp, ContextOperand(context, Context::FCONTEXT_INDEX)); - return ContextOperand(temp, slot->index()); + + // This function is used only for loads, not stores, so it's safe to + // return an rsi-based operand (the write barrier cannot be allowed to + // destroy the rsi register). + return ContextOperand(context, slot->index()); } @@ -1333,7 +1399,8 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(key); VisitForStackValue(value); if (property->emit_store()) { - __ CallRuntime(Runtime::kSetProperty, 3); + __ Push(Smi::FromInt(NONE)); // PropertyAttributes + __ CallRuntime(Runtime::kSetProperty, 4); } else { __ Drop(3); } @@ -1509,14 +1576,8 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { } Token::Value op = expr->binary_op(); - ConstantOperand constant = ShouldInlineSmiCase(op) - ? GetConstantOperand(op, expr->target(), expr->value()) - : kNoConstants; - ASSERT(constant == kRightConstant || constant == kNoConstants); - if (constant == kNoConstants) { - __ push(rax); // Left operand goes on the stack. - VisitForAccumulatorValue(expr->value()); - } + __ push(rax); // Left operand goes on the stack. + VisitForAccumulatorValue(expr->value()); OverwriteMode mode = expr->value()->ResultOverwriteAllowed() ? OVERWRITE_RIGHT @@ -1528,8 +1589,7 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { op, mode, expr->target(), - expr->value(), - constant); + expr->value()); } else { EmitBinaryOp(op, mode); } @@ -1580,10 +1640,7 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(Expression* expr, Token::Value op, OverwriteMode mode, Expression* left, - Expression* right, - ConstantOperand constant) { - ASSERT(constant == kNoConstants); // Only handled case. - + Expression* right) { // Do combined smi check of the operands. Left operand is on the // stack (popped into rdx). Right operand is in rax but moved into // rcx to make the shifts easier. @@ -1680,7 +1737,9 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) { __ movq(rdx, rax); __ pop(rax); // Restore value. __ Move(rcx, prop->key()->AsLiteral()->handle()); - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); break; } @@ -1701,7 +1760,9 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) { __ pop(rdx); } __ pop(rax); // Restore value. - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); break; } @@ -1730,57 +1791,76 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); - } else if (var->mode() != Variable::CONST || op == Token::INIT_CONST) { - // Perform the assignment for non-const variables and for initialization - // of const variables. Const assignments are simply skipped. - Label done; + } else if (op == Token::INIT_CONST) { + // Like var declarations, const declarations are hoisted to function + // scope. However, unlike var initializers, const initializers are able + // to drill a hole to that function context, even from inside a 'with' + // context. We thus bypass the normal static scope lookup. + Slot* slot = var->AsSlot(); + Label skip; + switch (slot->type()) { + case Slot::PARAMETER: + // No const parameters. + UNREACHABLE(); + break; + case Slot::LOCAL: + __ movq(rdx, Operand(rbp, SlotOffset(slot))); + __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); + __ j(not_equal, &skip); + __ movq(Operand(rbp, SlotOffset(slot)), rax); + break; + case Slot::CONTEXT: { + __ movq(rcx, ContextOperand(rsi, Context::FCONTEXT_INDEX)); + __ movq(rdx, ContextOperand(rcx, slot->index())); + __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); + __ j(not_equal, &skip); + __ movq(ContextOperand(rcx, slot->index()), rax); + int offset = Context::SlotOffset(slot->index()); + __ movq(rdx, rax); // Preserve the stored value in eax. + __ RecordWrite(rcx, offset, rdx, rbx); + break; + } + case Slot::LOOKUP: + __ push(rax); + __ push(rsi); + __ Push(var->name()); + __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); + break; + } + __ bind(&skip); + + } else if (var->mode() != Variable::CONST) { + // Perform the assignment for non-const variables. Const assignments + // are simply skipped. Slot* slot = var->AsSlot(); switch (slot->type()) { case Slot::PARAMETER: case Slot::LOCAL: - if (op == Token::INIT_CONST) { - // Detect const reinitialization by checking for the hole value. - __ movq(rdx, Operand(rbp, SlotOffset(slot))); - __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); - __ j(not_equal, &done); - } // Perform the assignment. __ movq(Operand(rbp, SlotOffset(slot)), rax); break; case Slot::CONTEXT: { MemOperand target = EmitSlotSearch(slot, rcx); - if (op == Token::INIT_CONST) { - // Detect const reinitialization by checking for the hole value. - __ movq(rdx, target); - __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); - __ j(not_equal, &done); - } // Perform the assignment and issue the write barrier. __ movq(target, rax); // The value of the assignment is in rax. RecordWrite clobbers its // register arguments. __ movq(rdx, rax); - int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize; + int offset = Context::SlotOffset(slot->index()); __ RecordWrite(rcx, offset, rdx, rbx); break; } case Slot::LOOKUP: - // Call the runtime for the assignment. The runtime will ignore - // const reinitialization. + // Call the runtime for the assignment. __ push(rax); // Value. __ push(rsi); // Context. __ Push(var->name()); - if (op == Token::INIT_CONST) { - // The runtime will ignore const redeclaration. - __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); - } else { - __ CallRuntime(Runtime::kStoreContextSlot, 3); - } + __ Push(Smi::FromInt(strict_mode_flag())); + __ CallRuntime(Runtime::kStoreContextSlot, 4); break; } - __ bind(&done); } } @@ -1809,7 +1889,9 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { } else { __ pop(rdx); } - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); // If the assignment ends an initialization block, revert to fast case. @@ -1847,7 +1929,9 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { } // Record source code position before IC call. SetSourcePosition(expr->position()); - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); // If the assignment ends an initialization block, revert to fast case. @@ -1963,6 +2047,27 @@ void FullCodeGenerator::EmitCallWithStub(Call* expr) { } +void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, + int arg_count) { + // Push copy of the first argument or undefined if it doesn't exist. + if (arg_count > 0) { + __ push(Operand(rsp, arg_count * kPointerSize)); + } else { + __ PushRoot(Heap::kUndefinedValueRootIndex); + } + + // Push the receiver of the enclosing function and do runtime call. + __ push(Operand(rbp, (2 + scope()->num_parameters()) * kPointerSize)); + + // Push the strict mode flag. + __ Push(Smi::FromInt(strict_mode_flag())); + + __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP + ? Runtime::kResolvePossiblyDirectEvalNoLookup + : Runtime::kResolvePossiblyDirectEval, 4); +} + + void FullCodeGenerator::VisitCall(Call* expr) { #ifdef DEBUG // We want to verify that RecordJSReturnSite gets called on all paths @@ -1990,21 +2095,30 @@ void FullCodeGenerator::VisitCall(Call* expr) { VisitForStackValue(args->at(i)); } - // Push copy of the function - found below the arguments. - __ push(Operand(rsp, (arg_count + 1) * kPointerSize)); - - // Push copy of the first argument or undefined if it doesn't exist. - if (arg_count > 0) { - __ push(Operand(rsp, arg_count * kPointerSize)); - } else { - __ PushRoot(Heap::kUndefinedValueRootIndex); + // If we know that eval can only be shadowed by eval-introduced + // variables we attempt to load the global eval function directly + // in generated code. If we succeed, there is no need to perform a + // context lookup in the runtime system. + Label done; + if (var->AsSlot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) { + Label slow; + EmitLoadGlobalSlotCheckExtensions(var->AsSlot(), + NOT_INSIDE_TYPEOF, + &slow); + // Push the function and resolve eval. + __ push(rax); + EmitResolvePossiblyDirectEval(SKIP_CONTEXT_LOOKUP, arg_count); + __ jmp(&done); + __ bind(&slow); } - // Push the receiver of the enclosing function and do runtime call. - __ push(Operand(rbp, (2 + scope()->num_parameters()) * kPointerSize)); - // Push the strict mode flag. - __ Push(Smi::FromInt(strict_mode_flag())); - __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4); + // Push copy of the function (found below the arguments) and + // resolve eval. + __ push(Operand(rsp, (arg_count + 1) * kPointerSize)); + EmitResolvePossiblyDirectEval(PERFORM_CONTEXT_LOOKUP, arg_count); + if (done.is_linked()) { + __ bind(&done); + } // The runtime call returns a pair of values in rax (function) and // rdx (receiver). Touch up the stack with the right values. @@ -2621,7 +2735,8 @@ void FullCodeGenerator::EmitMathPow(ZoneList* args) { ASSERT(args->length() == 2); VisitForStackValue(args->at(0)); VisitForStackValue(args->at(1)); - __ CallRuntime(Runtime::kMath_pow, 2); + MathPowStub stub; + __ CallStub(&stub); context()->Plug(rax); } @@ -2805,7 +2920,8 @@ void FullCodeGenerator::EmitStringCompare(ZoneList* args) { void FullCodeGenerator::EmitMathSin(ZoneList* args) { // Load the argument on the stack and call the stub. - TranscendentalCacheStub stub(TranscendentalCache::SIN); + TranscendentalCacheStub stub(TranscendentalCache::SIN, + TranscendentalCacheStub::TAGGED); ASSERT(args->length() == 1); VisitForStackValue(args->at(0)); __ CallStub(&stub); @@ -2815,7 +2931,8 @@ void FullCodeGenerator::EmitMathSin(ZoneList* args) { void FullCodeGenerator::EmitMathCos(ZoneList* args) { // Load the argument on the stack and call the stub. - TranscendentalCacheStub stub(TranscendentalCache::COS); + TranscendentalCacheStub stub(TranscendentalCache::COS, + TranscendentalCacheStub::TAGGED); ASSERT(args->length() == 1); VisitForStackValue(args->at(0)); __ CallStub(&stub); @@ -2825,7 +2942,8 @@ void FullCodeGenerator::EmitMathCos(ZoneList* args) { void FullCodeGenerator::EmitMathLog(ZoneList* args) { // Load the argument on the stack and call the stub. - TranscendentalCacheStub stub(TranscendentalCache::LOG); + TranscendentalCacheStub stub(TranscendentalCache::LOG, + TranscendentalCacheStub::TAGGED); ASSERT(args->length() == 1); VisitForStackValue(args->at(0)); __ CallStub(&stub); @@ -2877,7 +2995,73 @@ void FullCodeGenerator::EmitSwapElements(ZoneList* args) { VisitForStackValue(args->at(0)); VisitForStackValue(args->at(1)); VisitForStackValue(args->at(2)); + Label done; + Label slow_case; + Register object = rax; + Register index_1 = rbx; + Register index_2 = rcx; + Register elements = rdi; + Register temp = rdx; + __ movq(object, Operand(rsp, 2 * kPointerSize)); + // Fetch the map and check if array is in fast case. + // Check that object doesn't require security checks and + // has no indexed interceptor. + __ CmpObjectType(object, FIRST_JS_OBJECT_TYPE, temp); + __ j(below, &slow_case); + __ testb(FieldOperand(temp, Map::kBitFieldOffset), + Immediate(KeyedLoadIC::kSlowCaseBitFieldMask)); + __ j(not_zero, &slow_case); + + // Check the object's elements are in fast case and writable. + __ movq(elements, FieldOperand(object, JSObject::kElementsOffset)); + __ CompareRoot(FieldOperand(elements, HeapObject::kMapOffset), + Heap::kFixedArrayMapRootIndex); + __ j(not_equal, &slow_case); + + // Check that both indices are smis. + __ movq(index_1, Operand(rsp, 1 * kPointerSize)); + __ movq(index_2, Operand(rsp, 0 * kPointerSize)); + __ JumpIfNotBothSmi(index_1, index_2, &slow_case); + + // Check that both indices are valid. + // The JSArray length field is a smi since the array is in fast case mode. + __ movq(temp, FieldOperand(object, JSArray::kLengthOffset)); + __ SmiCompare(temp, index_1); + __ j(below_equal, &slow_case); + __ SmiCompare(temp, index_2); + __ j(below_equal, &slow_case); + + __ SmiToInteger32(index_1, index_1); + __ SmiToInteger32(index_2, index_2); + // Bring addresses into index1 and index2. + __ lea(index_1, FieldOperand(elements, index_1, times_pointer_size, + FixedArray::kHeaderSize)); + __ lea(index_2, FieldOperand(elements, index_2, times_pointer_size, + FixedArray::kHeaderSize)); + + // Swap elements. Use object and temp as scratch registers. + __ movq(object, Operand(index_1, 0)); + __ movq(temp, Operand(index_2, 0)); + __ movq(Operand(index_2, 0), object); + __ movq(Operand(index_1, 0), temp); + + Label new_space; + __ InNewSpace(elements, temp, equal, &new_space); + + __ movq(object, elements); + __ RecordWriteHelper(object, index_1, temp); + __ RecordWriteHelper(elements, index_2, temp); + + __ bind(&new_space); + // We are done. Drop elements from the stack, and return undefined. + __ addq(rsp, Immediate(3 * kPointerSize)); + __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); + __ jmp(&done); + + __ bind(&slow_case); __ CallRuntime(Runtime::kSwapElements, 3); + + __ bind(&done); context()->Plug(rax); } @@ -3000,9 +3184,12 @@ void FullCodeGenerator::EmitHasCachedArrayIndex(ZoneList* args) { void FullCodeGenerator::EmitGetCachedArrayIndex(ZoneList* args) { ASSERT(args->length() == 1); - VisitForAccumulatorValue(args->at(0)); + if (FLAG_debug_code) { + __ AbortIfNotString(rax); + } + __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); ASSERT(String::kHashShift >= kSmiTagSize); __ IndexFromHash(rax, rax); @@ -3355,7 +3542,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case NAMED_PROPERTY: { __ Move(rcx, prop->key()->AsLiteral()->handle()); __ pop(rdx); - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); if (expr->is_postfix()) { @@ -3370,7 +3559,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case KEYED_PROPERTY: { __ pop(rcx); __ pop(rdx); - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); EmitCallIC(ic, RelocInfo::CODE_TARGET); PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); if (expr->is_postfix()) { @@ -3715,6 +3906,22 @@ void FullCodeGenerator::EmitCallIC(Handle ic, RelocInfo::Mode mode) { void FullCodeGenerator::EmitCallIC(Handle ic, JumpPatchSite* patch_site) { + switch (ic->kind()) { + case Code::LOAD_IC: + __ IncrementCounter(&Counters::named_load_full, 1); + break; + case Code::KEYED_LOAD_IC: + __ IncrementCounter(&Counters::keyed_load_full, 1); + break; + case Code::STORE_IC: + __ IncrementCounter(&Counters::named_store_full, 1); + break; + case Code::KEYED_STORE_IC: + __ IncrementCounter(&Counters::keyed_store_full, 1); + default: + break; + } + __ call(ic, RelocInfo::CODE_TARGET); if (patch_site != NULL && patch_site->is_bound()) { patch_site->EmitPatchInfo(); diff --git a/deps/v8/src/x64/ic-x64.cc b/deps/v8/src/x64/ic-x64.cc index f8c40ab4e1..b3243cf48a 100644 --- a/deps/v8/src/x64/ic-x64.cc +++ b/deps/v8/src/x64/ic-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -766,7 +766,8 @@ void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) { } -void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { +void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, + StrictModeFlag strict_mode) { // ----------- S t a t e ------------- // -- rax : value // -- rcx : key @@ -813,7 +814,7 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { __ bind(&slow); __ Integer32ToSmi(rcx, rcx); __ bind(&slow_with_tagged_index); - GenerateRuntimeSetProperty(masm); + GenerateRuntimeSetProperty(masm, strict_mode); // Never returns to here. // Check whether the elements is a pixel array. @@ -1474,7 +1475,7 @@ void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { void StoreIC::GenerateMegamorphic(MacroAssembler* masm, - Code::ExtraICState extra_ic_state) { + StrictModeFlag strict_mode) { // ----------- S t a t e ------------- // -- rax : value // -- rcx : name @@ -1486,7 +1487,7 @@ void StoreIC::GenerateMegamorphic(MacroAssembler* masm, Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, NOT_IN_LOOP, MONOMORPHIC, - extra_ic_state); + strict_mode); StubCache::GenerateProbe(masm, flags, rdx, rcx, rbx, no_reg); // Cache miss: Jump to runtime. @@ -1593,7 +1594,8 @@ void StoreIC::GenerateNormal(MacroAssembler* masm) { } -void StoreIC::GenerateGlobalProxy(MacroAssembler* masm) { +void StoreIC::GenerateGlobalProxy(MacroAssembler* masm, + StrictModeFlag strict_mode) { // ----------- S t a t e ------------- // -- rax : value // -- rcx : name @@ -1604,14 +1606,17 @@ void StoreIC::GenerateGlobalProxy(MacroAssembler* masm) { __ push(rdx); __ push(rcx); __ push(rax); - __ push(rbx); + __ Push(Smi::FromInt(NONE)); // PropertyAttributes + __ Push(Smi::FromInt(strict_mode)); + __ push(rbx); // return address // Do tail-call to runtime routine. - __ TailCallRuntime(Runtime::kSetProperty, 3, 1); + __ TailCallRuntime(Runtime::kSetProperty, 5, 1); } -void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm) { +void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, + StrictModeFlag strict_mode) { // ----------- S t a t e ------------- // -- rax : value // -- rcx : key @@ -1623,10 +1628,12 @@ void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm) { __ push(rdx); // receiver __ push(rcx); // key __ push(rax); // value + __ Push(Smi::FromInt(NONE)); // PropertyAttributes + __ Push(Smi::FromInt(strict_mode)); // Strict mode. __ push(rbx); // return address // Do tail-call to runtime routine. - __ TailCallRuntime(Runtime::kSetProperty, 3, 1); + __ TailCallRuntime(Runtime::kSetProperty, 5, 1); } diff --git a/deps/v8/src/x64/jump-target-x64.cc b/deps/v8/src/x64/jump-target-x64.cc index 1208b0dbea..e715604632 100644 --- a/deps/v8/src/x64/jump-target-x64.cc +++ b/deps/v8/src/x64/jump-target-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2010 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/lithium-codegen-x64.cc b/deps/v8/src/x64/lithium-codegen-x64.cc index e6904b4dad..0ae8a003c9 100644 --- a/deps/v8/src/x64/lithium-codegen-x64.cc +++ b/deps/v8/src/x64/lithium-codegen-x64.cc @@ -77,6 +77,7 @@ bool LCodeGen::GenerateCode() { return GeneratePrologue() && GenerateBody() && GenerateDeferredCode() && + GenerateJumpTable() && GenerateSafepointTable(); } @@ -240,6 +241,16 @@ LInstruction* LCodeGen::GetNextInstruction() { } +bool LCodeGen::GenerateJumpTable() { + for (int i = 0; i < jump_table_.length(); i++) { + JumpTableEntry* info = jump_table_[i]; + __ bind(&(info->label_)); + __ Jump(info->address_, RelocInfo::RUNTIME_ENTRY); + } + return !is_aborted(); +} + + bool LCodeGen::GenerateDeferredCode() { ASSERT(is_generating()); for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { @@ -512,10 +523,17 @@ void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) { if (cc == no_condition) { __ Jump(entry, RelocInfo::RUNTIME_ENTRY); } else { - NearLabel done; - __ j(NegateCondition(cc), &done); - __ Jump(entry, RelocInfo::RUNTIME_ENTRY); - __ bind(&done); + JumpTableEntry* jump_info = NULL; + // We often have several deopts to the same entry, reuse the last + // jump entry if this is the case. + if (jump_table_.length() > 0 && + jump_table_[jump_table_.length() - 1]->address_ == entry) { + jump_info = jump_table_[jump_table_.length() - 1]; + } else { + jump_info = new JumpTableEntry(entry); + jump_table_.Add(jump_info); + } + __ j(cc, &jump_info->label_); } } @@ -527,7 +545,8 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { Handle data = Factory::NewDeoptimizationInputData(length, TENURED); - data->SetTranslationByteArray(*translations_.CreateByteArray()); + Handle translations = translations_.CreateByteArray(); + data->SetTranslationByteArray(*translations); data->SetInlinedFunctionCount(Smi::FromInt(inlined_function_count_)); Handle literals = @@ -686,13 +705,13 @@ void LCodeGen::DoCallStub(LCallStub* instr) { break; } case CodeStub::StringCharAt: { - // TODO(1116): Add StringCharAt stub to x64. - Abort("Unimplemented: %s", "StringCharAt Stub"); + StringCharAtStub stub; + CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); break; } case CodeStub::MathPow: { - // TODO(1115): Add MathPow stub to x64. - Abort("Unimplemented: %s", "MathPow Stub"); + MathPowStub stub; + CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); break; } case CodeStub::NumberToString: { @@ -711,7 +730,8 @@ void LCodeGen::DoCallStub(LCallStub* instr) { break; } case CodeStub::TranscendentalCache: { - TranscendentalCacheStub stub(instr->transcendental_type()); + TranscendentalCacheStub stub(instr->transcendental_type(), + TranscendentalCacheStub::TAGGED); CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); break; } @@ -1579,7 +1599,20 @@ static Condition BranchCondition(HHasInstanceType* instr) { void LCodeGen::DoHasInstanceType(LHasInstanceType* instr) { - Abort("Unimplemented: %s", "DoHasInstanceType"); + Register input = ToRegister(instr->InputAt(0)); + Register result = ToRegister(instr->result()); + + ASSERT(instr->hydrogen()->value()->representation().IsTagged()); + __ testl(input, Immediate(kSmiTagMask)); + NearLabel done, is_false; + __ j(zero, &is_false); + __ CmpObjectType(input, TestType(instr->hydrogen()), result); + __ j(NegateCondition(BranchCondition(instr->hydrogen())), &is_false); + __ LoadRoot(result, Heap::kTrueValueRootIndex); + __ jmp(&done); + __ bind(&is_false); + __ LoadRoot(result, Heap::kFalseValueRootIndex); + __ bind(&done); } @@ -1599,7 +1632,17 @@ void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) { void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) { - Abort("Unimplemented: %s", "DoHasCachedArrayIndex"); + Register input = ToRegister(instr->InputAt(0)); + Register result = ToRegister(instr->result()); + + ASSERT(instr->hydrogen()->value()->representation().IsTagged()); + __ LoadRoot(result, Heap::kTrueValueRootIndex); + __ testl(FieldOperand(input, String::kHashFieldOffset), + Immediate(String::kContainsCachedArrayIndexMask)); + NearLabel done; + __ j(not_zero, &done); + __ LoadRoot(result, Heap::kFalseValueRootIndex); + __ bind(&done); } @@ -1795,9 +1838,7 @@ void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { __ push(ToRegister(instr->InputAt(0))); __ Push(instr->function()); __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); - __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); - RecordSafepointWithRegisters( - instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); + CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); __ movq(kScratchRegister, rax); __ PopSafepointRegisters(); __ testq(kScratchRegister, kScratchRegister); @@ -2271,12 +2312,105 @@ void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { - Abort("Unimplemented: %s", "DoDeferredMathAbsTaggedHeapNumber"); + Register input_reg = ToRegister(instr->InputAt(0)); + __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), + Heap::kHeapNumberMapRootIndex); + DeoptimizeIf(not_equal, instr->environment()); + + Label done; + Register tmp = input_reg.is(rax) ? rcx : rax; + Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx; + + // Preserve the value of all registers. + __ PushSafepointRegisters(); + + Label negative; + __ movl(tmp, FieldOperand(input_reg, HeapNumber::kExponentOffset)); + // Check the sign of the argument. If the argument is positive, just + // return it. We do not need to patch the stack since |input| and + // |result| are the same register and |input| will be restored + // unchanged by popping safepoint registers. + __ testl(tmp, Immediate(HeapNumber::kSignMask)); + __ j(not_zero, &negative); + __ jmp(&done); + + __ bind(&negative); + + Label allocated, slow; + __ AllocateHeapNumber(tmp, tmp2, &slow); + __ jmp(&allocated); + + // Slow case: Call the runtime system to do the number allocation. + __ bind(&slow); + + __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); + RecordSafepointWithRegisters( + instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); + // Set the pointer to the new heap number in tmp. + if (!tmp.is(rax)) { + __ movq(tmp, rax); + } + + // Restore input_reg after call to runtime. + __ LoadFromSafepointRegisterSlot(input_reg, input_reg); + + __ bind(&allocated); + __ movq(tmp2, FieldOperand(input_reg, HeapNumber::kValueOffset)); + __ shl(tmp2, Immediate(1)); + __ shr(tmp2, Immediate(1)); + __ movq(FieldOperand(tmp, HeapNumber::kValueOffset), tmp2); + __ StoreToSafepointRegisterSlot(input_reg, tmp); + + __ bind(&done); + __ PopSafepointRegisters(); +} + + +void LCodeGen::EmitIntegerMathAbs(LUnaryMathOperation* instr) { + Register input_reg = ToRegister(instr->InputAt(0)); + __ testl(input_reg, input_reg); + Label is_positive; + __ j(not_sign, &is_positive); + __ negl(input_reg); // Sets flags. + DeoptimizeIf(negative, instr->environment()); + __ bind(&is_positive); } void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { - Abort("Unimplemented: %s", "DoMathAbs"); + // Class for deferred case. + class DeferredMathAbsTaggedHeapNumber: public LDeferredCode { + public: + DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen, + LUnaryMathOperation* instr) + : LDeferredCode(codegen), instr_(instr) { } + virtual void Generate() { + codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_); + } + private: + LUnaryMathOperation* instr_; + }; + + ASSERT(instr->InputAt(0)->Equals(instr->result())); + Representation r = instr->hydrogen()->value()->representation(); + + if (r.IsDouble()) { + XMMRegister scratch = xmm0; + XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); + __ xorpd(scratch, scratch); + __ subsd(scratch, input_reg); + __ andpd(input_reg, scratch); + } else if (r.IsInteger32()) { + EmitIntegerMathAbs(instr); + } else { // Tagged case. + DeferredMathAbsTaggedHeapNumber* deferred = + new DeferredMathAbsTaggedHeapNumber(this, instr); + Register input_reg = ToRegister(instr->InputAt(0)); + // Smi check. + __ JumpIfNotSmi(input_reg, deferred->entry()); + EmitIntegerMathAbs(instr); + __ bind(deferred->exit()); + } } @@ -2355,22 +2489,78 @@ void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) { void LCodeGen::DoPower(LPower* instr) { - Abort("Unimplemented: %s", "DoPower"); + LOperand* left = instr->InputAt(0); + XMMRegister left_reg = ToDoubleRegister(left); + ASSERT(!left_reg.is(xmm1)); + LOperand* right = instr->InputAt(1); + XMMRegister result_reg = ToDoubleRegister(instr->result()); + Representation exponent_type = instr->hydrogen()->right()->representation(); + if (exponent_type.IsDouble()) { + __ PrepareCallCFunction(2); + // Move arguments to correct registers + __ movsd(xmm0, left_reg); + ASSERT(ToDoubleRegister(right).is(xmm1)); + __ CallCFunction(ExternalReference::power_double_double_function(), 2); + } else if (exponent_type.IsInteger32()) { + __ PrepareCallCFunction(2); + // Move arguments to correct registers: xmm0 and edi (not rdi). + // On Windows, the registers are xmm0 and edx. + __ movsd(xmm0, left_reg); +#ifdef _WIN64 + ASSERT(ToRegister(right).is(rdx)); +#else + ASSERT(ToRegister(right).is(rdi)); +#endif + __ CallCFunction(ExternalReference::power_double_int_function(), 2); + } else { + ASSERT(exponent_type.IsTagged()); + CpuFeatures::Scope scope(SSE2); + Register right_reg = ToRegister(right); + + Label non_smi, call; + __ JumpIfNotSmi(right_reg, &non_smi); + __ SmiToInteger32(right_reg, right_reg); + __ cvtlsi2sd(xmm1, right_reg); + __ jmp(&call); + + __ bind(&non_smi); + __ CmpObjectType(right_reg, HEAP_NUMBER_TYPE , kScratchRegister); + DeoptimizeIf(not_equal, instr->environment()); + __ movsd(xmm1, FieldOperand(right_reg, HeapNumber::kValueOffset)); + + __ bind(&call); + __ PrepareCallCFunction(2); + // Move arguments to correct registers xmm0 and xmm1. + __ movsd(xmm0, left_reg); + // Right argument is already in xmm1. + __ CallCFunction(ExternalReference::power_double_double_function(), 2); + } + // Return value is in xmm0. + __ movsd(result_reg, xmm0); } void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { - Abort("Unimplemented: %s", "DoMathLog"); + ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); + TranscendentalCacheStub stub(TranscendentalCache::LOG, + TranscendentalCacheStub::UNTAGGED); + CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); } void LCodeGen::DoMathCos(LUnaryMathOperation* instr) { - Abort("Unimplemented: %s", "DoMathCos"); + ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); + TranscendentalCacheStub stub(TranscendentalCache::LOG, + TranscendentalCacheStub::UNTAGGED); + CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); } void LCodeGen::DoMathSin(LUnaryMathOperation* instr) { - Abort("Unimplemented: %s", "DoMathSin"); + ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); + TranscendentalCacheStub stub(TranscendentalCache::LOG, + TranscendentalCacheStub::UNTAGGED); + CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); } @@ -2414,6 +2604,7 @@ void LCodeGen::DoCallKeyed(LCallKeyed* instr) { int arity = instr->arity(); Handle ic = StubCache::ComputeKeyedCallInitialize(arity, NOT_IN_LOOP); CallCode(ic, RelocInfo::CODE_TARGET, instr); + __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); } @@ -2506,7 +2697,9 @@ void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { ASSERT(ToRegister(instr->value()).is(rax)); __ Move(rcx, instr->hydrogen()->name()); - Handle ic(Builtins::builtin(Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + info_->is_strict() ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -2575,7 +2768,9 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { ASSERT(ToRegister(instr->key()).is(rcx)); ASSERT(ToRegister(instr->value()).is(rax)); - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + info_->is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); CallCode(ic, RelocInfo::CODE_TARGET, instr); } diff --git a/deps/v8/src/x64/lithium-codegen-x64.h b/deps/v8/src/x64/lithium-codegen-x64.h index 52409f207b..420556a585 100644 --- a/deps/v8/src/x64/lithium-codegen-x64.h +++ b/deps/v8/src/x64/lithium-codegen-x64.h @@ -53,6 +53,7 @@ class LCodeGen BASE_EMBEDDED { current_instruction_(-1), instructions_(chunk->instructions()), deoptimizations_(4), + jump_table_(4), deoptimization_literals_(8), inlined_function_count_(0), scope_(chunk->graph()->info()->scope()), @@ -147,6 +148,7 @@ class LCodeGen BASE_EMBEDDED { bool GeneratePrologue(); bool GenerateBody(); bool GenerateDeferredCode(); + bool GenerateJumpTable(); bool GenerateSafepointTable(); void CallCode(Handle code, @@ -186,6 +188,7 @@ class LCodeGen BASE_EMBEDDED { XMMRegister ToDoubleRegister(int index) const; // Specific math operations - used from DoUnaryMathOperation. + void EmitIntegerMathAbs(LUnaryMathOperation* instr); void DoMathAbs(LUnaryMathOperation* instr); void DoMathFloor(LUnaryMathOperation* instr); void DoMathRound(LUnaryMathOperation* instr); @@ -233,6 +236,14 @@ class LCodeGen BASE_EMBEDDED { // Emits code for pushing a constant operand. void EmitPushConstantOperand(LOperand* operand); + struct JumpTableEntry { + inline JumpTableEntry(Address address) + : label_(), + address_(address) { } + Label label_; + Address address_; + }; + LChunk* const chunk_; MacroAssembler* const masm_; CompilationInfo* const info_; @@ -241,6 +252,7 @@ class LCodeGen BASE_EMBEDDED { int current_instruction_; const ZoneList* instructions_; ZoneList deoptimizations_; + ZoneList jump_table_; ZoneList > deoptimization_literals_; int inlined_function_count_; Scope* const scope_; diff --git a/deps/v8/src/x64/lithium-x64.cc b/deps/v8/src/x64/lithium-x64.cc index 2ed109d137..18b38e2481 100644 --- a/deps/v8/src/x64/lithium-x64.cc +++ b/deps/v8/src/x64/lithium-x64.cc @@ -1158,9 +1158,8 @@ LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) { LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal( HInstanceOfKnownGlobal* instr) { LInstanceOfKnownGlobal* result = - new LInstanceOfKnownGlobal(UseRegisterAtStart(instr->value())); - MarkAsSaveDoubles(result); - return AssignEnvironment(AssignPointerMap(DefineFixed(result, rax))); + new LInstanceOfKnownGlobal(UseFixed(instr->value(), rax)); + return MarkAsCall(DefineFixed(result, rax), instr); } @@ -1436,8 +1435,22 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { LInstruction* LChunkBuilder::DoPower(HPower* instr) { - Abort("Unimplemented: %s", "DoPower"); - return NULL; + ASSERT(instr->representation().IsDouble()); + // We call a C function for double power. It can't trigger a GC. + // We need to use fixed result register for the call. + Representation exponent_type = instr->right()->representation(); + ASSERT(instr->left()->representation().IsDouble()); + LOperand* left = UseFixedDouble(instr->left(), xmm2); + LOperand* right = exponent_type.IsDouble() ? + UseFixedDouble(instr->right(), xmm1) : +#ifdef _WIN64 + UseFixed(instr->right(), rdx); +#else + UseFixed(instr->right(), rdi); +#endif + LPower* result = new LPower(left, right); + return MarkAsCall(DefineFixedDouble(result, xmm1), instr, + CAN_DEOPTIMIZE_EAGERLY); } @@ -1502,8 +1515,10 @@ LInstruction* LChunkBuilder::DoIsSmi(HIsSmi* instr) { LInstruction* LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) { - Abort("Unimplemented: %s", "DoHasInstanceType"); - return NULL; + ASSERT(instr->value()->representation().IsTagged()); + LOperand* value = UseRegisterAtStart(instr->value()); + + return DefineAsRegister(new LHasInstanceType(value)); } @@ -1516,8 +1531,9 @@ LInstruction* LChunkBuilder::DoGetCachedArrayIndex( LInstruction* LChunkBuilder::DoHasCachedArrayIndex( HHasCachedArrayIndex* instr) { - Abort("Unimplemented: %s", "DoHasCachedArrayIndex"); - return NULL; + ASSERT(instr->value()->representation().IsTagged()); + LOperand* value = UseRegister(instr->value()); + return DefineAsRegister(new LHasCachedArrayIndex(value)); } diff --git a/deps/v8/src/x64/macro-assembler-x64.cc b/deps/v8/src/x64/macro-assembler-x64.cc index 48e42c85ca..8845bbb77c 100644 --- a/deps/v8/src/x64/macro-assembler-x64.cc +++ b/deps/v8/src/x64/macro-assembler-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -136,7 +136,7 @@ void MacroAssembler::RecordWrite(Register object, Register value) { // The compiled code assumes that record write doesn't change the // context register, so we check that none of the clobbered - // registers are esi. + // registers are rsi. ASSERT(!object.is(rsi) && !value.is(rsi) && !address.is(rsi)); // First, check if a write barrier is even needed. The tests below @@ -1503,6 +1503,11 @@ void MacroAssembler::StoreToSafepointRegisterSlot(Register dst, Register src) { } +void MacroAssembler::LoadFromSafepointRegisterSlot(Register dst, Register src) { + movq(dst, SafepointRegisterSlot(src)); +} + + Operand MacroAssembler::SafepointRegisterSlot(Register reg) { return Operand(rsp, SafepointRegisterStackIndex(reg.code()) * kPointerSize); } @@ -2531,9 +2536,21 @@ void MacroAssembler::LoadContext(Register dst, int context_chain_length) { } // The context may be an intermediate context, not a function context. movq(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); - } else { // context is the current function context. - // The context may be an intermediate context, not a function context. - movq(dst, Operand(rsi, Context::SlotOffset(Context::FCONTEXT_INDEX))); + } else { + // Slot is in the current function context. Move it into the + // destination register in case we store into it (the write barrier + // cannot be allowed to destroy the context in rsi). + movq(dst, rsi); + } + + // We should not have found a 'with' context by walking the context chain + // (i.e., the static scope chain and runtime context chain do not agree). + // A variable occurring in such a scope should have slot type LOOKUP and + // not CONTEXT. + if (FLAG_debug_code) { + cmpq(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); + Check(equal, "Yo dawg, I heard you liked function contexts " + "so I put function contexts in all your contexts"); } } diff --git a/deps/v8/src/x64/macro-assembler-x64.h b/deps/v8/src/x64/macro-assembler-x64.h index 4c5c60c8f0..4cf59c4e89 100644 --- a/deps/v8/src/x64/macro-assembler-x64.h +++ b/deps/v8/src/x64/macro-assembler-x64.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -174,7 +174,7 @@ class MacroAssembler: public Assembler { // Store the value in register src in the safepoint register stack // slot for register dst. void StoreToSafepointRegisterSlot(Register dst, Register src); - + void LoadFromSafepointRegisterSlot(Register dst, Register src); // --------------------------------------------------------------------------- // JavaScript invokes diff --git a/deps/v8/src/x64/regexp-macro-assembler-x64.cc b/deps/v8/src/x64/regexp-macro-assembler-x64.cc index 27f3482a9a..cd3bfbd42c 100644 --- a/deps/v8/src/x64/regexp-macro-assembler-x64.cc +++ b/deps/v8/src/x64/regexp-macro-assembler-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/regexp-macro-assembler-x64.h b/deps/v8/src/x64/regexp-macro-assembler-x64.h index 182bc5529f..421a229447 100644 --- a/deps/v8/src/x64/regexp-macro-assembler-x64.h +++ b/deps/v8/src/x64/regexp-macro-assembler-x64.h @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2010 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/simulator-x64.h b/deps/v8/src/x64/simulator-x64.h index 3a62ffd5c3..aa2994f267 100644 --- a/deps/v8/src/x64/simulator-x64.h +++ b/deps/v8/src/x64/simulator-x64.h @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/deps/v8/src/x64/stub-cache-x64.cc b/deps/v8/src/x64/stub-cache-x64.cc index c27e1b8c42..109985c726 100644 --- a/deps/v8/src/x64/stub-cache-x64.cc +++ b/deps/v8/src/x64/stub-cache-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -2408,12 +2408,13 @@ MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, __ push(rdx); // receiver __ push(rcx); // name __ push(rax); // value + __ Push(Smi::FromInt(strict_mode_)); __ push(rbx); // restore return address // Do tail-call to the runtime system. ExternalReference store_ic_property = ExternalReference(IC_Utility(IC::kStoreInterceptorProperty)); - __ TailCallExternalReference(store_ic_property, 3, 1); + __ TailCallExternalReference(store_ic_property, 4, 1); // Handle store cache miss. __ bind(&miss); @@ -3490,10 +3491,13 @@ MaybeObject* ExternalArrayStubCompiler::CompileKeyedStoreStub( __ push(rdx); // receiver __ push(rcx); // key __ push(rax); // value + __ Push(Smi::FromInt(NONE)); // PropertyAttributes + __ Push(Smi::FromInt( + Code::ExtractExtraICStateFromFlags(flags) & kStrictMode)); __ push(rbx); // return address // Do tail-call to runtime routine. - __ TailCallRuntime(Runtime::kSetProperty, 3, 1); + __ TailCallRuntime(Runtime::kSetProperty, 5, 1); return GetCode(flags); } diff --git a/deps/v8/src/x64/virtual-frame-x64.cc b/deps/v8/src/x64/virtual-frame-x64.cc index 31f9527a6d..c4d7e65663 100644 --- a/deps/v8/src/x64/virtual-frame-x64.cc +++ b/deps/v8/src/x64/virtual-frame-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -274,6 +274,24 @@ void VirtualFrame::Push(Expression* expr) { } +void VirtualFrame::Push(Handle value) { + if (ConstantPoolOverflowed()) { + Result temp = cgen()->allocator()->Allocate(); + ASSERT(temp.is_valid()); + if (value->IsSmi()) { + __ Move(temp.reg(), Smi::cast(*value)); + } else { + __ movq(temp.reg(), value, RelocInfo::EMBEDDED_OBJECT); + } + Push(&temp); + } else { + FrameElement element = + FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED); + elements_.Add(element); + } +} + + void VirtualFrame::Drop(int count) { ASSERT(count >= 0); ASSERT(height() >= count); @@ -1124,9 +1142,9 @@ Result VirtualFrame::CallStoreIC(Handle name, StrictModeFlag strict_mode) { // Value and (if not contextual) receiver are on top of the frame. // The IC expects name in rcx, value in rax, and receiver in rdx. - Handle ic(Builtins::builtin(strict_mode == kStrictMode - ? Builtins::StoreIC_Initialize_Strict - : Builtins::StoreIC_Initialize)); + Handle ic(Builtins::builtin( + (strict_mode == kStrictMode) ? Builtins::StoreIC_Initialize_Strict + : Builtins::StoreIC_Initialize)); Result value = Pop(); RelocInfo::Mode mode; if (is_contextual) { @@ -1146,7 +1164,7 @@ Result VirtualFrame::CallStoreIC(Handle name, } -Result VirtualFrame::CallKeyedStoreIC() { +Result VirtualFrame::CallKeyedStoreIC(StrictModeFlag strict_mode) { // Value, key, and receiver are on the top of the frame. The IC // expects value in rax, key in rcx, and receiver in rdx. Result value = Pop(); @@ -1190,7 +1208,9 @@ Result VirtualFrame::CallKeyedStoreIC() { receiver.Unuse(); } - Handle ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); + Handle ic(Builtins::builtin( + (strict_mode == kStrictMode) ? Builtins::KeyedStoreIC_Initialize_Strict + : Builtins::KeyedStoreIC_Initialize)); return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); } diff --git a/deps/v8/src/x64/virtual-frame-x64.h b/deps/v8/src/x64/virtual-frame-x64.h index 4a9c72034e..7396db17f6 100644 --- a/deps/v8/src/x64/virtual-frame-x64.h +++ b/deps/v8/src/x64/virtual-frame-x64.h @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -343,7 +343,7 @@ class VirtualFrame : public ZoneObject { // Call keyed store IC. Value, key, and receiver are found on top // of the frame. All three are dropped. - Result CallKeyedStoreIC(); + Result CallKeyedStoreIC(StrictModeFlag strict_mode); // Call call IC. Function name, arguments, and receiver are found on top // of the frame and dropped by the call. @@ -400,9 +400,11 @@ class VirtualFrame : public ZoneObject { // Uses kScratchRegister, emits appropriate relocation info. void EmitPush(Handle value); + inline bool ConstantPoolOverflowed(); + // Push an element on the virtual frame. + void Push(Handle value); inline void Push(Register reg, TypeInfo info = TypeInfo::Unknown()); - inline void Push(Handle value); inline void Push(Smi* value); // Pushing a result invalidates it (its contents become owned by the diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 0da3f1cdc7..f450a34597 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -7627,10 +7627,11 @@ static void GenerateSomeGarbage() { "garbage = undefined;"); } + v8::Handle DirectApiCallback(const v8::Arguments& args) { static int count = 0; if (count++ % 3 == 0) { - v8::V8::LowMemoryNotification(); // This should move the stub + i::Heap::CollectAllGarbage(true); // This should move the stub GenerateSomeGarbage(); // This should ensure the old stub memory is flushed } return v8::Handle(); @@ -7682,6 +7683,54 @@ THREADED_TEST(CallICFastApi_DirectCall_Throw) { } +v8::Handle DirectGetterCallback(Local name, + const v8::AccessorInfo& info) { + if (++p_getter_count % 3 == 0) { + i::Heap::CollectAllGarbage(true); + GenerateSomeGarbage(); + } + return v8::Handle(); +} + + +THREADED_TEST(LoadICFastApi_DirectCall_GCMoveStub) { + v8::HandleScope scope; + LocalContext context; + v8::Handle obj = v8::ObjectTemplate::New(); + obj->SetAccessor(v8_str("p1"), DirectGetterCallback); + context->Global()->Set(v8_str("o1"), obj->NewInstance()); + p_getter_count = 0; + CompileRun( + "function f() {" + " for (var i = 0; i < 30; i++) o1.p1;" + "}" + "f();"); + CHECK_EQ(30, p_getter_count); +} + + +v8::Handle ThrowingDirectGetterCallback( + Local name, const v8::AccessorInfo& info) { + return v8::ThrowException(v8_str("g")); +} + + +THREADED_TEST(LoadICFastApi_DirectCall_Throw) { + v8::HandleScope scope; + LocalContext context; + v8::Handle obj = v8::ObjectTemplate::New(); + obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback); + context->Global()->Set(v8_str("o1"), obj->NewInstance()); + v8::Handle result = CompileRun( + "var result = '';" + "for (var i = 0; i < 5; i++) {" + " try { o1.p1; } catch (e) { result += e; }" + "}" + "result;"); + CHECK_EQ(v8_str("ggggg"), result); +} + + THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) { int interceptor_call_count = 0; v8::HandleScope scope; @@ -10042,10 +10091,11 @@ class RegExpStringModificationTest { // Inject the input as a global variable. i::Handle input_name = i::Factory::NewStringFromAscii(i::Vector("input", 5)); - i::Top::global_context()->global()->SetProperty(*input_name, - *input_, - NONE)->ToObjectChecked(); - + i::Top::global_context()->global()->SetProperty( + *input_name, + *input_, + NONE, + i::kNonStrictMode)->ToObjectChecked(); MorphThread morph_thread(this); morph_thread.Start(); diff --git a/deps/v8/test/cctest/test-compiler.cc b/deps/v8/test/cctest/test-compiler.cc index b424b7f9e1..9f21b78dd6 100644 --- a/deps/v8/test/cctest/test-compiler.cc +++ b/deps/v8/test/cctest/test-compiler.cc @@ -108,7 +108,7 @@ static void SetGlobalProperty(const char* name, Object* value) { Handle object(value); Handle symbol = Factory::LookupAsciiSymbol(name); Handle global(Top::context()->global()); - SetProperty(global, symbol, object, NONE); + SetProperty(global, symbol, object, NONE, kNonStrictMode); } diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc index 441aae63c6..7245e54be7 100644 --- a/deps/v8/test/cctest/test-debug.cc +++ b/deps/v8/test/cctest/test-debug.cc @@ -153,7 +153,8 @@ class DebugLocalContext { Handle debug_string = v8::internal::Factory::LookupAsciiSymbol("debug"); SetProperty(global, debug_string, - Handle(Debug::debug_context()->global_proxy()), DONT_ENUM); + Handle(Debug::debug_context()->global_proxy()), DONT_ENUM, + ::v8::internal::kNonStrictMode); } private: v8::Persistent context_; diff --git a/deps/v8/test/cctest/test-heap.cc b/deps/v8/test/cctest/test-heap.cc index a23ee171f2..9cce01eaea 100644 --- a/deps/v8/test/cctest/test-heap.cc +++ b/deps/v8/test/cctest/test-heap.cc @@ -212,13 +212,14 @@ TEST(GarbageCollection) { Handle initial_map = Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); function->set_initial_map(*initial_map); - Top::context()->global()->SetProperty(*name, - *function, - NONE)->ToObjectChecked(); + Top::context()->global()->SetProperty( + *name, *function, NONE, kNonStrictMode)->ToObjectChecked(); // Allocate an object. Unrooted after leaving the scope. Handle obj = Factory::NewJSObject(function); - obj->SetProperty(*prop_name, Smi::FromInt(23), NONE)->ToObjectChecked(); - obj->SetProperty(*prop_namex, Smi::FromInt(24), NONE)->ToObjectChecked(); + obj->SetProperty( + *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); + obj->SetProperty( + *prop_namex, Smi::FromInt(24), NONE, kNonStrictMode)->ToObjectChecked(); CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex)); @@ -238,10 +239,10 @@ TEST(GarbageCollection) { HandleScope inner_scope; // Allocate another object, make it reachable from global. Handle obj = Factory::NewJSObject(function); - Top::context()->global()->SetProperty(*obj_name, - *obj, - NONE)->ToObjectChecked(); - obj->SetProperty(*prop_name, Smi::FromInt(23), NONE)->ToObjectChecked(); + Top::context()->global()->SetProperty( + *obj_name, *obj, NONE, kNonStrictMode)->ToObjectChecked(); + obj->SetProperty( + *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); } // After gc, it should survive. @@ -540,12 +541,12 @@ TEST(FunctionAllocation) { Handle prop_name = Factory::LookupAsciiSymbol("theSlot"); Handle obj = Factory::NewJSObject(function); - obj->SetProperty(*prop_name, Smi::FromInt(23), NONE)->ToObjectChecked(); + obj->SetProperty( + *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); // Check that we can add properties to function objects. - function->SetProperty(*prop_name, - Smi::FromInt(24), - NONE)->ToObjectChecked(); + function->SetProperty( + *prop_name, Smi::FromInt(24), NONE, kNonStrictMode)->ToObjectChecked(); CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name)); } @@ -567,7 +568,8 @@ TEST(ObjectProperties) { CHECK(!obj->HasLocalProperty(*first)); // add first - obj->SetProperty(*first, Smi::FromInt(1), NONE)->ToObjectChecked(); + obj->SetProperty( + *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); CHECK(obj->HasLocalProperty(*first)); // delete first @@ -575,8 +577,10 @@ TEST(ObjectProperties) { CHECK(!obj->HasLocalProperty(*first)); // add first and then second - obj->SetProperty(*first, Smi::FromInt(1), NONE)->ToObjectChecked(); - obj->SetProperty(*second, Smi::FromInt(2), NONE)->ToObjectChecked(); + obj->SetProperty( + *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); + obj->SetProperty( + *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); CHECK(obj->HasLocalProperty(*first)); CHECK(obj->HasLocalProperty(*second)); @@ -588,8 +592,10 @@ TEST(ObjectProperties) { CHECK(!obj->HasLocalProperty(*second)); // add first and then second - obj->SetProperty(*first, Smi::FromInt(1), NONE)->ToObjectChecked(); - obj->SetProperty(*second, Smi::FromInt(2), NONE)->ToObjectChecked(); + obj->SetProperty( + *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); + obj->SetProperty( + *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); CHECK(obj->HasLocalProperty(*first)); CHECK(obj->HasLocalProperty(*second)); @@ -603,14 +609,16 @@ TEST(ObjectProperties) { // check string and symbol match static const char* string1 = "fisk"; Handle s1 = Factory::NewStringFromAscii(CStrVector(string1)); - obj->SetProperty(*s1, Smi::FromInt(1), NONE)->ToObjectChecked(); + obj->SetProperty( + *s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); Handle s1_symbol = Factory::LookupAsciiSymbol(string1); CHECK(obj->HasLocalProperty(*s1_symbol)); // check symbol and string match static const char* string2 = "fugl"; Handle s2_symbol = Factory::LookupAsciiSymbol(string2); - obj->SetProperty(*s2_symbol, Smi::FromInt(1), NONE)->ToObjectChecked(); + obj->SetProperty( + *s2_symbol, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); Handle s2 = Factory::NewStringFromAscii(CStrVector(string2)); CHECK(obj->HasLocalProperty(*s2)); } @@ -631,7 +639,8 @@ TEST(JSObjectMaps) { Handle obj = Factory::NewJSObject(function); // Set a propery - obj->SetProperty(*prop_name, Smi::FromInt(23), NONE)->ToObjectChecked(); + obj->SetProperty( + *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); // Check the map has changed @@ -698,8 +707,10 @@ TEST(JSObjectCopy) { Handle first = Factory::LookupAsciiSymbol("first"); Handle second = Factory::LookupAsciiSymbol("second"); - obj->SetProperty(*first, Smi::FromInt(1), NONE)->ToObjectChecked(); - obj->SetProperty(*second, Smi::FromInt(2), NONE)->ToObjectChecked(); + obj->SetProperty( + *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); + obj->SetProperty( + *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); Object* ok = obj->SetElement(0, *first)->ToObjectChecked(); @@ -716,8 +727,10 @@ TEST(JSObjectCopy) { CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); // Flip the values. - clone->SetProperty(*first, Smi::FromInt(2), NONE)->ToObjectChecked(); - clone->SetProperty(*second, Smi::FromInt(1), NONE)->ToObjectChecked(); + clone->SetProperty( + *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); + clone->SetProperty( + *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); ok = clone->SetElement(0, *second)->ToObjectChecked(); ok = clone->SetElement(1, *first)->ToObjectChecked(); diff --git a/deps/v8/test/cctest/test-mark-compact.cc b/deps/v8/test/cctest/test-mark-compact.cc index 86f105f2c9..3e3175e735 100644 --- a/deps/v8/test/cctest/test-mark-compact.cc +++ b/deps/v8/test/cctest/test-mark-compact.cc @@ -189,7 +189,8 @@ TEST(MarkCompactCollector) { function->set_initial_map(initial_map); Top::context()->global()->SetProperty(func_name, function, - NONE)->ToObjectChecked(); + NONE, + kNonStrictMode)->ToObjectChecked(); JSObject* obj = JSObject::cast(Heap::AllocateJSObject(function)->ToObjectChecked()); @@ -208,10 +209,14 @@ TEST(MarkCompactCollector) { String::cast(Heap::LookupAsciiSymbol("theObject")->ToObjectChecked()); Top::context()->global()->SetProperty(obj_name, obj, - NONE)->ToObjectChecked(); + NONE, + kNonStrictMode)->ToObjectChecked(); String* prop_name = String::cast(Heap::LookupAsciiSymbol("theSlot")->ToObjectChecked()); - obj->SetProperty(prop_name, Smi::FromInt(23), NONE)->ToObjectChecked(); + obj->SetProperty(prop_name, + Smi::FromInt(23), + NONE, + kNonStrictMode)->ToObjectChecked(); Heap::CollectGarbage(OLD_POINTER_SPACE); diff --git a/deps/v8/test/es5conform/es5conform.status b/deps/v8/test/es5conform/es5conform.status index e021fc54dc..d6f7caf581 100644 --- a/deps/v8/test/es5conform/es5conform.status +++ b/deps/v8/test/es5conform/es5conform.status @@ -269,72 +269,6 @@ chapter11/11.13/11.13.1/11.13.1-4-3-s: FAIL # in strict mode (Global.length) chapter11/11.13/11.13.1/11.13.1-4-4-s: FAIL # simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Object.length) -chapter11/11.13/11.13.1/11.13.1-4-5-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Function.length) -chapter11/11.13/11.13.1/11.13.1-4-6-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Array.length) -chapter11/11.13/11.13.1/11.13.1-4-7-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (String.length) -chapter11/11.13/11.13.1/11.13.1-4-8-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Boolean.length) -chapter11/11.13/11.13.1/11.13.1-4-9-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Number.length) -chapter11/11.13/11.13.1/11.13.1-4-10-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Date.length) -chapter11/11.13/11.13.1/11.13.1-4-11-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (RegExp.length) -chapter11/11.13/11.13.1/11.13.1-4-12-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Error.length) -chapter11/11.13/11.13.1/11.13.1-4-13-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Number.MAX_VALUE) -chapter11/11.13/11.13.1/11.13.1-4-14-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Number.MIN_VALUE) -chapter11/11.13/11.13.1/11.13.1-4-15-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Number.NaN) -chapter11/11.13/11.13.1/11.13.1-4-16-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Number.NEGATIVE_INFINITY) -chapter11/11.13/11.13.1/11.13.1-4-17-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Number.POSITIVE_INFINITY) -chapter11/11.13/11.13.1/11.13.1-4-18-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Math.E) -chapter11/11.13/11.13.1/11.13.1-4-19-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Math.LN10) -chapter11/11.13/11.13.1/11.13.1-4-20-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Math.LN2) -chapter11/11.13/11.13.1/11.13.1-4-21-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Math.LOG2E) -chapter11/11.13/11.13.1/11.13.1-4-22-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Math.LOG10E) -chapter11/11.13/11.13.1/11.13.1-4-23-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Math.PI) -chapter11/11.13/11.13.1/11.13.1-4-24-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Math.SQRT1_2) -chapter11/11.13/11.13.1/11.13.1-4-25-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property -# in strict mode (Math.SQRT2) -chapter11/11.13/11.13.1/11.13.1-4-26-s: FAIL -# simple assignment throws TypeError if LeftHandSide is a readonly property # in strict mode (Global.undefined) chapter11/11.13/11.13.1/11.13.1-4-27-s: FAIL diff --git a/deps/v8/test/mjsunit/array-concat.js b/deps/v8/test/mjsunit/array-concat.js index db89f4d0b8..97bd85aca2 100644 --- a/deps/v8/test/mjsunit/array-concat.js +++ b/deps/v8/test/mjsunit/array-concat.js @@ -101,7 +101,6 @@ while (pos = poses.shift()) { assertEquals("undefined", typeof(c[-1])); assertEquals("undefined", typeof(c[0xffffffff])); assertEquals(c.length, a.length + 1); - } poses = [140, 4000000000]; @@ -193,3 +192,46 @@ for (var i = 0; i < holey.length; i++) { assertTrue(i in holey); } } + +// Polluted prototype from prior tests. +delete Array.prototype[123]; + +// Check that concat reads getters in the correct order. +var arr1 = [,2]; +var arr2 = [1,3]; +var r1 = [].concat(arr1, arr2); // [,2,1,3] +assertEquals([,2,1,3], r1); + +// Make first array change length of second array. +Object.defineProperty(arr1, 0, {get: function() { + arr2.push("X"); + return undefined; + }, configurable: true}) +var r2 = [].concat(arr1, arr2); // [undefined,2,1,3,"X"] +assertEquals([undefined,2,1,3,"X"], r2); + +// Make first array change length of second array massively. +arr2.length = 2; +Object.defineProperty(arr1, 0, {get: function() { + arr2[500000] = "X"; + return undefined; + }, configurable: true}) +var r3 = [].concat(arr1, arr2); // [undefined,2,1,3,"X"] +var expected = [undefined,2,1,3]; +expected[500000 + 2] = "X"; + +assertEquals(expected, r3); + +var arr3 = []; +var trace = []; +var expectedTrace = [] +function mkGetter(i) { return function() { trace.push(i); }; } +arr3.length = 10000; +for (var i = 0; i < 100; i++) { + Object.defineProperty(arr3, i * i, {get: mkGetter(i)}); + expectedTrace[i] = i; + expectedTrace[100 + i] = i; +} +var r4 = [0].concat(arr3, arr3); +assertEquals(1 + arr3.length * 2, r4.length); +assertEquals(expectedTrace, trace); diff --git a/deps/v8/test/mjsunit/array-join.js b/deps/v8/test/mjsunit/array-join.js index c66e4626e7..ddd14967f0 100644 --- a/deps/v8/test/mjsunit/array-join.js +++ b/deps/v8/test/mjsunit/array-join.js @@ -27,19 +27,44 @@ // Test that array join calls toString on subarrays. var a = [[1,2],3,4,[5,6]]; +assertEquals('1,2345,6', a.join('')); assertEquals('1,2*3*4*5,6', a.join('*')); +assertEquals('1,2**3**4**5,6', a.join('**')); +assertEquals('1,2****3****4****5,6', a.join('****')); +assertEquals('1,2********3********4********5,6', a.join('********')); +assertEquals('1,2**********3**********4**********5,6', a.join('**********')); // Create a cycle. a.push(a); +assertEquals('1,2345,6', a.join('')); assertEquals('1,2*3*4*5,6*', a.join('*')); +assertEquals('1,2**3**4**5,6**', a.join('**')); +assertEquals('1,2****3****4****5,6****', a.join('****')); +assertEquals('1,2********3********4********5,6********', a.join('********')); +assertEquals('1,2**********3**********4**********5,6**********', a.join('**********')); // Replace array.prototype.toString. Array.prototype.toString = function() { return "array"; } +assertEquals('array34arrayarray', a.join('')); assertEquals('array*3*4*array*array', a.join('*')); +assertEquals('array**3**4**array**array', a.join('**')); +assertEquals('array****3****4****array****array', a.join('****')); +assertEquals('array********3********4********array********array', a.join('********')); +assertEquals('array**********3**********4**********array**********array', a.join('**********')); Array.prototype.toString = function() { throw 42; } +assertThrows("a.join('')"); assertThrows("a.join('*')"); +assertThrows("a.join('**')"); +assertThrows("a.join('****')"); +assertThrows("a.join('********')"); +assertThrows("a.join('**********')"); Array.prototype.toString = function() { return "array"; } +assertEquals('array34arrayarray', a.join('')); assertEquals('array*3*4*array*array', a.join('*')); +assertEquals('array**3**4**array**array', a.join('**')); +assertEquals('array****3****4****array****array', a.join('****')); +assertEquals('array********3********4********array********array', a.join('********')); +assertEquals('array**********3**********4**********array**********array', a.join('**********')); diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index c10281fc19..8f042ced7a 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -110,18 +110,6 @@ regress/regress-3247124: SKIP # should be platform-independent. regress/regress-1132: SKIP -############################################################################## -[ $arch == arm && $crankshaft ] - -# BUG (1094) -regress/regress-deopt-gc: SKIP - -############################################################################## -[ $arch == x64 && $crankshaft ] - -# BUG (1094) -regress/regress-deopt-gc: SKIP - ############################################################################## [ $arch == mips ] diff --git a/deps/v8/test/mjsunit/override-eval-with-non-function.js b/deps/v8/test/mjsunit/override-eval-with-non-function.js new file mode 100644 index 0000000000..aa93b25305 --- /dev/null +++ b/deps/v8/test/mjsunit/override-eval-with-non-function.js @@ -0,0 +1,36 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// When 'eval' is overridden with a non-function object we should +// check whether the object is callable. + +function test() { + eval = /foo/; + assertEquals("foo", eval("foobar")); +} + +test(); diff --git a/deps/v8/test/mjsunit/regress/regress-1145.js b/deps/v8/test/mjsunit/regress/regress-1145.js new file mode 100644 index 0000000000..16d5527bbb --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-1145.js @@ -0,0 +1,54 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --opt-eagerly --debug-code --lazy + +// See: http://code.google.com/p/v8/issues/detail?id=1145 +// Should not throw a syntax error exception (change this if we make lazily +// compiled functions with syntax errors into early errors). +// Should not hit an assertion in debug mode. + +// A lazily compiled function with a syntax error that is attempted inlined +// would set a pending exception that is then ignored (until it triggers +// an assert). +// This file must be at least 1024 bytes long to trigger lazy compilation. + +function f() { return 1; } + +// Must be lazy. Must throw SyntaxError during compilation. +function fail() { continue; } + +function opt_me() { + var x = 1; + // Do lots of function calls and hope to be optimized. + for (var i = 0; i < 1000000; i++) { + x = f(); + } + if (x == 0) fail(); // Hope to be inlined during optimization. +} + +opt_me(); diff --git a/deps/v8/test/mjsunit/regress/regress-1172-bis.js b/deps/v8/test/mjsunit/regress/regress-1172-bis.js new file mode 100644 index 0000000000..e8d5c81273 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-1172-bis.js @@ -0,0 +1,37 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Verifies that exception thrown from JS accessors when attempting a call +// are properly treated. + +Object.prototype.__defineGetter__(0, function() { throw 42; }); +try { + Object[0](); + assertUnreachable(); +} catch(e) { + assertEquals(42, e); +} diff --git a/deps/v8/test/mjsunit/regress/regress-1181.js b/deps/v8/test/mjsunit/regress/regress-1181.js new file mode 100644 index 0000000000..d45a0bee35 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-1181.js @@ -0,0 +1,54 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// The first count times, test is called with an integer argument and +// crankshaft produces code for int32 representation. Test that the +// implementation correctly deoptimizes. + +// Flags: --allow-natives-syntax + +function test(x) { + var xp = x * 1 - 1; + return xp; +} + + +function check(count) { + %DeoptimizeFunction(test); + var i; + for(var x=0; x < count; x++){ + for(var y=0; y < count; y++){ + i = test(x / 100); + } + } + assertEquals((count - 1) / 100, i + 1); +} + + +check(150); +check(200); +check(350); \ No newline at end of file diff --git a/deps/v8/test/mjsunit/regress/regress-1207.js b/deps/v8/test/mjsunit/regress/regress-1207.js new file mode 100644 index 0000000000..102178abba --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-1207.js @@ -0,0 +1,35 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Test throwing an exception from instanceof. +try { +var object = { }; +function fib(n) { + var f0 = (object instanceof encodeURI)('#2: var x = 1; x <= 1 === true'), f1 = 1; +} +fib(75); +} catch (o) { } diff --git a/deps/v8/test/mjsunit/regress/regress-1209.js b/deps/v8/test/mjsunit/regress/regress-1209.js new file mode 100644 index 0000000000..c017fb5107 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-1209.js @@ -0,0 +1,34 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function crashMe(n) { + var nasty = []; + while (n--) + nasty.push("a" + 0); + return Function.apply(null, nasty); +} +crashMe(64 + 1).length; diff --git a/deps/v8/test/mjsunit/regress/regress-1210.js b/deps/v8/test/mjsunit/regress/regress-1210.js new file mode 100644 index 0000000000..9c708a5805 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-1210.js @@ -0,0 +1,48 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Deoptimization of the key expression in an arguments access should see +// the arguments object as the value of the receiver. + +var a = 0; + +function observe(x, y) { return x; } + +function side_effect(x) { a = x; } + +function test() { + // We will trigger deoptimization of 'a + 0' which should bail out to + // immediately after the call to 'side_effect' (i.e., still in the key + // subexpression of the arguments access). + return observe(a, arguments[side_effect(a), a + 0]); +} + +// Run enough to optimize assuming global 'a' is a smi. +for (var i = 0; i < 1000000; ++i) test(0); + +a = "hello"; +test(0); diff --git a/deps/v8/test/mjsunit/regress/regress-1213.js b/deps/v8/test/mjsunit/regress/regress-1213.js new file mode 100644 index 0000000000..d66e3cefc4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-1213.js @@ -0,0 +1,43 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Test that we do not allow overwriting a global property with a +// redeclaration that makes the property configurable (and hence +// deletable). + +var x = 0; + +function TestGlobal() { + for (var i = 0; i < 2; i++) { + x = x + 1; + } + this.eval('function x() {};'); + delete this['x']; +} + +TestGlobal(); +TestGlobal(); diff --git a/deps/v8/test/mjsunit/regress/regress-1218.js b/deps/v8/test/mjsunit/regress/regress-1218.js new file mode 100644 index 0000000000..dd036edbd7 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-1218.js @@ -0,0 +1,29 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Builtin functions should not have prototype objects. +assertFalse(Error.prototype.toString.hasOwnProperty("prototype")); diff --git a/deps/v8/test/mjsunit/strict-mode.js b/deps/v8/test/mjsunit/strict-mode.js index ab3e535ec3..4071232ebf 100644 --- a/deps/v8/test/mjsunit/strict-mode.js +++ b/deps/v8/test/mjsunit/strict-mode.js @@ -280,6 +280,19 @@ CheckStrictMode("function strict() { print(--arguments); }", SyntaxError); CheckStrictMode("function strict() { var x = --eval; }", SyntaxError); CheckStrictMode("function strict() { var x = --arguments; }", SyntaxError); +// Use of const in strict mode is disallowed in anticipation of ES Harmony. +CheckStrictMode("const x = 0;", SyntaxError); +CheckStrictMode("for (const x = 0; false;) {}", SyntaxError); +CheckStrictMode("function strict() { const x = 0; }", SyntaxError); + +// Strict mode only allows functions in SourceElements +CheckStrictMode("if (true) { function invalid() {} }", SyntaxError); +CheckStrictMode("for (;false;) { function invalid() {} }", SyntaxError); +CheckStrictMode("{ function invalid() {} }", SyntaxError); +CheckStrictMode("try { function invalid() {} } catch(e) {}", SyntaxError); +CheckStrictMode("try { } catch(e) { function invalid() {} }", SyntaxError); +CheckStrictMode("function outer() {{ function invalid() {} }}", SyntaxError); + // Delete of an unqualified identifier CheckStrictMode("delete unqualified;", SyntaxError); CheckStrictMode("function strict() { delete unqualified; }", SyntaxError); @@ -700,3 +713,118 @@ repeat(10, function() { testAssignToUndefined(false); }); cleanup(Boolean); } })(); + + +(function ObjectEnvironment() { + var o = {}; + Object.defineProperty(o, "foo", { value: "FOO", writable: false }); + assertThrows( + function () { + with (o) { + (function() { + "use strict"; + foo = "Hello"; + })(); + } + }, + TypeError); +})(); + + +(function TestSetPropertyWithoutSetter() { + var o = { get foo() { return "Yey"; } }; + assertThrows( + function broken() { + "use strict"; + o.foo = (0xBADBAD00 >> 1); + }, + TypeError); +})(); + + +(function TestSetPropertyNonConfigurable() { + var frozen = Object.freeze({}); + var sealed = Object.seal({}); + + function strict(o) { + "use strict"; + o.property = "value"; + } + + assertThrows(function() { strict(frozen); }, TypeError); + assertThrows(function() { strict(sealed); }, TypeError); +})(); + + +(function TestAssignmentToReadOnlyProperty() { + "use strict"; + + var o = {}; + Object.defineProperty(o, "property", { value: 7 }); + + assertThrows(function() { o.property = "new value"; }, TypeError); + assertThrows(function() { o.property += 10; }, TypeError); + assertThrows(function() { o.property -= 10; }, TypeError); + assertThrows(function() { o.property *= 10; }, TypeError); + assertThrows(function() { o.property /= 10; }, TypeError); + assertThrows(function() { o.property++; }, TypeError); + assertThrows(function() { o.property--; }, TypeError); + assertThrows(function() { ++o.property; }, TypeError); + assertThrows(function() { --o.property; }, TypeError); + + var name = "prop" + "erty"; // to avoid symbol path. + assertThrows(function() { o[name] = "new value"; }, TypeError); + assertThrows(function() { o[name] += 10; }, TypeError); + assertThrows(function() { o[name] -= 10; }, TypeError); + assertThrows(function() { o[name] *= 10; }, TypeError); + assertThrows(function() { o[name] /= 10; }, TypeError); + assertThrows(function() { o[name]++; }, TypeError); + assertThrows(function() { o[name]--; }, TypeError); + assertThrows(function() { ++o[name]; }, TypeError); + assertThrows(function() { --o[name]; }, TypeError); + + assertEquals(o.property, 7); +})(); + + +(function TestAssignmentToReadOnlyLoop() { + var name = "prop" + "erty"; // to avoid symbol path. + var o = {}; + Object.defineProperty(o, "property", { value: 7 }); + + function strict(o, name) { + "use strict"; + o[name] = "new value"; + } + + for (var i = 0; i < 10; i ++) { + try { + strict(o, name); + assertUnreachable(); + } catch(e) { + assertInstanceof(e, TypeError); + } + } +})(); + + +// Specialized KeyedStoreIC experiencing miss. +(function testKeyedStoreICStrict() { + var o = [9,8,7,6,5,4,3,2,1]; + + function test(o, i, v) { + "use strict"; + o[i] = v; + } + + for (var i = 0; i < 10; i ++) { + test(o, 5, 17); // start specialized for smi indices + assertEquals(o[5], 17); + test(o, "a", 19); + assertEquals(o["a"], 19); + test(o, "5", 29); + assertEquals(o[5], 29); + test(o, 100000, 31); + assertEquals(o[100000], 31); + } +})(); diff --git a/doc/api/addons.markdown b/doc/api/addons.markdown index 847d4144b5..5d8edd02d7 100644 --- a/doc/api/addons.markdown +++ b/doc/api/addons.markdown @@ -77,4 +77,4 @@ All Node addons must export a function called `init` with this signature: extern 'C' void init (Handle target) For the moment, that is all the documentation on addons. Please see - for a real example. + for a real example. diff --git a/doc/api/appendix_1.markdown b/doc/api/appendix_1.markdown index ea2700dea9..c035466fd1 100644 --- a/doc/api/appendix_1.markdown +++ b/doc/api/appendix_1.markdown @@ -21,7 +21,7 @@ elsewhere. - [mDNS/Zeroconf/Bonjour](http://github.com/agnat/node_mdns) -- [RabbitMQ, AMQP](http://github.com/joyent/node-amqp) +- [RabbitMQ, AMQP](https://github.com/ry/node-amqp) - [mysql](http://github.com/felixge/node-mysql) diff --git a/doc/api/https.markdown b/doc/api/https.markdown index b98c16b1f0..3c6a7c43a0 100644 --- a/doc/api/https.markdown +++ b/doc/api/https.markdown @@ -53,6 +53,18 @@ Example: console.error(e); }); +The options argument has the following options + +- host: IP or domain of host to make request to. Defaults to `'localhost'`. +- port: port of host to request to. Defaults to 443. +- path: Path to request. Default `'/'`. +- method: HTTP request method. Default `'GET'`. +- key: Private key to use for SSL. Default `null`. +- cert: Public x509 certificate to use. Default `null`. +- ca: An authority certificate or array of authority certificates to check + the remote host against. + + ## https.get(options, callback) Like `http.get()` but for HTTPS. diff --git a/doc/api/modules.markdown b/doc/api/modules.markdown index 5f2b747eec..f07fcd252d 100644 --- a/doc/api/modules.markdown +++ b/doc/api/modules.markdown @@ -212,6 +212,10 @@ the `NODE_PATH` environment variable might have been set to: /home/micheil/.node_modules:/usr/local/lib/node_modules +Loading from the `require.paths` locations is only performed if the +module could not be found using the `node_modules` algorithm above. +Global modules are lower priority than bundled dependencies. + #### **Note:** Please Avoid Modifying `require.paths` For compatibility reasons, `require.paths` is still given first priority diff --git a/doc/api/net.markdown b/doc/api/net.markdown index 6c67666b0e..e3321e02da 100644 --- a/doc/api/net.markdown +++ b/doc/api/net.markdown @@ -4,11 +4,21 @@ The `net` module provides you with an asynchronous network wrapper. It contains methods for creating both servers and clients (called streams). You can include this module with `require("net");` -### net.createServer(connectionListener) +### net.createServer([options], [connectionListener]) Creates a new TCP server. The `connectionListener` argument is automatically set as a listener for the `'connection'` event. +`options` is an object with the following defaults: + + { allowHalfOpen: false + } + +If `allowHalfOpen` is `true`, then the socket won't automatically send FIN +packet when the other end of the socket sends a FIN packet. The socket becomes +non-readable, but still writable. You should call the end() method explicitly. +See `'end'` event for more information. + ### net.createConnection(arguments...) Construct a new socket object and opens a socket to the given location. When @@ -153,6 +163,21 @@ and passed to the user through the `'connection'` event of a server. `net.Socket` instances are EventEmitters with the following events: +#### new net.Socket([options]) + +Construct a new socket object. + +`options` is an object with the following defaults: + + { fd: null + type: null + allowHalfOpen: false + } + +`fd` allows you to specify the existing file descriptor of socket. `type` +specified underlying protocol. It can be `'tcp4'`, `'tcp6'`, or `'unix'`. +About `allowHalfOpen`, refer to `createServer()` and `'end'` event. + #### socket.connect(port, [host], [callback]) #### socket.connect(path, [callback]) diff --git a/doc/index.html b/doc/index.html index 34dc236eba..a6b5d84834 100644 --- a/doc/index.html +++ b/doc/index.html @@ -20,7 +20,7 @@
  • Download
  • ChangeLog
  • About
  • -
  • v0.4.1 docs
  • +
  • v0.4.2 docs

  • Wiki
  • @@ -91,9 +91,9 @@ server.listen(8124, "127.0.0.1");

    - 2011.02.19 - node-v0.4.1.tar.gz - (Documentation) + 2011.03.02 + node-v0.4.2.tar.gz + (Documentation)

    Historical: versions, docs

    diff --git a/lib/_debugger.js b/lib/_debugger.js index 0618e4e816..f155ca2e71 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var net = require('net'); var readline = require('readline'); var inherits = require('util').inherits; diff --git a/lib/_linklist.js b/lib/_linklist.js index c5c209bfdc..b73bbed22b 100644 --- a/lib/_linklist.js +++ b/lib/_linklist.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + function init(list) { list._idleNext = list; list._idlePrev = list; diff --git a/lib/buffer.js b/lib/buffer.js index d5fb174d04..d3eb752f17 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var SlowBuffer = process.binding('buffer').SlowBuffer; diff --git a/lib/child_process.js b/lib/child_process.js index 2de11d670f..2b2fc41352 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var util = require('util'); var EventEmitter = require('events').EventEmitter; var Stream = require('net').Stream; diff --git a/lib/console.js b/lib/console.js index 708630725b..54a4d811fe 100644 --- a/lib/console.js +++ b/lib/console.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var writeError = process.binding('stdio').writeError; // console object diff --git a/lib/constants.js b/lib/constants.js index 33be3ae339..1b87b2b2d0 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + module.exports = process.binding('constants'); diff --git a/lib/crypto.js b/lib/crypto.js index 9c644c3c6e..c95103f3df 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + try { var binding = process.binding('crypto'); diff --git a/lib/dgram.js b/lib/dgram.js index 89c47f8d5c..815650bd0b 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var util = require('util'); var fs = require('fs'); var events = require('events'); diff --git a/lib/dns.js b/lib/dns.js index 516c7c20c2..a71738e893 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var dns = process.binding('cares'); var net = process.binding('net'); var IOWatcher = process.binding('io_watcher').IOWatcher; diff --git a/lib/events.js b/lib/events.js index 6505606b4e..2d2d5d19cb 100644 --- a/lib/events.js +++ b/lib/events.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var EventEmitter = exports.EventEmitter = process.EventEmitter; var isArray = Array.isArray; @@ -9,6 +30,7 @@ var isArray = Array.isArray; // that to be increased. Set to zero for unlimited. var defaultMaxListeners = 10; EventEmitter.prototype.setMaxListeners = function(n) { + if (!this._events) this._events = {}; this._events.maxListeners = n; }; diff --git a/lib/freelist.js b/lib/freelist.js index 31acea2f90..61a3f78f64 100644 --- a/lib/freelist.js +++ b/lib/freelist.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // This is a free list to avoid creating so many of the same object. exports.FreeList = function(name, max, constructor) { this.name = name; diff --git a/lib/fs.js b/lib/fs.js index fccbfd2551..99002ba7a7 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var util = require('util'); var binding = process.binding('fs'); @@ -1091,7 +1112,15 @@ WriteStream.prototype.write = function(data) { return false; }; -WriteStream.prototype.end = function(cb) { +WriteStream.prototype.end = function(data, encoding, cb) { + if (typeof(data) === 'function') { + cb = data; + } else if (typeof(encoding) === 'function') { + cb = encoding; + this.write(data); + } else if (arguments.length > 0) { + this.write(data, encoding); + } this.writable = false; this._queue.push([fs.close, cb]); this.flush(); diff --git a/lib/http.js b/lib/http.js index ca813c0109..386be18b9a 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var util = require('util'); var net = require('net'); var stream = require('stream'); @@ -1289,8 +1310,10 @@ Agent.prototype._establishNewConnection = function() { // All that should be required for keep-alive is to not reconnect, // but outgoingFlush instead. if (!req.shouldKeepAlive) { - debug('AGENT socket.end()'); - if (socket.writable) socket.end(); + if (socket.writable) { + debug('AGENT socket.destroySoon()'); + socket.destroySoon(); + } assert(!socket.writable); } else { debug('AGENT socket keep-alive'); diff --git a/lib/https.js b/lib/https.js index 141eff7791..1fd0e1bbc2 100644 --- a/lib/https.js +++ b/lib/https.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var tls = require('tls'); var http = require('http'); var inherits = require('util').inherits; diff --git a/lib/module.js b/lib/module.js index 304387d030..fa147d62e8 100644 --- a/lib/module.js +++ b/lib/module.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var NativeModule = require('native_module'); var Script = process.binding('evals').Script; var runInThisContext = Script.runInThisContext; @@ -202,7 +223,10 @@ Module._resolveLookupPaths = function(request, parent) { var start = request.substring(0, 2); if (start !== './' && start !== '..') { var paths = Module._paths; - if (parent) paths = paths.concat(parent.paths); + if (parent) { + if (!parent.paths) parent.paths = []; + paths = parent.paths.concat(paths); + } return [request, paths]; } @@ -211,7 +235,7 @@ Module._resolveLookupPaths = function(request, parent) { // make require('./path/to/foo') work - normally the path is taken // from realpath(__filename) but with eval there is no filename var mainPaths = ['.'].concat(Module._paths); - mainPaths = mainPaths.concat(Module._nodeModulePaths('.')); + mainPaths = Module._nodeModulePaths('.').concat(mainPaths); return [request, mainPaths]; } diff --git a/lib/net.js b/lib/net.js index d298e9a8e1..39010bf8b1 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var util = require('util'); var events = require('events'); var stream = require('stream'); @@ -118,7 +139,7 @@ function setImplmentationMethods(self) { // emitting the same value that we see now. Otherwise, we can end up // calling emit() after recvMsg() has been called again and end up // emitting null (or another FD). - if (recvMsg.fd !== null) { + if (typeof recvMsg.fd === 'number') { var fd = recvMsg.fd; process.nextTick(function() { self.emit('fd', fd); @@ -172,7 +193,7 @@ function initSocket(self) { self._readWatcher = ioWatchers.alloc(); self._readWatcher.socket = self; self._readWatcher.callback = onReadable; - self.readable = false; + self.readable = self.destroyed = false; // Queue of buffers and string that need to be written to socket. self._writeQueue = []; @@ -251,16 +272,16 @@ Object.defineProperty(Socket.prototype, 'readyState', { if (this._connecting) { return 'opening'; } else if (this.readable && this.writable) { - assert(typeof this.fd == 'number'); + assert(typeof this.fd === 'number'); return 'open'; } else if (this.readable && !this.writable) { - assert(typeof this.fd == 'number'); + assert(typeof this.fd === 'number'); return 'readOnly'; } else if (!this.readable && this.writable) { - assert(typeof this.fd == 'number'); + assert(typeof this.fd === 'number'); return 'writeOnly'; } else { - assert(typeof this.fd != 'number'); + assert(typeof this.fd !== 'number'); return 'closed'; } } @@ -665,7 +686,7 @@ Socket.prototype._onReadable = function() { Socket.prototype.connect = function() { var self = this; initSocket(self); - if (self.fd) throw new Error('Socket already opened'); + if (typeof self.fd === 'number') throw new Error('Socket already opened'); if (!self._readWatcher) throw new Error('No readWatcher'); timers.active(this); @@ -723,7 +744,7 @@ Socket.prototype.setKeepAlive = function(enable, time) { Socket.prototype.setTimeout = function(msecs, callback) { if (msecs > 0) { timers.enroll(this, msecs); - if (this.fd) { timers.active(this); } + if (typeof this.fd === 'number') { timers.active(this); } if (callback) { this.once('timeout', callback); } @@ -739,7 +760,9 @@ Socket.prototype.pause = function() { Socket.prototype.resume = function() { - if (this.fd === null) throw new Error('Cannot resume() closed Socket.'); + if (typeof this.fd !== 'number') { + throw new Error('Cannot resume() closed Socket.'); + } if (this._readWatcher) { this._readWatcher.stop(); this._readWatcher.set(this.fd, true, false); @@ -788,12 +811,12 @@ Socket.prototype.destroy = function(exception) { timers.unenroll(this); - if (this.server) { + if (this.server && !this.destroyed) { this.server.connections--; } // FIXME Bug when this.fd == 0 - if (typeof this.fd == 'number') { + if (typeof this.fd === 'number') { debug('close ' + this.fd); close(this.fd); this.fd = null; @@ -802,6 +825,8 @@ Socket.prototype.destroy = function(exception) { self.emit('close', exception ? true : false); }); } + + this.destroyed = true; }; @@ -875,7 +900,7 @@ function Server(/* [ options, ] listener */) { self.watcher.stop(); } - while (self.fd) { + while (typeof self.fd === 'number') { try { var peerInfo = accept(self.fd); } catch (e) { @@ -984,7 +1009,7 @@ Server.prototype._rejectPending = function() { // server.listen(8000, '192.168.1.2'); Server.prototype.listen = function() { var self = this; - if (self.fd) throw new Error('Server already opened'); + if (typeof self.fd === 'number') throw new Error('Server already opened'); var lastArg = arguments[arguments.length - 1]; if (typeof lastArg == 'function') { @@ -1039,7 +1064,7 @@ Server.prototype.listen = function() { }; Server.prototype.listenFD = function(fd, type) { - if (this.fd) { + if (typeof this.fd === 'number') { throw new Error('Server already opened'); } @@ -1074,7 +1099,7 @@ Server.prototype._doListen = function() { // It could be that server.close() was called between the time the // original listen command was issued and this. Bail if that's the case. // See test/simple/test-net-eaddrinuse.js - if (typeof self.fd != 'number') return; + if (typeof self.fd !== 'number') return; try { listen(self.fd, self._backlog || 128); @@ -1096,7 +1121,7 @@ Server.prototype.address = function() { Server.prototype.close = function() { var self = this; - if (!self.fd) throw new Error('Not running'); + if (typeof self.fd !== 'number') throw new Error('Not running'); self.watcher.stop(); diff --git a/lib/os.js b/lib/os.js index 1106e056a4..d2ff550814 100644 --- a/lib/os.js +++ b/lib/os.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var binding = process.binding('os'); exports.hostname = binding.getHostname; diff --git a/lib/path.js b/lib/path.js index ccd1598f6d..59fc5b3216 100644 --- a/lib/path.js +++ b/lib/path.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var isWindows = process.platform === 'win32'; diff --git a/lib/querystring.js b/lib/querystring.js index 87c4391a55..aa433982a6 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Query String Utilities var QueryString = exports; diff --git a/lib/readline.js b/lib/readline.js index b44d27db54..abefa4b103 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Inspiration for this code comes from Salvatore Sanfilippo's linenoise. // http://github.com/antirez/linenoise // Reference: diff --git a/lib/repl.js b/lib/repl.js index 447192e950..75d09d7031 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + /* A repl library that you can include in your own code to get a runtime * interface to your program. * @@ -45,6 +66,9 @@ function resetContext() { for (var i in global) context[i] = global[i]; context.module = module; context.require = require; + context.global = context; + context.global.global = context; + for (var i in require.cache) delete require.cache[i]; } diff --git a/lib/stream.js b/lib/stream.js index c5fcd2a4c2..94368d6c60 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var events = require('events'); var util = require('util'); diff --git a/lib/string_decoder.js b/lib/string_decoder.js index 00a1bcb495..991b255e83 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var StringDecoder = exports.StringDecoder = function(encoding) { this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); if (this.encoding === 'utf8') { diff --git a/lib/sys.js b/lib/sys.js index ea831c33e7..cd5b142c13 100644 --- a/lib/sys.js +++ b/lib/sys.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var util = require('util'); var sysWarning; diff --git a/lib/timers.js b/lib/timers.js index 06229ed97f..d6fede1fa0 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var Timer = process.binding('timer').Timer; var L = require('_linklist'); var assert = require('assert').ok; diff --git a/lib/tls.js b/lib/tls.js index db6807e06c..3debbef389 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var crypto = require('crypto'); var util = require('util'); var net = require('net'); @@ -170,7 +191,11 @@ CryptoStream.prototype.end = function(d) { CryptoStream.prototype.destroySoon = function(err) { - return this.end(); + if (this.writable) { + this.end(); + } else { + this.destroy(); + } }; @@ -504,33 +529,49 @@ exports.createSecurePair = function(credentials, * Because it is also called everywhere, we also check if the connection has * completed negotiation and emit 'secure' from here if it has. */ -SecurePair.prototype._cycle = function() { +SecurePair.prototype._cycle = function(depth) { + depth = depth ? depth : 0; if (this._done) { return; } - // Make this function reentrant. - if (this._cycleLock) return; - this._cycleLock = true; - this._writeCalled = false; + if(depth == 0) this._writeCalled = false; var established = this._secureEstablished; - this.encrypted._pull(); - this.cleartext._pull(); - this.cleartext._push(); - this.encrypted._push(); + if (!this._cycleEncryptedPullLock) { + this._cycleEncryptedPullLock = true; + this.encrypted._pull(); + this._cycleEncryptedPullLock = false; + } + + if (!this._cycleCleartextPullLock) { + this._cycleCleartextPullLock = true; + this.cleartext._pull(); + this._cycleCleartextPullLock = false; + } - this._cycleLock = false; + if (!this._cycleCleartextPushLock) { + this._cycleCleartextPushLock = true; + this.cleartext._push(); + this._cycleCleartextPushLock = false; + } + + if (!this._cycleEncryptedPushLock) { + this._cycleEncryptedPushLock = true; + this.encrypted._push(); + this._cycleEncryptedPushLock = false; + } if (this._done) { return; } - if ((!established && this._secureEstablished) || this._writeCalled) { + if ((!established && this._secureEstablished) || + (depth == 0 && this._writeCalled)) { // If we were not established but now we are, let's cycle again. // Or if there is some data to write... - this._cycle(); + this._cycle(depth + 1); } }; diff --git a/lib/tty.js b/lib/tty.js index cba6372201..00ee9f6082 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var binding = process.binding('stdio'); diff --git a/lib/tty_posix.js b/lib/tty_posix.js index 0bb0eb840e..042c752580 100644 --- a/lib/tty_posix.js +++ b/lib/tty_posix.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var binding = process.binding('stdio'), net = require('net'), @@ -35,6 +56,12 @@ function ReadStream(fd) { if (!(this instanceof ReadStream)) return new ReadStream(fd); net.Socket.call(this, fd); + if (this._writeWatcher) { + this._writeWatcher.stop(); + this._writeWatcher = null; + } + this.writable = false; + var self = this, keypressListeners = this.listeners('keypress'); @@ -114,7 +141,7 @@ ReadStream.prototype._emitKey = function(s) { } } - if (s === '\r') { + if (s === '\r' || s === '\n') { // enter key.name = 'enter'; @@ -285,6 +312,12 @@ ReadStream.prototype._emitKey = function(s) { function WriteStream(fd) { if (!(this instanceof WriteStream)) return new WriteStream(fd); net.Socket.call(this, fd); + + if (this._readWatcher) { + this._readWatcher.stop(); + this._readWatcher = null; + } + this.readable = false; } inherits(WriteStream, net.Socket); exports.WriteStream = WriteStream; diff --git a/lib/tty_win32.js b/lib/tty_win32.js index 7aa137a094..7a5c9597de 100644 --- a/lib/tty_win32.js +++ b/lib/tty_win32.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var binding = process.binding('stdio'), Stream = require('stream').Stream, diff --git a/lib/url.js b/lib/url.js index f272551ac9..cbea2f0fc3 100644 --- a/lib/url.js +++ b/lib/url.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.parse = urlParse; exports.resolve = urlResolve; exports.resolveObject = urlResolveObject; @@ -7,9 +28,30 @@ exports.format = urlFormat; // compiled once on the first module load. var protocolPattern = /^([a-z0-9]+:)/, portPattern = /:[0-9]+$/, - nonHostChars = ['/', '?', ';', '#'], + delims = ['<', '>', '"', '\'', '`', /\s/], + unwise = ['{', '}', '|', '\\', '^', '~', '[', ']', '`'].concat(delims), + nonHostChars = ['/', '?', ';', '#'].concat(unwise), + hostnameMaxLen = 255, + hostnamePartPattern = /^[a-z0-9][a-z0-9A-Z-]{0,62}$/, + unsafeProtocol = { + 'javascript': true, + 'javascript:': true + }, hostlessProtocol = { + 'javascript': true, + 'javascript:': true, + 'file': true, + 'file:': true + }, + pathedProtocol = { + 'http': true, + 'https': true, + 'ftp': true, + 'gopher': true, 'file': true, + 'http:': true, + 'ftp:': true, + 'gopher:': true, 'file:': true }, slashedProtocol = { @@ -29,7 +71,7 @@ var protocolPattern = /^([a-z0-9]+:)/, function urlParse(url, parseQueryString, slashesDenoteHost) { if (url && typeof(url) === 'object' && url.href) return url; - var out = { href: url }, + var out = {}, rest = url; var proto = protocolPattern.exec(rest); @@ -50,6 +92,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) { out.slashes = true; } } + if (!hostlessProtocol[proto] && (slashes || (proto && !slashedProtocol[proto]))) { // there's a hostname. @@ -79,9 +122,36 @@ function urlParse(url, parseQueryString, slashesDenoteHost) { // we've indicated that there is a hostname, // so even if it's empty, it has to be present. out.hostname = out.hostname || ''; + + // validate a little. + if (out.hostname.length > hostnameMaxLen) { + out.hostname = ''; + } else { + var hostparts = out.hostname.split(/\./); + for (var i = 0, l = hostparts.length; i < l; i++) { + var part = hostparts[i]; + if (!part.match(hostnamePartPattern)) { + out.hostname = ''; + break; + } + } + } } // now rest is set to the post-host stuff. + // chop off any delim chars. + if (!unsafeProtocol[proto]) { + var chop = rest.length; + for (var i = 0, l = delims.length; i < l; i++) { + var c = rest.indexOf(delims[i]); + if (c !== -1) { + chop = Math.min(c, chop); + } + } + rest = rest.substr(0, chop); + } + + // chop off from the tail first. var hash = rest.indexOf('#'); if (hash !== -1) { @@ -99,9 +169,17 @@ function urlParse(url, parseQueryString, slashesDenoteHost) { rest = rest.slice(0, qm); } else if (parseQueryString) { // no query string, but parseQueryString still requested + out.search = ''; out.query = {}; } if (rest) out.pathname = rest; + if (slashedProtocol[proto] && + out.hostname && !out.pathname) { + out.pathname = '/'; + } + + // finally, reconstruct the href based on what has been validated. + out.href = urlFormat(out); return out; } @@ -123,13 +201,12 @@ function urlFormat(obj) { ) : false, pathname = obj.pathname || '', - search = obj.search || ( - obj.query && ('?' + ( - typeof(obj.query) === 'object' ? - querystring.stringify(obj.query) : - String(obj.query) - )) - ) || '', + query = obj.query && + ((typeof obj.query === 'object' && + Object.keys(obj.query).length) ? + querystring.stringify(obj.query) : + '') || '', + search = obj.search || (query && ('?' + query)) || '', hash = obj.hash || ''; if (protocol && protocol.substr(-1) !== ':') protocol += ':'; diff --git a/lib/util.js b/lib/util.js index aa8e132431..b824a71a71 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var events = require('events'); diff --git a/lib/vm.js b/lib/vm.js index 4f31e62caa..3ce71c9ca0 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var binding = process.binding('evals'); exports.Script = binding.Script; diff --git a/src/node.cc b/src/node.cc index ddca07b8cb..267d59332d 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1,4 +1,23 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. #include @@ -48,6 +67,7 @@ #include #include #include +#include #ifdef HAVE_OPENSSL # include #endif @@ -96,7 +116,6 @@ static ev_idle tick_spinner; static bool need_tick_cb; static Persistent tick_callback_sym; -static ev_async enable_debug; static ev_async eio_want_poll_notifier; static ev_async eio_done_poll_notifier; static ev_idle eio_poller; @@ -1273,7 +1292,7 @@ static void ReportException(TryCatch &try_catch, bool show_line) { } // Executes a str within the current v8 context. -Local ExecuteString(Local source, Local filename) { +Local ExecuteString(Handle source, Handle filename) { HandleScope scope; TryCatch try_catch; @@ -1761,6 +1780,7 @@ static void DebugBreakMessageHandler(const Debug::Message& message) { // debug-agent.cc of v8/src when a new session is created } + Persistent binding_cache; static Handle Binding(const Arguments& args) { @@ -2052,8 +2072,8 @@ static void Load(int argc, char *argv[]) { TryCatch try_catch; - Local f_value = ExecuteString(String::New(MainSource()), - String::New("node.js")); + Local f_value = ExecuteString(MainSource(), + IMMUTABLE_STRING("node.js")); if (try_catch.HasCaught()) { ReportException(try_catch, true); exit(10); @@ -2190,13 +2210,6 @@ static void SignalExit(int signal) { } -static void EnableDebugSignalHandler(int signal) { - // can't do much here, marshal this back into the main thread where we'll - // enable the debugger. - ev_async_send(EV_DEFAULT_UC_ &enable_debug); -} - - static void EnableDebug(bool wait_connect) { // Start the debug thread and it's associated TCP server on port 5858. bool r = Debug::EnableAgent("node " NODE_VERSION, debug_port); @@ -2217,10 +2230,22 @@ static void EnableDebug(bool wait_connect) { } -static void EnableDebug2(EV_P_ ev_async *watcher, int revents) { - assert(watcher == &enable_debug); - assert(revents == EV_ASYNC); - EnableDebug(false); +static volatile bool hit_signal; + + +static void EnableDebugSignalHandler(int signal) { + // This is signal safe. + hit_signal = true; + v8::Debug::DebugBreak(); +} + + +static void DebugSignalCB(const Debug::EventDetails& details) { + if (hit_signal && details.GetEvent() == v8::Break) { + hit_signal = false; + fprintf(stderr, "Hit SIGUSR1 - starting debugger agent.\n"); + EnableDebug(false); + } } @@ -2357,9 +2382,7 @@ int Start(int argc, char *argv[]) { } else { #ifdef __POSIX__ RegisterSignalHandler(SIGUSR1, EnableDebugSignalHandler); - ev_async_init(&enable_debug, EnableDebug2); - ev_async_start(EV_DEFAULT_UC_ &enable_debug); - ev_unref(EV_DEFAULT_UC); + Debug::SetDebugEventListener2(DebugSignalCB); #endif // __POSIX__ } diff --git a/src/node.d b/src/node.d index bc52adf698..b81930c813 100644 --- a/src/node.d +++ b/src/node.d @@ -1,3 +1,25 @@ +/* Copyright Joyent, Inc. and other Node contributors. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + /* * This is the DTrace library file for the node provider, which includes * the necessary translators to get from the args[] to something useful. diff --git a/src/node.h b/src/node.h index 434796514d..f232704895 100644 --- a/src/node.h +++ b/src/node.h @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef SRC_NODE_H_ #define SRC_NODE_H_ @@ -38,7 +58,7 @@ int Start (int argc, char *argv[]); do { \ v8::Local __callback##_SIG = v8::Signature::New(templ); \ v8::Local __callback##_TEM = \ - FunctionTemplate::New(callback, v8::Handle(), \ + v8::FunctionTemplate::New(callback, v8::Handle(), \ __callback##_SIG); \ templ->PrototypeTemplate()->Set(v8::String::NewSymbol(name), \ __callback##_TEM); \ diff --git a/src/node.js b/src/node.js index 6b0aa6f53e..7308810955 100644 --- a/src/node.js +++ b/src/node.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Hello, and welcome to hacking node.js! // // This file is invoked by node::Load in src/node.cc, and responsible for @@ -71,12 +92,9 @@ }; startup.globalConsole = function() { - global.__defineGetter__('console', function() { - return NativeModule.require('console'); - }); + global.console = NativeModule.require('console'); }; - startup._lazyConstants = null; startup.lazyConstants = function() { @@ -126,32 +144,29 @@ }; startup.processStdio = function() { - var stdout, stdin; - - process.__defineGetter__('stdout', function() { - if (stdout) return stdout; - - var binding = process.binding('stdio'), - net = NativeModule.require('net'), - fs = NativeModule.require('fs'), - tty = NativeModule.require('tty'), - fd = binding.stdoutFD; - - if (binding.isatty(fd)) { - stdout = new tty.WriteStream(fd); - } else if (binding.isStdoutBlocking()) { - stdout = new fs.WriteStream(null, {fd: fd}); - } else { - stdout = new net.Stream(fd); - // FIXME Should probably have an option in net.Stream to create a - // stream from an existing fd which is writable only. But for now - // we'll just add this hack and set the `readable` member to false. - // Test: ./node test/fixtures/echo.js < /etc/passwd - stdout.readable = false; - } + var binding = process.binding('stdio'), + net = NativeModule.require('net'), + fs = NativeModule.require('fs'), + tty = NativeModule.require('tty'); + + // process.stdout + + var fd = binding.stdoutFD; + + if (binding.isatty(fd)) { + process.stdout = new tty.WriteStream(fd); + } else if (binding.isStdoutBlocking()) { + process.stdout = new fs.WriteStream(null, {fd: fd}); + } else { + process.stdout = new net.Stream(fd); + // FIXME Should probably have an option in net.Stream to create a + // stream from an existing fd which is writable only. But for now + // we'll just add this hack and set the `readable` member to false. + // Test: ./node test/fixtures/echo.js < /etc/passwd + process.stdout.readable = false; + } - return stdout; - }); + // process.stderr var events = NativeModule.require('events'); var stderr = process.stderr = new events.EventEmitter(); @@ -160,26 +175,18 @@ stderr.write = process.binding('stdio').writeError; stderr.end = stderr.destroy = stderr.destroySoon = function() { }; - process.__defineGetter__('stdin', function() { - if (stdin) return stdin; + // process.stdin - var binding = process.binding('stdio'), - net = NativeModule.require('net'), - fs = NativeModule.require('fs'), - tty = NativeModule.require('tty'), - fd = binding.openStdin(); + var fd = binding.openStdin(); - if (binding.isatty(fd)) { - stdin = new tty.ReadStream(fd); - } else if (binding.isStdinBlocking()) { - stdin = new fs.ReadStream(null, {fd: fd}); - } else { - stdin = new net.Stream(fd); - stdin.readable = true; - } - - return stdin; - }); + if (binding.isatty(fd)) { + process.stdin = new tty.ReadStream(fd); + } else if (binding.isStdinBlocking()) { + process.stdin = new fs.ReadStream(null, {fd: fd}); + } else { + process.stdin = new net.Stream(fd); + process.stdin.readable = true; + } process.openStdin = function() { process.stdin.resume(); diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 44a6750053..17e49f9ff4 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_buffer.h b/src/node_buffer.h index 9a0e1d2401..91f93dc1d0 100644 --- a/src/node_buffer.h +++ b/src/node_buffer.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_BUFFER_H_ #define NODE_BUFFER_H_ @@ -63,7 +84,7 @@ class Buffer : public ObjectWrap { } static inline size_t Length(Buffer *b) { - return Buffer::Length(b); + return Buffer::Length(b->handle_); } diff --git a/src/node_cares.cc b/src/node_cares.cc index 0cffbda34d..327fbd4678 100644 --- a/src/node_cares.cc +++ b/src/node_cares.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include @@ -216,6 +237,7 @@ static void ResolveError(Persistent &cb, int status) { Local obj = e->ToObject(); obj->Set(String::NewSymbol("errno"), Integer::New(status)); + obj->Set(String::NewSymbol("code"), code); TryCatch try_catch; diff --git a/src/node_cares.h b/src/node_cares.h index 62244d493c..0af763e309 100644 --- a/src/node_cares.h +++ b/src/node_cares.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_CARES_H_ #define NODE_CARES_H_ diff --git a/src/node_child_process.cc b/src/node_child_process.cc index 413c28266d..759c901203 100644 --- a/src/node_child_process.cc +++ b/src/node_child_process.cc @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include @@ -327,6 +347,36 @@ int ChildProcess::Spawn(const char *file, _exit(127); } + if (custom_fds[0] == -1) { + close(stdin_pipe[1]); // close write end + dup2(stdin_pipe[0], STDIN_FILENO); + } else { + ResetFlags(custom_fds[0]); + dup2(custom_fds[0], STDIN_FILENO); + } + + if (custom_fds[1] == -1) { + close(stdout_pipe[0]); // close read end + dup2(stdout_pipe[1], STDOUT_FILENO); + } else { + ResetFlags(custom_fds[1]); + dup2(custom_fds[1], STDOUT_FILENO); + } + + if (custom_fds[2] == -1) { + close(stderr_pipe[0]); // close read end + dup2(stderr_pipe[1], STDERR_FILENO); + } else { + ResetFlags(custom_fds[2]); + dup2(custom_fds[2], STDERR_FILENO); + } + + if (strlen(cwd) && chdir(cwd)) { + perror("chdir()"); + _exit(127); + } + + static char buf[PATH_MAX + 1]; int gid = -1; @@ -380,34 +430,6 @@ int ChildProcess::Spawn(const char *file, } - if (custom_fds[0] == -1) { - close(stdin_pipe[1]); // close write end - dup2(stdin_pipe[0], STDIN_FILENO); - } else { - ResetFlags(custom_fds[0]); - dup2(custom_fds[0], STDIN_FILENO); - } - - if (custom_fds[1] == -1) { - close(stdout_pipe[0]); // close read end - dup2(stdout_pipe[1], STDOUT_FILENO); - } else { - ResetFlags(custom_fds[1]); - dup2(custom_fds[1], STDOUT_FILENO); - } - - if (custom_fds[2] == -1) { - close(stderr_pipe[0]); // close read end - dup2(stderr_pipe[1], STDERR_FILENO); - } else { - ResetFlags(custom_fds[2]); - dup2(custom_fds[2], STDERR_FILENO); - } - - if (strlen(cwd) && chdir(cwd)) { - perror("chdir()"); - _exit(127); - } environ = env; diff --git a/src/node_child_process.h b/src/node_child_process.h index c77f68ad8f..6090c47ff9 100644 --- a/src/node_child_process.h +++ b/src/node_child_process.h @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_CHILD_PROCESS_H_ #define NODE_CHILD_PROCESS_H_ diff --git a/src/node_child_process_win32.cc b/src/node_child_process_win32.cc index 2734f25092..9027d96442 100644 --- a/src/node_child_process_win32.cc +++ b/src/node_child_process_win32.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_config.h.in b/src/node_config.h.in index 94b9b3cffd..18d1d7504a 100644 --- a/src/node_config.h.in +++ b/src/node_config.h.in @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_CONFIG_H #define NODE_CONFIG_H diff --git a/src/node_constants.cc b/src/node_constants.cc index 7ea372223e..ecb34a6b78 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_constants.h b/src/node_constants.h index 1f02c51beb..ac7dce00f6 100644 --- a/src/node_constants.h +++ b/src/node_constants.h @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef SRC_CONSTANTS_H_ #define SRC_CONSTANTS_H_ diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 22147806fd..46bd4b76c8 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include @@ -16,6 +37,11 @@ # define OPENSSL_CONST #endif +#define ASSERT_IS_STRING_OR_BUFFER(val) \ + if (!val->IsString() && !Buffer::HasInstance(val)) { \ + return ThrowException(Exception::TypeError(String::New("Not a string or buffer"))); \ + } + namespace node { namespace crypto { @@ -297,6 +323,7 @@ Handle SecureContext::AddCACert(const Arguments& args) { if (!x509) return False(); X509_STORE_add_cert(sc->ca_store_, x509); + SSL_CTX_add_client_CA(sc->ctx_, x509); X509_free(x509); @@ -1419,6 +1446,7 @@ class Cipher : public ObjectWrap { "Must give cipher-type, key"))); } + ASSERT_IS_STRING_OR_BUFFER(args[1]); ssize_t key_buf_len = DecodeBytes(args[1], BINARY); if (key_buf_len < 0) { @@ -1455,6 +1483,8 @@ class Cipher : public ObjectWrap { return ThrowException(Exception::Error(String::New( "Must give cipher-type, key, and iv as argument"))); } + + ASSERT_IS_STRING_OR_BUFFER(args[1]); ssize_t key_len = DecodeBytes(args[1], BINARY); if (key_len < 0) { @@ -1462,6 +1492,7 @@ class Cipher : public ObjectWrap { return ThrowException(exception); } + ASSERT_IS_STRING_OR_BUFFER(args[2]); ssize_t iv_len = DecodeBytes(args[2], BINARY); if (iv_len < 0) { @@ -1491,12 +1522,13 @@ class Cipher : public ObjectWrap { return args.This(); } - static Handle CipherUpdate(const Arguments& args) { Cipher *cipher = ObjectWrap::Unwrap(args.This()); HandleScope scope; + ASSERT_IS_STRING_OR_BUFFER(args[0]); + enum encoding enc = ParseEncoding(args[1]); ssize_t len = DecodeBytes(args[0], enc); @@ -1780,6 +1812,7 @@ class Decipher : public ObjectWrap { "Must give cipher-type, key as argument"))); } + ASSERT_IS_STRING_OR_BUFFER(args[1]); ssize_t key_len = DecodeBytes(args[1], BINARY); if (key_len < 0) { @@ -1817,6 +1850,7 @@ class Decipher : public ObjectWrap { "Must give cipher-type, key, and iv as argument"))); } + ASSERT_IS_STRING_OR_BUFFER(args[1]); ssize_t key_len = DecodeBytes(args[1], BINARY); if (key_len < 0) { @@ -1824,6 +1858,7 @@ class Decipher : public ObjectWrap { return ThrowException(exception); } + ASSERT_IS_STRING_OR_BUFFER(args[2]); ssize_t iv_len = DecodeBytes(args[2], BINARY); if (iv_len < 0) { @@ -1858,6 +1893,8 @@ class Decipher : public ObjectWrap { Decipher *cipher = ObjectWrap::Unwrap(args.This()); + ASSERT_IS_STRING_OR_BUFFER(args[0]); + ssize_t len = DecodeBytes(args[0], BINARY); if (len < 0) { return ThrowException(Exception::Error(String::New( @@ -2159,6 +2196,7 @@ class Hmac : public ObjectWrap { "Must give hashtype string as argument"))); } + ASSERT_IS_STRING_OR_BUFFER(args[1]); ssize_t len = DecodeBytes(args[1], BINARY); if (len < 0) { @@ -2188,6 +2226,7 @@ class Hmac : public ObjectWrap { HandleScope scope; + ASSERT_IS_STRING_OR_BUFFER(args[0]); enum encoding enc = ParseEncoding(args[1]); ssize_t len = DecodeBytes(args[0], enc); @@ -2335,6 +2374,7 @@ class Hash : public ObjectWrap { Hash *hash = ObjectWrap::Unwrap(args.This()); + ASSERT_IS_STRING_OR_BUFFER(args[0]); enum encoding enc = ParseEncoding(args[1]); ssize_t len = DecodeBytes(args[0], enc); @@ -2526,6 +2566,7 @@ class Sign : public ObjectWrap { HandleScope scope; + ASSERT_IS_STRING_OR_BUFFER(args[0]); enum encoding enc = ParseEncoding(args[1]); ssize_t len = DecodeBytes(args[0], enc); @@ -2572,6 +2613,7 @@ class Sign : public ObjectWrap { md_len = 8192; // Maximum key size is 8192 bits md_value = new unsigned char[md_len]; + ASSERT_IS_STRING_OR_BUFFER(args[0]); ssize_t len = DecodeBytes(args[0], BINARY); if (len < 0) { @@ -2739,6 +2781,7 @@ class Verify : public ObjectWrap { Verify *verify = ObjectWrap::Unwrap(args.This()); + ASSERT_IS_STRING_OR_BUFFER(args[0]); enum encoding enc = ParseEncoding(args[1]); ssize_t len = DecodeBytes(args[0], enc); @@ -2777,6 +2820,7 @@ class Verify : public ObjectWrap { Verify *verify = ObjectWrap::Unwrap(args.This()); + ASSERT_IS_STRING_OR_BUFFER(args[0]); ssize_t klen = DecodeBytes(args[0], BINARY); if (klen < 0) { @@ -2788,7 +2832,7 @@ class Verify : public ObjectWrap { ssize_t kwritten = DecodeWrite(kbuf, klen, args[0], BINARY); assert(kwritten == klen); - + ASSERT_IS_STRING_OR_BUFFER(args[1]); ssize_t hlen = DecodeBytes(args[1], BINARY); if (hlen < 0) { diff --git a/src/node_crypto.h b/src/node_crypto.h index 4b019463ae..539353a1cf 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef SRC_NODE_CRYPTO_H_ #define SRC_NODE_CRYPTO_H_ diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index ca7495e2f7..6481267344 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #ifdef HAVE_DTRACE diff --git a/src/node_dtrace.h b/src/node_dtrace.h index a3f75d0a0a..3a916be06d 100644 --- a/src/node_dtrace.h +++ b/src/node_dtrace.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_DTRACE_H_ #define NODE_DTRACE_H_ diff --git a/src/node_events.cc b/src/node_events.cc index 366bd091e4..8c0b5a6483 100644 --- a/src/node_events.cc +++ b/src/node_events.cc @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_events.h b/src/node_events.h index cb4391ac4a..fc87189374 100644 --- a/src/node_events.h +++ b/src/node_events.h @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef SRC_EVENTS_H_ #define SRC_EVENTS_H_ diff --git a/src/node_extensions.cc b/src/node_extensions.cc index 776bb40af8..fb46a1d930 100644 --- a/src/node_extensions.cc +++ b/src/node_extensions.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include "node.h" #include "node_version.h" diff --git a/src/node_extensions.h b/src/node_extensions.h index 131d34e6f1..dc50a52a2a 100644 --- a/src/node_extensions.h +++ b/src/node_extensions.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + NODE_EXT_LIST_START NODE_EXT_LIST_ITEM(node_buffer) diff --git a/src/node_file.cc b/src/node_file.cc index 9f0b8437c6..e4d00af073 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include #include diff --git a/src/node_file.h b/src/node_file.h index 7baa469912..6ac5a31e18 100644 --- a/src/node_file.h +++ b/src/node_file.h @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef SRC_FILE_H_ #define SRC_FILE_H_ diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 62dea03fd5..7d1ca422d9 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_http_parser.h b/src/node_http_parser.h index 78ba175eed..456a000831 100644 --- a/src/node_http_parser.h +++ b/src/node_http_parser.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_HTTP_PARSER #define NODE_HTTP_PARSER diff --git a/src/node_idle_watcher.cc b/src/node_idle_watcher.cc index 9ae1c4bc5f..293714a003 100644 --- a/src/node_idle_watcher.cc +++ b/src/node_idle_watcher.cc @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_idle_watcher.h b/src/node_idle_watcher.h index 42298257cd..c1c7bd21ab 100644 --- a/src/node_idle_watcher.h +++ b/src/node_idle_watcher.h @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_IDLE_H_ #define NODE_IDLE_H_ diff --git a/src/node_io_watcher.cc b/src/node_io_watcher.cc index 7e516155ab..4854a8fa9a 100644 --- a/src/node_io_watcher.cc +++ b/src/node_io_watcher.cc @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_io_watcher.h b/src/node_io_watcher.h index 06d431ece9..dd5bbaee36 100644 --- a/src/node_io_watcher.h +++ b/src/node_io_watcher.h @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_IO_H_ #define NODE_IO_H_ diff --git a/src/node_javascript.cc b/src/node_javascript.cc index 95005eeb15..f1ec3355df 100644 --- a/src/node_javascript.cc +++ b/src/node_javascript.cc @@ -1,6 +1,28 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include "node.h" #include "node_natives.h" +#include "node_string.h" #include #include @@ -8,8 +30,8 @@ using namespace v8; namespace node { -const char* MainSource() { - return node_native; +Handle MainSource() { + return BUILTIN_ASCII_ARRAY(node_native, sizeof(node_native)-1); } void DefineJavaScript(v8::Handle target) { @@ -18,14 +40,10 @@ void DefineJavaScript(v8::Handle target) { for (int i = 0; natives[i].name; i++) { if (natives[i].source != node_native) { Local name = String::New(natives[i].name); - // TODO: Use ExternalAsciiStringResource for source - // Might need to do some assertions in js2c about chars > 128 - Local source = String::New(natives[i].source); + Handle source = BUILTIN_ASCII_ARRAY(natives[i].source, natives[i].source_len); target->Set(name, source); } } } - - } // namespace node diff --git a/src/node_javascript.h b/src/node_javascript.h index 4df3bfa31e..58e5010d65 100644 --- a/src/node_javascript.h +++ b/src/node_javascript.h @@ -1,8 +1,29 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include namespace node { void DefineJavaScript(v8::Handle target); -const char* MainSource(); +v8::Handle MainSource(); } // namespace node diff --git a/src/node_main.cc b/src/node_main.cc index 9a241bf4a8..3100149868 100644 --- a/src/node_main.cc +++ b/src/node_main.cc @@ -1,4 +1,23 @@ -// Copyright 2010 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. #include diff --git a/src/node_net.cc b/src/node_net.cc index 5a2d308266..a0bda02035 100644 --- a/src/node_net.cc +++ b/src/node_net.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_net.h b/src/node_net.h index 97a978dbc6..b57b4967aa 100644 --- a/src/node_net.h +++ b/src/node_net.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_NET #define NODE_NET diff --git a/src/node_object_wrap.h b/src/node_object_wrap.h index fba40fb2c6..b10755498a 100644 --- a/src/node_object_wrap.h +++ b/src/node_object_wrap.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef object_wrap_h #define object_wrap_h diff --git a/src/node_os.cc b/src/node_os.cc index 643eb69ffb..1b985276c4 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_os.h b/src/node_os.h index dcc705c71d..596d268e70 100644 --- a/src/node_os.h +++ b/src/node_os.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef node_os_h #define node_os_h diff --git a/src/node_provider.d b/src/node_provider.d index 2d96114a2b..9a26dbfbe8 100644 --- a/src/node_provider.d +++ b/src/node_provider.d @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + /* * DTrace provider for node.js. */ diff --git a/src/node_root_certs.h b/src/node_root_certs.h index fe31c7e354..c82fde8f00 100644 --- a/src/node_root_certs.h +++ b/src/node_root_certs.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef SRC_NODE_ROOT_CERTS_H_ #define SRC_NODE_ROOT_CERTS_H_ diff --git a/src/node_script.cc b/src/node_script.cc index 279d26f405..49446ccbb3 100644 --- a/src/node_script.cc +++ b/src/node_script.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include #include diff --git a/src/node_script.h b/src/node_script.h index 364bd18ca8..78ebc8e463 100644 --- a/src/node_script.h +++ b/src/node_script.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef node_script_h #define node_script_h diff --git a/src/node_signal_watcher.cc b/src/node_signal_watcher.cc index b722280831..3337ec2697 100644 --- a/src/node_signal_watcher.cc +++ b/src/node_signal_watcher.cc @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_signal_watcher.h b/src/node_signal_watcher.h index 9baeb0535e..9c14967656 100644 --- a/src/node_signal_watcher.h +++ b/src/node_signal_watcher.h @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_SIGNAL_WATCHER_H_ #define NODE_SIGNAL_WATCHER_H_ diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc index bbc4fdfbd4..340f387354 100644 --- a/src/node_stat_watcher.cc +++ b/src/node_stat_watcher.cc @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_stat_watcher.h b/src/node_stat_watcher.h index 078a11f62d..af02f0b06b 100644 --- a/src/node_stat_watcher.h +++ b/src/node_stat_watcher.h @@ -1,4 +1,24 @@ -// Copyright 2009 Ryan Dahl +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_STAT_WATCHER_H_ #define NODE_STAT_WATCHER_H_ diff --git a/src/node_stdio.cc b/src/node_stdio.cc index c601478d6c..00bdd86506 100644 --- a/src/node_stdio.cc +++ b/src/node_stdio.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include @@ -295,7 +316,7 @@ void Stdio::Initialize(v8::Handle target) { NODE_SET_METHOD(target, "isStdinBlocking", IsStdinBlocking); NODE_SET_METHOD(target, "setRawMode", SetRawMode); NODE_SET_METHOD(target, "getWindowSize", GetWindowSize); - NODE_SET_METHOD(target, "setWindowSize", GetWindowSize); + NODE_SET_METHOD(target, "setWindowSize", SetWindowSize); NODE_SET_METHOD(target, "isatty", IsATTY); NODE_SET_METHOD(target, "openpty", OpenPTY); diff --git a/src/node_stdio.h b/src/node_stdio.h index 97a6140de5..d13ac01bc9 100644 --- a/src/node_stdio.h +++ b/src/node_stdio.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef node_stdio_h #define node_stdio_h diff --git a/src/node_stdio_win32.cc b/src/node_stdio_win32.cc index 8da6f104f1..76661de1a1 100644 --- a/src/node_stdio_win32.cc +++ b/src/node_stdio_win32.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/node_string.cc b/src/node_string.cc new file mode 100644 index 0000000000..f8dfbdfa31 --- /dev/null +++ b/src/node_string.cc @@ -0,0 +1,39 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +#include "node_string.h" + +namespace node { + +using namespace v8; + +Handle ImmutableAsciiSource::CreateFromLiteral( + const char *string_literal, + size_t length) { + HandleScope scope; + + Local ret = String::NewExternal(new ImmutableAsciiSource( + string_literal, + length)); + return scope.Close(ret); +} + +} diff --git a/src/node_string.h b/src/node_string.h new file mode 100644 index 0000000000..5625f22dbe --- /dev/null +++ b/src/node_string.h @@ -0,0 +1,63 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +#ifndef SRC_NODE_STRING_H_ +#define SRC_NODE_STRING_H_ + +#include + +namespace node { + +#define IMMUTABLE_STRING(string_literal) \ + ::node::ImmutableAsciiSource::CreateFromLiteral( \ + string_literal "", sizeof(string_literal) - 1) +#define BUILTIN_ASCII_ARRAY(array, len) \ + ::node::ImmutableAsciiSource::CreateFromLiteral(array, len) + +class ImmutableAsciiSource : public v8::String::ExternalAsciiStringResource { + public: + static v8::Handle CreateFromLiteral(const char *string_literal, + size_t length); + + ImmutableAsciiSource(const char *src, size_t src_len) + : buffer_(src), + buf_len_(src_len) { + } + + ~ImmutableAsciiSource() { + } + + const char *data() const { + return buffer_; + } + + size_t length() const { + return buf_len_; + } + + private: + const char *buffer_; + size_t buf_len_; +}; + +} // namespace node + +#endif // SRC_NODE_STRING_H_ diff --git a/src/node_timer.cc b/src/node_timer.cc index f7dfafe971..50902895e7 100644 --- a/src/node_timer.cc +++ b/src/node_timer.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include #include diff --git a/src/node_timer.h b/src/node_timer.h index e945cb6bcf..8e1c6a5126 100644 --- a/src/node_timer.h +++ b/src/node_timer.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef SRC_NODE_TIMER_H_ #define SRC_NODE_TIMER_H_ diff --git a/src/node_version.h b/src/node_version.h index 119e1e9955..56c0d63b9f 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include "node_config.h" diff --git a/src/platform.h b/src/platform.h index a2fbe3019e..d31c9a415a 100644 --- a/src/platform.h +++ b/src/platform.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_PLATFORM_H_ #define NODE_PLATFORM_H_ diff --git a/src/platform_cygwin.cc b/src/platform_cygwin.cc index 3d65425266..7dc610a41d 100644 --- a/src/platform_cygwin.cc +++ b/src/platform_cygwin.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include "node.h" #include "platform.h" diff --git a/src/platform_darwin.cc b/src/platform_darwin.cc index f60d119b99..a2149b4c77 100644 --- a/src/platform_darwin.cc +++ b/src/platform_darwin.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include "node.h" #include "platform.h" diff --git a/src/platform_freebsd.cc b/src/platform_freebsd.cc index 0b48d45ea3..2bb373f061 100644 --- a/src/platform_freebsd.cc +++ b/src/platform_freebsd.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include "node.h" #include "platform.h" diff --git a/src/platform_linux.cc b/src/platform_linux.cc index cf9742b716..7602c92826 100644 --- a/src/platform_linux.cc +++ b/src/platform_linux.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include "node.h" #include "platform.h" diff --git a/src/platform_none.cc b/src/platform_none.cc index 753fc038b8..e6d595bda0 100644 --- a/src/platform_none.cc +++ b/src/platform_none.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include "node.h" #include "platform.h" diff --git a/src/platform_openbsd.cc b/src/platform_openbsd.cc index e195fdbe95..1583647ef0 100644 --- a/src/platform_openbsd.cc +++ b/src/platform_openbsd.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include "node.h" #include "platform.h" diff --git a/src/platform_sunos.cc b/src/platform_sunos.cc index 96133259bb..38d4ea4e68 100644 --- a/src/platform_sunos.cc +++ b/src/platform_sunos.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include "node.h" #include "platform.h" diff --git a/src/platform_win32.cc b/src/platform_win32.cc index f963a94f2f..a39b06cac4 100644 --- a/src/platform_win32.cc +++ b/src/platform_win32.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #include #include diff --git a/src/platform_win32.h b/src/platform_win32.h index 66e1194b53..caca03dbf1 100644 --- a/src/platform_win32.h +++ b/src/platform_win32.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_PLATFORM_WIN32_H_ #define NODE_PLATFORM_WIN32_H_ diff --git a/src/platform_win32_winsock.cc b/src/platform_win32_winsock.cc index df193d9c86..3cbf6c66c2 100644 --- a/src/platform_win32_winsock.cc +++ b/src/platform_win32_winsock.cc @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + /* * This file contains all winsock-related stuff. * Socketpair() for winsock is implemented here. diff --git a/src/platform_win32_winsock.h b/src/platform_win32_winsock.h index f78329daca..0db6e0798b 100644 --- a/src/platform_win32_winsock.h +++ b/src/platform_win32_winsock.h @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + #ifndef NODE_PLATFORM_WIN32_WINSOCK_H_ #define NODE_PLATFORM_WIN32_WINSOCK_H_ diff --git a/test/common.js b/test/common.js index 0677253864..bf0a43f9e7 100644 --- a/test/common.js +++ b/test/common.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var path = require('path'); var assert = require('assert'); diff --git a/test/disabled/test-cat.js b/test/disabled/test-cat.js index e3784254be..7339fca368 100644 --- a/test/disabled/test-cat.js +++ b/test/disabled/test-cat.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common.js'); var assert = require('assert'); var http = require('http'); diff --git a/test/disabled/test-child-process-uid-gid.js b/test/disabled/test-child-process-uid-gid.js index b63e2255d2..021c16d030 100644 --- a/test/disabled/test-child-process-uid-gid.js +++ b/test/disabled/test-child-process-uid-gid.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var assert = require("assert"); var spawn = require("child_process").spawn; var fs = require('fs'); diff --git a/test/disabled/test-dns.js b/test/disabled/test-dns.js index 318b5222d7..a7d6117830 100644 --- a/test/disabled/test-dns.js +++ b/test/disabled/test-dns.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/disabled/test-eio-race3.js b/test/disabled/test-eio-race3.js index 820128ae46..fa5ea97026 100644 --- a/test/disabled/test-eio-race3.js +++ b/test/disabled/test-eio-race3.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + /* XXX Can this test be modified to not call the now-removed wait()? */ var common = require('../common'); diff --git a/test/disabled/test-fs-sendfile.js b/test/disabled/test-fs-sendfile.js index 01cab5ed94..809e68fc30 100644 --- a/test/disabled/test-fs-sendfile.js +++ b/test/disabled/test-fs-sendfile.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-http-agent2.js b/test/disabled/test-http-agent2.js similarity index 50% rename from test/simple/test-http-agent2.js rename to test/disabled/test-http-agent2.js index eed1cb90d0..0a1612d382 100644 --- a/test/simple/test-http-agent2.js +++ b/test/disabled/test-http-agent2.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/disabled/test-http-big-proxy-responses.js b/test/disabled/test-http-big-proxy-responses.js index 6cf28a729c..74ecf28071 100644 --- a/test/disabled/test-http-big-proxy-responses.js +++ b/test/disabled/test-http-big-proxy-responses.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var util = require('util'), diff --git a/test/disabled/test-http-head-request.js b/test/disabled/test-http-head-request.js index e2ad9ef277..045c9dc354 100644 --- a/test/disabled/test-http-head-request.js +++ b/test/disabled/test-http-head-request.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/disabled/test-http-stress.js b/test/disabled/test-http-stress.js index d424554bf3..34ed955251 100644 --- a/test/disabled/test-http-stress.js +++ b/test/disabled/test-http-stress.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/disabled/test-http-tls.js b/test/disabled/test-http-tls.js index 4c720b42d0..bbf08f314f 100644 --- a/test/disabled/test-http-tls.js +++ b/test/disabled/test-http-tls.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/disabled/test-https-loop-to-google.js b/test/disabled/test-https-loop-to-google.js index dd3bae8c62..ae9e1999eb 100644 --- a/test/disabled/test-https-loop-to-google.js +++ b/test/disabled/test-https-loop-to-google.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Failing test for https // Will fail with "socket hang up" for 4 out of 10 requests diff --git a/test/disabled/test-idle-watcher.js b/test/disabled/test-idle-watcher.js index 00a4f2928f..86cebe4147 100644 --- a/test/disabled/test-idle-watcher.js +++ b/test/disabled/test-idle-watcher.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/disabled/test-net-fd-passing.js b/test/disabled/test-net-fd-passing.js index 18d685366d..cda9f86a51 100644 --- a/test/disabled/test-net-fd-passing.js +++ b/test/disabled/test-net-fd-passing.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/disabled/test-net-tls-pummel.js b/test/disabled/test-net-tls-pummel.js index c3ba57fdb4..2761115117 100644 --- a/test/disabled/test-net-tls-pummel.js +++ b/test/disabled/test-net-tls-pummel.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/disabled/test-net-tls.js b/test/disabled/test-net-tls.js index ff1b819ce1..4214a68e6e 100644 --- a/test/disabled/test-net-tls.js +++ b/test/disabled/test-net-tls.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var fs = require('fs'); diff --git a/test/disabled/test-process-title.js b/test/disabled/test-process-title.js index c7c96687f7..9bffdc3074 100644 --- a/test/disabled/test-process-title.js +++ b/test/disabled/test-process-title.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; diff --git a/test/disabled/test-readline.js b/test/disabled/test-readline.js index 05a8e800fd..a0541aab07 100644 --- a/test/disabled/test-readline.js +++ b/test/disabled/test-readline.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Can't test this when 'make test' doesn't assign a tty to the stdout. // Yet another use-case for require('tty').spawn ? var common = require('../common'); diff --git a/test/disabled/test-remote-module-loading.js b/test/disabled/test-remote-module-loading.js index f5bb11c8db..5ce7bc1ed6 100644 --- a/test/disabled/test-remote-module-loading.js +++ b/test/disabled/test-remote-module-loading.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/disabled/test-setuidgid.js b/test/disabled/test-setuidgid.js index a2d24ae913..f5a7821118 100644 --- a/test/disabled/test-setuidgid.js +++ b/test/disabled/test-setuidgid.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Requires special privlages var common = require('../common'); var assert = require('assert'); diff --git a/test/disabled/test-tls-large-push.js b/test/disabled/test-tls-large-push.js index cb96c04194..11f9a0d80d 100644 --- a/test/disabled/test-tls-large-push.js +++ b/test/disabled/test-tls-large-push.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Server sends a large string. Client counts bytes and pauses every few // seconds. Makes sure that pause and resume work properly. var common = require('../common'); diff --git a/test/disabled/test-tls-server.js b/test/disabled/test-tls-server.js index 363a530506..0f2149883b 100644 --- a/test/disabled/test-tls-server.js +++ b/test/disabled/test-tls-server.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Example of new TLS API. Test with: // // $> openssl s_client -connect localhost:12346 \ diff --git a/test/disabled/test-tty-stdio.js b/test/disabled/test-tty-stdio.js new file mode 100644 index 0000000000..e41b68c1c8 --- /dev/null +++ b/test/disabled/test-tty-stdio.js @@ -0,0 +1,33 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// Can't test this when 'make test' doesn't assign a tty to the stdout. +var common = require('../common'); +var assert = require('assert'); +var tty = require('tty'); + +assert.ok(process.stdin instanceof tty.ReadStream); +assert.ok(process.stdin.readable); +assert.ok(!process.stdin.writable); + +assert.ok(process.stdout instanceof tty.WriteStream); +assert.ok(!process.stdout.readable); +assert.ok(process.stdout.writable); diff --git a/test/disabled/tls-client.js b/test/disabled/tls-client.js index 8383582e47..169a52145c 100644 --- a/test/disabled/tls-client.js +++ b/test/disabled/tls-client.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var tls = require('tls'); var fs = require('fs'); diff --git a/test/disabled/tls_client.js b/test/disabled/tls_client.js index 81b10f556f..d574635b0e 100644 --- a/test/disabled/tls_client.js +++ b/test/disabled/tls_client.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/disabled/tls_server.js b/test/disabled/tls_server.js index 899c0cc789..ee25daad4b 100644 --- a/test/disabled/tls_server.js +++ b/test/disabled/tls_server.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/fixtures/a.js b/test/fixtures/a.js index ebbfe03527..3e4975841c 100644 --- a/test/fixtures/a.js +++ b/test/fixtures/a.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var c = require('./b/c'); console.error('load fixtures/a.js'); diff --git a/test/fixtures/b/c.js b/test/fixtures/b/c.js index 8eec4704a9..a8a3a272b0 100644 --- a/test/fixtures/b/c.js +++ b/test/fixtures/b/c.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var d = require('./d'); var assert = require('assert'); diff --git a/test/fixtures/b/d.js b/test/fixtures/b/d.js index 77dbb8be9a..ef449f6790 100644 --- a/test/fixtures/b/d.js +++ b/test/fixtures/b/d.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + console.error('load fixtures/b/d.js'); var string = 'D'; diff --git a/test/fixtures/b/package/index.js b/test/fixtures/b/package/index.js index cbf16fdc28..c88d605ea0 100644 --- a/test/fixtures/b/package/index.js +++ b/test/fixtures/b/package/index.js @@ -1,2 +1,23 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.hello = 'world'; console.error('load package/index.js'); diff --git a/test/fixtures/child_process_should_emit_error.js b/test/fixtures/child_process_should_emit_error.js index 9f7b2bb80f..6e63235c4f 100644 --- a/test/fixtures/child_process_should_emit_error.js +++ b/test/fixtures/child_process_should_emit_error.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var exec = require('child_process').exec; [0, 1].forEach(function(i) { diff --git a/test/fixtures/cycles/folder/foo.js b/test/fixtures/cycles/folder/foo.js index f2bf829bac..07da5c9685 100644 --- a/test/fixtures/cycles/folder/foo.js +++ b/test/fixtures/cycles/folder/foo.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var root = require('./../root'); diff --git a/test/fixtures/cycles/root.js b/test/fixtures/cycles/root.js index e73c9d9d6a..ddce47d187 100644 --- a/test/fixtures/cycles/root.js +++ b/test/fixtures/cycles/root.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var foo = exports.foo = require('./folder/foo'); diff --git a/test/fixtures/echo.js b/test/fixtures/echo.js index bcc2ddfe09..689096c1a8 100644 --- a/test/fixtures/echo.js +++ b/test/fixtures/echo.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/fixtures/exit.js b/test/fixtures/exit.js index c6c8b8209d..7e0fd7dd6b 100644 --- a/test/fixtures/exit.js +++ b/test/fixtures/exit.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + process.exit(process.argv[2] || 1); diff --git a/test/fixtures/global/plain.js b/test/fixtures/global/plain.js index 42567881d6..f983d7c68b 100644 --- a/test/fixtures/global/plain.js +++ b/test/fixtures/global/plain.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + foo = 'foo'; global.bar = 'bar'; diff --git a/test/fixtures/keys/Makefile b/test/fixtures/keys/Makefile index e94665fd39..fa64352a80 100644 --- a/test/fixtures/keys/Makefile +++ b/test/fixtures/keys/Makefile @@ -6,14 +6,14 @@ all: agent1-cert.pem agent2-cert.pem agent3-cert.pem agent4-cert.pem ca2-crl.pem # ('password' is used for the CA password.) # ca1-cert.pem: ca1.cnf - openssl req -new -x509 -config ca1.cnf -keyout ca1-key.pem -out ca1-cert.pem + openssl req -new -x509 -days 9999 -config ca1.cnf -keyout ca1-key.pem -out ca1-cert.pem # # Create Certificate Authority: ca2 # ('password' is used for the CA password.) # ca2-cert.pem: ca2.cnf - openssl req -new -x509 -config ca2.cnf -keyout ca2-key.pem -out ca2-cert.pem + openssl req -new -x509 -days 9999 -config ca2.cnf -keyout ca2-key.pem -out ca2-cert.pem echo '01' > ca2-serial touch ca2-database.txt @@ -30,7 +30,7 @@ agent1-csr.pem: agent1.cnf agent1-key.pem agent1-cert.pem: agent1-csr.pem ca1-cert.pem ca1-key.pem openssl x509 -req \ - -days 999 \ + -days 9999 \ -passin "pass:password" \ -in agent1-csr.pem \ -CA ca1-cert.pem \ @@ -56,7 +56,7 @@ agent2-csr.pem: agent2-key.pem agent2.cnf # Create a Certificate for the agent. agent2-cert.pem: agent2-csr.pem agent2-key.pem openssl x509 -req \ - -days 999 \ + -days 9999 \ -in agent2-csr.pem \ -signkey agent2-key.pem \ -out agent2-cert.pem @@ -76,7 +76,7 @@ agent3-csr.pem: agent3.cnf agent3-key.pem agent3-cert.pem: agent3-csr.pem ca2-cert.pem ca2-key.pem openssl x509 -req \ - -days 999 \ + -days 9999 \ -passin "pass:password" \ -in agent3-csr.pem \ -CA ca2-cert.pem \ @@ -100,7 +100,7 @@ agent4-csr.pem: agent4.cnf agent4-key.pem agent4-cert.pem: agent4-csr.pem ca2-cert.pem ca2-key.pem openssl x509 -req \ - -days 999 \ + -days 9999 \ -passin "pass:password" \ -in agent4-csr.pem \ -CA ca2-cert.pem \ diff --git a/test/fixtures/keys/agent1-cert.pem b/test/fixtures/keys/agent1-cert.pem index a9865aadb3..816f6fbf17 100644 --- a/test/fixtures/keys/agent1-cert.pem +++ b/test/fixtures/keys/agent1-cert.pem @@ -1,14 +1,14 @@ -----BEGIN CERTIFICATE----- -MIICKjCCAZMCCQD5jfGqPDk4DzANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJV +MIICKjCCAZMCCQDQ8o4kHKdCPDANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJV UzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAO BgNVBAsTB05vZGUuanMxDDAKBgNVBAMTA2NhMTEgMB4GCSqGSIb3DQEJARYRcnlA -dGlueWNsb3Vkcy5vcmcwHhcNMTEwMjEwMDIzMDIwWhcNMTMxMTA1MDIzMDIwWjB9 +dGlueWNsb3Vkcy5vcmcwHhcNMTEwMzE0MTgyOTEyWhcNMzgwNzI5MTgyOTEyWjB9 MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQK EwZKb3llbnQxEDAOBgNVBAsTB05vZGUuanMxDzANBgNVBAMTBmFnZW50MTEgMB4G CSqGSIb3DQEJARYRcnlAdGlueWNsb3Vkcy5vcmcwXDANBgkqhkiG9w0BAQEFAANL -ADBIAkEAz2/2xnYqQQUEquP0AyfI0KJ7V3uA/EdN5ysOVBK9EYbklM0UBKRdob3Z -URutrEYq18vi8P0rBwDn76f3D87J3QIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFAi -xZFExnFluQLHx5P/9R2LgfMLAZxUAhQDQSilh/6ItoaWz9bbfxh7hIc8fgGd11Xr -f19nK4D2Ov9nZg+Kh5Tbta8Akr9/htxAcg3LBbQj1BEJsi14ZLk6L92gbwBiXtyf -SWX6ulpS+op3GNH6Jbr9bFkz5voyF2qYgC+PkuMS +ADBIAkEAnzpAqcoXZxWJz/WFK7BXwD23jlREyG11x7gkydteHvn6PrVBbB5yfu6c +bk8w3/Ar608AcyMQ9vHjkLQKH7cjEQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAKha +HqjCfTIut+m/idKy3AoFh48tBHo3p9Nl5uBjQJmahKdZAaiksL24Pl+NzPQ8LIU+ +FyDHFp6OeJKN6HzZ72Bh9wpBVu6Uj1hwhZhincyTXT80wtSI/BoUAW8Ls2kwPdus +64LsJhhxqj2m4vPKNRbHB2QxnNrGi30CUf3kt3Ia -----END CERTIFICATE----- diff --git a/test/fixtures/keys/agent1-csr.pem b/test/fixtures/keys/agent1-csr.pem index 07942c9f2d..748fd00036 100644 --- a/test/fixtures/keys/agent1-csr.pem +++ b/test/fixtures/keys/agent1-csr.pem @@ -2,9 +2,9 @@ MIIBXTCCAQcCAQAwfTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMQswCQYDVQQH EwJTRjEPMA0GA1UEChMGSm95ZW50MRAwDgYDVQQLEwdOb2RlLmpzMQ8wDQYDVQQD EwZhZ2VudDExIDAeBgkqhkiG9w0BCQEWEXJ5QHRpbnljbG91ZHMub3JnMFwwDQYJ -KoZIhvcNAQEBBQADSwAwSAJBAM9v9sZ2KkEFBKrj9AMnyNCie1d7gPxHTecrDlQS -vRGG5JTNFASkXaG92VEbraxGKtfL4vD9KwcA5++n9w/Oyd0CAwEAAaAlMCMGCSqG +KoZIhvcNAQEBBQADSwAwSAJBAJ86QKnKF2cVic/1hSuwV8A9t45URMhtdce4JMnb +Xh75+j61QWwecn7unG5PMN/wK+tPAHMjEPbx45C0Ch+3IxECAwEAAaAlMCMGCSqG SIb3DQEJBzEWExRBIGNoYWxsZW5nZSBwYXNzd29yZDANBgkqhkiG9w0BAQUFAANB -AHjM51IihZNCEjR2dQkMY5yh45ZNSstuTCUR7EuPIuvAgUdcupK768dpt3s+OH6v -/oEAskuzZoJlogkWum4Hx+4= +AF+AfG64hNyYHum46m6i7RgnUBrJSOynGjs23TekV4he3QdMSAAPPqbll8W14+y3 +vOo7/yQ2v2uTqxCjakUNPPs= -----END CERTIFICATE REQUEST----- diff --git a/test/fixtures/keys/agent1-key.pem b/test/fixtures/keys/agent1-key.pem index 381942d5d7..5dae7eb99d 100644 --- a/test/fixtures/keys/agent1-key.pem +++ b/test/fixtures/keys/agent1-key.pem @@ -1,9 +1,9 @@ -----BEGIN RSA PRIVATE KEY----- -MIIBPAIBAAJBAM9v9sZ2KkEFBKrj9AMnyNCie1d7gPxHTecrDlQSvRGG5JTNFASk -XaG92VEbraxGKtfL4vD9KwcA5++n9w/Oyd0CAwEAAQJBALlbYdZrBky9MDOHp6Ye -KboMRkygplxHVtxGw/HqIJoEJC/Vfx3c5Cc95ZlqMkQeTG/bBHwUNaQ7lVbGASgC -l2ECIQDucbswxxYRiZ5Sjm1BKfLdM7hkkN7HxncoKFAlKzVEmQIhAN61zixVvBEf -OgS5Y26XyXwQ0MLVODzXkqEp1yUR0vXlAiEA4Mzy2YLpCHHBhT3oPUZqRSgM0StQ -DfLLxl1zagd5egkCIQCdQbrnS1KUtHv/QfiX6s32sNj3+h7Pt1huPGESZ9eSkQIg -Xc7II2rq0zPMQ50CzFMq6ckehMNxrM/EUfSwHhXmIKU= +MIIBOwIBAAJBAJ86QKnKF2cVic/1hSuwV8A9t45URMhtdce4JMnbXh75+j61QWwe +cn7unG5PMN/wK+tPAHMjEPbx45C0Ch+3IxECAwEAAQJBAI2cU1IuR+4IO87WPyAB +76kruoo87AeNQkjjvuQ/00+b/6IS45mcEP5Kw0NukbqBhIw2di9uQ9J51DJ/ZfQr ++YECIQDUHaN3ZjIdJ7/w8Yq9Zzz+3kY2F/xEz6e4ftOFW8bY2QIhAMAref+WYckC +oECgOLAvAxB1lI4j7oCbAaawfxKdnPj5AiEAi95rXx09aGpAsBGmSdScrPdG1v6j +83/2ebrvoZ1uFqkCIB0AssnrRVjUB6GZTNTyU3ERfdkx/RX1zvr8WkFR/lXpAiB7 +cUZ1i8ZkZrPrdVgw2cb28UJM7qZHQnXcMHTXFFvxeQ== -----END RSA PRIVATE KEY----- diff --git a/test/fixtures/keys/agent2-cert.pem b/test/fixtures/keys/agent2-cert.pem index 7fe4703ffc..8e4354db4e 100644 --- a/test/fixtures/keys/agent2-cert.pem +++ b/test/fixtures/keys/agent2-cert.pem @@ -1,13 +1,13 @@ -----BEGIN CERTIFICATE----- -MIIB7DCCAZYCCQC+WNujvsT5HzANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJV +MIIB7DCCAZYCCQC7gs0MDNn6MTANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJV UzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAO BgNVBAsTB05vZGUuanMxDzANBgNVBAMTBmFnZW50MjEgMB4GCSqGSIb3DQEJARYR -cnlAdGlueWNsb3Vkcy5vcmcwHhcNMTEwMjEwMDIzMDIwWhcNMTMxMTA1MDIzMDIw +cnlAdGlueWNsb3Vkcy5vcmcwHhcNMTEwMzE0MTgyOTEyWhcNMzgwNzI5MTgyOTEy WjB9MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYD VQQKEwZKb3llbnQxEDAOBgNVBAsTB05vZGUuanMxDzANBgNVBAMTBmFnZW50MjEg MB4GCSqGSIb3DQEJARYRcnlAdGlueWNsb3Vkcy5vcmcwXDANBgkqhkiG9w0BAQEF -AANLADBIAkEAtqdUsNzNCbBOWRe1Vyd5m7CGQ8XaDLZkvIVNvB8PWjJiQR4AfPXk -Ubxg4vKEmsHYY76a9Err+bGkuu/zaIEzQwIDAQABMA0GCSqGSIb3DQEBBQUAA0EA -H7VfQ08YLGGsj/eB0YU/au1D3MX4zbE+JRKZCHx/h6ht8rRKbnVSiyqS18UG8AE2 -q84jwsOYoSpcdKJ95iQyUg== +AANLADBIAkEAyXb8FrRdKbhrKLgLSsn61i1C7w7fVVVd7OQsmV/7p9WB2lWFiDlC +WKGU9SiIz/A6wNZDUAuc2E+VwtpCT561AQIDAQABMA0GCSqGSIb3DQEBBQUAA0EA +C8HzpuNhFLCI3A5KkBS5zHAQax6TFUOhbpBCR0aTDbJ6F1liDTK1lmU/BjvPoj+9 +1LHwrmh29rK8kBPEjmymCQ== -----END CERTIFICATE----- diff --git a/test/fixtures/keys/agent2-csr.pem b/test/fixtures/keys/agent2-csr.pem index cd437ac0be..a670c4c632 100644 --- a/test/fixtures/keys/agent2-csr.pem +++ b/test/fixtures/keys/agent2-csr.pem @@ -2,9 +2,9 @@ MIIBXTCCAQcCAQAwfTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMQswCQYDVQQH EwJTRjEPMA0GA1UEChMGSm95ZW50MRAwDgYDVQQLEwdOb2RlLmpzMQ8wDQYDVQQD EwZhZ2VudDIxIDAeBgkqhkiG9w0BCQEWEXJ5QHRpbnljbG91ZHMub3JnMFwwDQYJ -KoZIhvcNAQEBBQADSwAwSAJBALanVLDczQmwTlkXtVcneZuwhkPF2gy2ZLyFTbwf -D1oyYkEeAHz15FG8YOLyhJrB2GO+mvRK6/mxpLrv82iBM0MCAwEAAaAlMCMGCSqG +KoZIhvcNAQEBBQADSwAwSAJBAMl2/Ba0XSm4ayi4C0rJ+tYtQu8O31VVXezkLJlf ++6fVgdpVhYg5QlihlPUoiM/wOsDWQ1ALnNhPlcLaQk+etQECAwEAAaAlMCMGCSqG SIb3DQEJBzEWExRBIGNoYWxsZW5nZSBwYXNzd29yZDANBgkqhkiG9w0BAQUFAANB -AJTLv/C1fM7K8dOLEaRH0fGJmzZUiKSsw6itpnpkwF7CTZDfq1KohlUnd8n53qzL -YpJD0CA9dj/YsnCM3JszRuU= +AJnll2pt5l0pzskQSpjjLVTlFDFmJr/AZ3UK8v0WxBjYjCe5Jx4YehkChpxIyDUm +U3J9q9MDUf0+Y2+EGkssFfk= -----END CERTIFICATE REQUEST----- diff --git a/test/fixtures/keys/agent2-key.pem b/test/fixtures/keys/agent2-key.pem index a2ab86a9b4..522903c635 100644 --- a/test/fixtures/keys/agent2-key.pem +++ b/test/fixtures/keys/agent2-key.pem @@ -1,9 +1,9 @@ -----BEGIN RSA PRIVATE KEY----- -MIIBOgIBAAJBALanVLDczQmwTlkXtVcneZuwhkPF2gy2ZLyFTbwfD1oyYkEeAHz1 -5FG8YOLyhJrB2GO+mvRK6/mxpLrv82iBM0MCAwEAAQJBAIZGCJpkF08SDuar6SGC -4YE0id90qVFDHFcCYBz1cGHK/WzFleKyF4FilK47C5LspT+wwFnbczQ02qLApeMU -irECIQDonMMTOXSoFh/q6e241nTpqTuPFeKl9hinQxZ9gDqZRQIhAMkErN6+0CGH -grXsWj16hmHv1ufkbGQnn6uQ5B3G5K7nAiAXDnLHlQpbHtZLEqTdjWRJRN0Cccjl -al9HNP8lsXAdgQIgbHhdYATPAojA+7ICL9KB2S82ZANaieDnxAh3T6oXlFkCIC0U -e/cXHcEGT5k6TwPif3cplB/cnnMl3BzVzBYDuV/2 +MIIBOgIBAAJBAMl2/Ba0XSm4ayi4C0rJ+tYtQu8O31VVXezkLJlf+6fVgdpVhYg5 +QlihlPUoiM/wOsDWQ1ALnNhPlcLaQk+etQECAwEAAQJBAMT6Bf34+UHKY1ObpsbH +9u2jsVblFq1rWvs8GPMY6oertzvwm3DpuSUp7PTgOB1nLTLYtCERbQ4ovtN8tn3p +OHUCIQDzIEGsoCr5vlxXvy2zJwu+fxYuhTZWMVuo1397L0VyhwIhANQh+yzqUgaf +WRtSB4T2W7ADtJI35ET61jKBty3CqJY3AiAIwju7dVW3A5WeD6Qc1SZGKZvp9yCb +AFI2BfVwwaY11wIgXF3PeGcvACMyMWsuSv7aPXHfliswAbkWuzcwA4TW01ECIGWa +cgsDvVFxmfM5NPSuT/UDTa6R5BFISB5ea0N0AR3I -----END RSA PRIVATE KEY----- diff --git a/test/fixtures/keys/agent3-cert.pem b/test/fixtures/keys/agent3-cert.pem index 26dbe5e00a..e4a235079f 100644 --- a/test/fixtures/keys/agent3-cert.pem +++ b/test/fixtures/keys/agent3-cert.pem @@ -1,14 +1,14 @@ -----BEGIN CERTIFICATE----- -MIICKjCCAZMCCQDMRmF28ReZjTANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJV +MIICKjCCAZMCCQCDBr594bsJmTANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJV UzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAO BgNVBAsTB05vZGUuanMxDDAKBgNVBAMTA2NhMjEgMB4GCSqGSIb3DQEJARYRcnlA -dGlueWNsb3Vkcy5vcmcwHhcNMTEwMjEwMDc1NjU1WhcNMTMxMTA1MDc1NjU1WjB9 +dGlueWNsb3Vkcy5vcmcwHhcNMTEwMzE0MTgyOTEyWhcNMzgwNzI5MTgyOTEyWjB9 MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQK EwZKb3llbnQxEDAOBgNVBAsTB05vZGUuanMxDzANBgNVBAMTBmFnZW50MzEgMB4G CSqGSIb3DQEJARYRcnlAdGlueWNsb3Vkcy5vcmcwXDANBgkqhkiG9w0BAQEFAANL -ADBIAkEAvo97SurQMLbB62avPWW7KZQ4Xw1jhXZ9uoQ+3A+RZoZ7MRkLYT8R+8l/ -r3ZZo6uYVMrlP14YPZ35qXGs2i7vqwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAHde -DjVjyBmqHJFkZ1bhGOUisChHxg90SX+X9aCxpS7PPWJks56HDlQWMIeU4LmFDX+B -1dF8TKSiWb7XHWLChrMaRdF01wDUuM/lgnJvK+YikiHdAz3dndUT93JQwWv8skg1 -6pHpYaK3A5AsHH+bogz+/sCCuoVwp8hPwcVWJkXK +ADBIAkEAtlNDZ+bHeBI0B2gD/IWqA7Aq1hwsnS4+XpnLesjTQcL2JwFFpkR0oWrw +yjrYhCogi7c5gjKrLZF1d2JD5JgHgQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAJoK +bXwsImk7vJz9649yrmsXwnuGbEKVYMvqcGyjaZNP9lYEG41y5CeRzxhWy2rlYdhE +f2nqE2lg75oJP7LQqfQY7aCqwahM3q/GQbsfKVCGjF7TVyq9TQzd8iW+FEJIQzSE +3aN85hR67+3VAXeSzmkGSVBO2m1SJIug4qftIkc2 -----END CERTIFICATE----- diff --git a/test/fixtures/keys/agent3-csr.pem b/test/fixtures/keys/agent3-csr.pem index f4c46d9384..e6c0c74b3a 100644 --- a/test/fixtures/keys/agent3-csr.pem +++ b/test/fixtures/keys/agent3-csr.pem @@ -2,9 +2,9 @@ MIIBXTCCAQcCAQAwfTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMQswCQYDVQQH EwJTRjEPMA0GA1UEChMGSm95ZW50MRAwDgYDVQQLEwdOb2RlLmpzMQ8wDQYDVQQD EwZhZ2VudDMxIDAeBgkqhkiG9w0BCQEWEXJ5QHRpbnljbG91ZHMub3JnMFwwDQYJ -KoZIhvcNAQEBBQADSwAwSAJBAL6Pe0rq0DC2wetmrz1luymUOF8NY4V2fbqEPtwP -kWaGezEZC2E/EfvJf692WaOrmFTK5T9eGD2d+alxrNou76sCAwEAAaAlMCMGCSqG +KoZIhvcNAQEBBQADSwAwSAJBALZTQ2fmx3gSNAdoA/yFqgOwKtYcLJ0uPl6Zy3rI +00HC9icBRaZEdKFq8Mo62IQqIIu3OYIyqy2RdXdiQ+SYB4ECAwEAAaAlMCMGCSqG SIb3DQEJBzEWExRBIGNoYWxsZW5nZSBwYXNzd29yZDANBgkqhkiG9w0BAQUFAANB -AJ0eUoKBgimALry2MLT3VktNJQwD8OorIIvnUz0BjG86F0fVX+FWZEqw1aXmblAZ -WTPvnqq//bzzi2PwvoEJ4Lc= +AEGo76iH+a8pnE+RWQT+wg9/BL+iIuqrcFXLs0rbGonqderrwXAe15ODwql/Bfu3 +zgMt8ooTsgMPcMX9EgmubEM= -----END CERTIFICATE REQUEST----- diff --git a/test/fixtures/keys/agent3-key.pem b/test/fixtures/keys/agent3-key.pem index bc2a5b72b6..d72f071e4c 100644 --- a/test/fixtures/keys/agent3-key.pem +++ b/test/fixtures/keys/agent3-key.pem @@ -1,9 +1,9 @@ -----BEGIN RSA PRIVATE KEY----- -MIIBOQIBAAJBAL6Pe0rq0DC2wetmrz1luymUOF8NY4V2fbqEPtwPkWaGezEZC2E/ -EfvJf692WaOrmFTK5T9eGD2d+alxrNou76sCAwEAAQJAcT7Nk4kWLkz900pTzBX/ -80a9dWd8hF0VfNmIjbjGvPkaCW6th6N5TuSJbrwrKcSqyxB9fG8/oY42IsGe+Tj8 -MQIhAN3VnmNLml9/w6ksMfulhddGPKEi7RpNvTe+rq3vVsfTAiEA2+jOzgkA3Vn0 -riBRt7jAH+8OTh9Qxu23akW77nj/6ckCIChCeqpesDegwmvTf4bCNZYqQxqjchCS -B0M0shMTGtbNAiAFEtHynvKOKM0kV0qLWo/ULMe/tak/bayVnxY+4jvFQQIgSToA -tCzu09vpDbkH5oXgZbLKSznShbYWpAng1XMJlYI= +MIIBOwIBAAJBALZTQ2fmx3gSNAdoA/yFqgOwKtYcLJ0uPl6Zy3rI00HC9icBRaZE +dKFq8Mo62IQqIIu3OYIyqy2RdXdiQ+SYB4ECAwEAAQJAIk+G9s2SKgFa8y3a2jGZ +LfqABSzmJGooaIsOpLuYLd6eCC31XUDlT4rPVGRhysKQCQ4+NMjgdnj9ZqNnvXY/ +RQIhAOgbdltr3Ey2hy7RuDW5rmOeJTuVqCrZ7QI8ifyCEbYTAiEAyRfvWSvvASeP +kZTMUhATRUpuyDQW+058NE0oJSinTpsCIQCR/FPhBGI3TcaQyA9Ym0T4GwvIAkUX +TqInefRAAX8qSQIgZVJPAdIWGbHSL9sWW97HpukLCorcbYEtKbkamiZyrjMCIQCX +lX76ttkeId5OsJGQcF67eFMMr2UGZ1WMf6M39lCYHQ== -----END RSA PRIVATE KEY----- diff --git a/test/fixtures/keys/agent4-cert.pem b/test/fixtures/keys/agent4-cert.pem index 3d3bda4030..07157b919b 100644 --- a/test/fixtures/keys/agent4-cert.pem +++ b/test/fixtures/keys/agent4-cert.pem @@ -1,15 +1,15 @@ -----BEGIN CERTIFICATE----- -MIICSDCCAbGgAwIBAgIJAMxGYXbxF5mOMA0GCSqGSIb3DQEBBQUAMHoxCzAJBgNV +MIICSDCCAbGgAwIBAgIJAIMGvn3huwmaMA0GCSqGSIb3DQEBBQUAMHoxCzAJBgNV BAYTAlVTMQswCQYDVQQIEwJDQTELMAkGA1UEBxMCU0YxDzANBgNVBAoTBkpveWVu dDEQMA4GA1UECxMHTm9kZS5qczEMMAoGA1UEAxMDY2EyMSAwHgYJKoZIhvcNAQkB -FhFyeUB0aW55Y2xvdWRzLm9yZzAeFw0xMTAyMTAwNzU2NTVaFw0xMzExMDUwNzU2 -NTVaMH0xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTELMAkGA1UEBxMCU0YxDzAN +FhFyeUB0aW55Y2xvdWRzLm9yZzAeFw0xMTAzMTQxODI5MTJaFw0zODA3MjkxODI5 +MTJaMH0xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTELMAkGA1UEBxMCU0YxDzAN BgNVBAoTBkpveWVudDEQMA4GA1UECxMHTm9kZS5qczEPMA0GA1UEAxMGYWdlbnQ0 MSAwHgYJKoZIhvcNAQkBFhFyeUB0aW55Y2xvdWRzLm9yZzBcMA0GCSqGSIb3DQEB -AQUAA0sAMEgCQQC+eEnKdt2AHzGMt1EkALMiSHk6MLnHLxigi6CCM3jxxNz/lw7Y -uZfAWyTBr6jjCZsa/SC8DpE7caRZED//F4tFAgMBAAGjFzAVMBMGA1UdJQQMMAoG -CCsGAQUFBwMCMA0GCSqGSIb3DQEBBQUAA4GBAKJu+RhRDKkzVn9BrS8r3hPlJUdS -ybHfZpsOHpltmzO+PkWaio7jEXT7nnKBjV4VP8ld6wDa4mk+tRyhgt91+nmvrIeT -yw7I9UBY7RCCDIXy755zSkT3OitOTk7besU70Am8/P3Srg7IyHeYBnJVLqn4FIlz -/apIKko90U+bEgk2 +AQUAA0sAMEgCQQDN/yMfmQ8zdvmjlGk7b3Mn6wY2FjaMb4c5ENJX15vyYhKS1zhx +6n0kQIn2vf6yqG7tO5Okz2IJiD9Sa06mK6GrAgMBAAGjFzAVMBMGA1UdJQQMMAoG +CCsGAQUFBwMCMA0GCSqGSIb3DQEBBQUAA4GBAA8FXpRmdrHBdlofNvxa14zLvv0N +WnUGUmxVklFLKXvpVWTanOhVgI2TDCMrT5WvCRTD25iT1EUKWxjDhFJrklQJ+IfC +KC6fsgO7AynuxWSfSkc8/acGiAH+20vW9QxR53HYiIDMXEV/wnE0KVcr3t/d70lr +ImanTrunagV+3O4O -----END CERTIFICATE----- diff --git a/test/fixtures/keys/agent4-csr.pem b/test/fixtures/keys/agent4-csr.pem index 26cfaa2871..97e115d030 100644 --- a/test/fixtures/keys/agent4-csr.pem +++ b/test/fixtures/keys/agent4-csr.pem @@ -2,9 +2,9 @@ MIIBXTCCAQcCAQAwfTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMQswCQYDVQQH EwJTRjEPMA0GA1UEChMGSm95ZW50MRAwDgYDVQQLEwdOb2RlLmpzMQ8wDQYDVQQD EwZhZ2VudDQxIDAeBgkqhkiG9w0BCQEWEXJ5QHRpbnljbG91ZHMub3JnMFwwDQYJ -KoZIhvcNAQEBBQADSwAwSAJBAL54Scp23YAfMYy3USQAsyJIeTowuccvGKCLoIIz -ePHE3P+XDti5l8BbJMGvqOMJmxr9ILwOkTtxpFkQP/8Xi0UCAwEAAaAlMCMGCSqG +KoZIhvcNAQEBBQADSwAwSAJBAM3/Ix+ZDzN2+aOUaTtvcyfrBjYWNoxvhzkQ0lfX +m/JiEpLXOHHqfSRAifa9/rKobu07k6TPYgmIP1JrTqYroasCAwEAAaAlMCMGCSqG SIb3DQEJBzEWExRBIGNoYWxsZW5nZSBwYXNzd29yZDANBgkqhkiG9w0BAQUFAANB -AJc7y8DLaJ+j9wdEmjPV+mt6NuFQ3MHVuTzteMAsdASiJ9ce5U/vNMvS0UXdjzkd -y4uuWOqLyZaajVCqDDk5JvE= +AMzo7GUOBtGm5MSck1rrEE2C1bU3qoVvXVuiN3A/57zXeNeq24FZMLnkDeL9U+/b +Kj646XFou04gla982Xp74p0= -----END CERTIFICATE REQUEST----- diff --git a/test/fixtures/keys/agent4-key.pem b/test/fixtures/keys/agent4-key.pem index 68610f81b8..b770b015db 100644 --- a/test/fixtures/keys/agent4-key.pem +++ b/test/fixtures/keys/agent4-key.pem @@ -1,9 +1,9 @@ -----BEGIN RSA PRIVATE KEY----- -MIIBPQIBAAJBAL54Scp23YAfMYy3USQAsyJIeTowuccvGKCLoIIzePHE3P+XDti5 -l8BbJMGvqOMJmxr9ILwOkTtxpFkQP/8Xi0UCAwEAAQJBALq4g2ZnBpfOfK29HF9W -DEZElAs2rzkT82mX198sBJnFOFfdo0GdGkA8LlQVwXEv2yWKlzN5zrkJPK/I/Z6A -vxUCIQDxRDPGSV0nfnFH5mcs7pnWNIi7tRZecsAhaj2gGBNCfwIhAMoZ94XYslXl -2eHUDPvVYhzNqdRWXfgD8N89lYXXTMg7AiEAnPwmwCeuYGtKpGEL01WxbYqjSZfr -5Sq/Tz7EuG3R4lsCIQDIz/pprUKuJUBUqt3n0UO2uQgZq2Odj1TkjQ2oOqDZhwIh -AIydKQ6a35hFleOih3yiHvFPUEE7jOAIhGTOAd3s31LN +MIIBOQIBAAJBAM3/Ix+ZDzN2+aOUaTtvcyfrBjYWNoxvhzkQ0lfXm/JiEpLXOHHq +fSRAifa9/rKobu07k6TPYgmIP1JrTqYroasCAwEAAQJAN8RQb+dx1A7rejtdWbfM +Rww7PD07Oz2eL/a72wgFsdIabRuVypIoHunqV0sAegYtNJt9yu+VhREw0R5tx/qz +EQIhAPY+nmzp0b4iFRk7mtGUmCTr9iwwzoqzITwphE7FpQnFAiEA1ihUHFT9YPHO +f85skM6qZv77NEgXHO8NJmQZ5GX1ZK8CICzle+Mluo0tD6W7HV4q9pZ8wzSJbY8S +W/PpKetm09F1AiAWTw8sAGKAtc/IGo3Oq+iuYAN1F8lolzJsfGMCGujsOwIgAJKP +t3eXilwX3ZlsDWSklWNZ7iYcfYrvAc3JqU6gFCE= -----END RSA PRIVATE KEY----- diff --git a/test/fixtures/keys/ca1-cert.pem b/test/fixtures/keys/ca1-cert.pem index 0f685a2d89..1951de77a2 100644 --- a/test/fixtures/keys/ca1-cert.pem +++ b/test/fixtures/keys/ca1-cert.pem @@ -1,15 +1,15 @@ -----BEGIN CERTIFICATE----- -MIICazCCAdQCCQC2s7NK93h5BzANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJV +MIICazCCAdQCCQDTlFdg2h0DBjANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJV UzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAO BgNVBAsTB05vZGUuanMxDDAKBgNVBAMTA2NhMTEgMB4GCSqGSIb3DQEJARYRcnlA -dGlueWNsb3Vkcy5vcmcwHhcNMTEwMjEwMDIzMDIwWhcNMTEwMzEyMDIzMDIwWjB6 +dGlueWNsb3Vkcy5vcmcwHhcNMTEwMzE0MTgyOTEyWhcNMzgwNzI5MTgyOTEyWjB6 MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQK EwZKb3llbnQxEDAOBgNVBAsTB05vZGUuanMxDDAKBgNVBAMTA2NhMTEgMB4GCSqG SIb3DQEJARYRcnlAdGlueWNsb3Vkcy5vcmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0A -MIGJAoGBALPYC82pdSQara5t+AexwKNIIqPTw1DkthcHCkiZ5XhcrsXY1RdRw+gZ -S4SUr9YM27Ip62xhRcRhVLcrfUzHh/fIh/UOU0xJQrmE2bXdJ6gRC1AVIyJZBOlS -nd5KsMxbGg0Xu9DIph2USwCbp2T00/95Y8rD6T9LA3Eo+shnE4Q9AgMBAAEwDQYJ -KoZIhvcNAQEFBQADgYEAQhOPlI1uXLnQi/uTfQ/ux0dyGIf5wEXvVXB0q7YyulaH -lgCKAL0yujMzik9ZToxcTvSQ3bOfi5J/wURJBrxyLg2S3p2rd5eAICBDzwTgLNmB -U6xY2qBLUUyJ+KoU1N0m4Vcp03MRSxJ2Mb7W6R9sG4UMrgh/t+s/UStJ+wepZOk= +MIGJAoGBAKxbsLdJbi53pcP1pzg8lgJhLEvcNlV2ogr97WURp+gPjK+HFXj2xl9w +qDQrxpmvTya+urBG7OagTjV1E7dRE7PTr4TkEqehmxF026Opb0PZewuIBOKX4UgG +PSfk0fksrje6YJb+OkiBfA/q7eznZF8cmq7MRrs7LWe9A6Bic/apAgMBAAEwDQYJ +KoZIhvcNAQEFBQADgYEAk6hlYgjCBihG4dM+3324W1WsvjU8QscsTXu8SGL0y9b6 +82zZikj0W9FU6u98WHtXwuFt3mKlGCcou2pluZvj02T2iVKSMs2oYL8JOlvM8hVf +GEeg2EriLlzmdxNz4/I86DlBiyoTijZh8/qrItsK7+a56P0exH8ouXzlhL1Bhjw= -----END CERTIFICATE----- diff --git a/test/fixtures/keys/ca1-cert.srl b/test/fixtures/keys/ca1-cert.srl index 2ddaebdb40..046be14b82 100644 --- a/test/fixtures/keys/ca1-cert.srl +++ b/test/fixtures/keys/ca1-cert.srl @@ -1 +1 @@ -F98DF1AA3C39380F +D0F28E241CA7423C diff --git a/test/fixtures/keys/ca1-key.pem b/test/fixtures/keys/ca1-key.pem index 6fc055f49e..a4e4516c62 100644 --- a/test/fixtures/keys/ca1-key.pem +++ b/test/fixtures/keys/ca1-key.pem @@ -1,17 +1,17 @@ -----BEGIN ENCRYPTED PRIVATE KEY----- -MIICxjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQI2YbQGDCg2C8CAggA -MBQGCCqGSIb3DQMHBAiMhBgi9zbv0gSCAoC/gyjRMNyFjQC99KZz6I8/axXFxiYR -h/K59xzqjaYX/Dl5UWacL6opjR8wilTG27pL6FN3wv4T9pwgYJDPP63NMs8VZd+t -lO6zv1Pv4YtP3+/f/pFRkEtTZYCxIuqWtH0bk3KmWVpwb2ymxIu+nYEfaq36OJp1 -yTR0DuK1zPrTsRq2n7qi0cHNDfMHIvUTtTgYYqvDCAQx0M9C0/qXDyBgkmJLfoxS -0T5hh6ksS5zr5ffy12jE4NuaSMCyzL1w8MCgRsbpJF3M7ZjN0DceHibhv8HrmRwh -qwvyEL8Esh4kYx0wW9/PPzyhidKGDGw9gzfPap+Hu6xrY77r5tdkqd0HS8bGUQSJ -zOpWqymwlbMMb0LfQbjfiTlAEdpCYiMLdtMM62QnGkLFxQMvxo5ENpuCvSuBwns/ -ycAhu2oLICayXUcFY0Pqi+tkBK8u/Ix89WXGeuceaWONXhFA1xqafcLCaiPfikNR -icb7E152JDXT4vBduUT7V0PecgetM9BkfGXYJzroR7gx9wyuSLS5XCXUflXIgmYU -VPgoYe7rYVSovv2jYKQJtJv2RFhdMchqHCtVsPyjIeyYE/+hdR4Z8xZNU2h5QhDO -t6DRB5Kat30hyV9FtXxde38wHUVHZ8bPtP9mf5RwYs1Oz9gSImvqPwZFjl7nnUug -XmgzVLWLOwt5yZaxWnnWo1FL9EOfedXV20oAK7+jwxL0x1t2foi3QL1i7TapKiyD -9GcWpgFrasoa7gCDHW0Yu2V1SI4VTurgJP1cgGnh2cbNvC+Odv7YZwwuV6ynuPGn -y7zMmbwnRTG2OzPjrYCGIo93Vn/vqVh4lfIJhbCESSScSYOe2iEvMN6U +MIICxjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIrulhMUmafvECAggA +MBQGCCqGSIb3DQMHBAjsjahmkf3zGwSCAoANt0xX8ZZT2CxeyUadbOuku6NrHoFy +YBvnEFvuq3TGm3NB72BxprvfMUNR5Xi6e6rJgtRQttPRX6oN2qfB8+W11vFBeFWG +gxarEotklca4bujPMwxRowyMT20n+yXvRc+Fd5tYrMcaBeweQZD69J242HJMJJmq +Lzvo2qYGaOxjpc8aUDzeDsv8cnlh5Xk1ZcRucRPM9j26KOPSt0wOd4RdN83AE8cW +Xu+k5TSMlPQLWihjS+KzEQ8Rs9CuubxrdmecF6DM70u0kYCLZ1Ex7+kBZu06CUpJ +PODaLca4W92XkBq4X25WgAAaCAj4nZZmgn0X0Fwl1lBqjOK5nEnYpjxuwjjJ2KVz +3j+kBK5tW6RBE4BM37r7NiM1FAzi8sgNYSVS9oa4m1qGfadEEQdhaMsAfM0SZ/8M +6NUPKlQmoDda9aCO7rqRuQ7pYQ9mpNxcWEBQi0cG6/3VXtqi/TewAKT1T5DToAzg +pL4eOTqeDp4VKif5r2u7Nj0EiM4j2TT88onGsdgRtjgUpNmJCRWYaCzs3QZggdYE +nLZt7ZRXpJ11tERKG3b28qrIw9jHULRAjjWEkEGbxYTpAlrgXklV/04XXnxxAVOP +0YjDzbfx5QCRCq5UHV4Gl3ELoBaOuxcIIN8YrE2oC1CY9uV/HSk4CSlxHNtWyxbA +WbCU2SoEHnwBVlTPbZyfErM33c3u4LJyNx6ah7NzMh5AoQ+cPXlzxFBEGIyAmW37 +pItxDNwL1PzXHGpfOM/QZ5wjzGIwXsh8j94jDNB+TIMG4+dm4aXkolevPjJrYAeG +XZC5mvfMsntNGNFszT/8iXLwt7tlMlQQQl/2b5m6L5yffy6m39wGqTVa -----END ENCRYPTED PRIVATE KEY----- diff --git a/test/fixtures/keys/ca2-cert.pem b/test/fixtures/keys/ca2-cert.pem index 5e3e221e8b..95e30411f7 100644 --- a/test/fixtures/keys/ca2-cert.pem +++ b/test/fixtures/keys/ca2-cert.pem @@ -1,15 +1,15 @@ -----BEGIN CERTIFICATE----- -MIICazCCAdQCCQDzyKZgsfidNjANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJV +MIICazCCAdQCCQDVGbMO4Y2VUTANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJV UzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAO BgNVBAsTB05vZGUuanMxDDAKBgNVBAMTA2NhMjEgMB4GCSqGSIb3DQEJARYRcnlA -dGlueWNsb3Vkcy5vcmcwHhcNMTEwMjEwMDc1NjU1WhcNMTEwMzEyMDc1NjU1WjB6 +dGlueWNsb3Vkcy5vcmcwHhcNMTEwMzE0MTgyOTEyWhcNMzgwNzI5MTgyOTEyWjB6 MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQK EwZKb3llbnQxEDAOBgNVBAsTB05vZGUuanMxDDAKBgNVBAMTA2NhMjEgMB4GCSqG SIb3DQEJARYRcnlAdGlueWNsb3Vkcy5vcmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0A -MIGJAoGBAMf9gxkjRyoHsgvya+jMlHRRds6qwt43t6tB6tkB6dW/23HBvXOCuHe0 -Ryn2EofWtNaLg6IfJg8JwM6k39/EvGgjr730WeI2iQt2b7+OmBBLiEr+Xkrkeskp -Wv+3TdbwF08Vh4pV34kPQhD+q2d0PBZUGgBUVhVzcwZ4XWWJDq1DAgMBAAEwDQYJ -KoZIhvcNAQEFBQADgYEArEYmxp6S+LRE6Nu7ULVElCXL1ouR+srM03j25D/2G/6O -lryRDHGTsNUytBhQFghwi1vPB8mHTVLpWV9NgTbQrQF4qjQHY6CzcM2gnNfkmWql -mpR3x4hs25a86KR3OzrAx4JOkpvzEf1PJgWOLaKt38JoPxehvhgNMx1sd+MR8kw= +MIGJAoGBAMOOtRmmjoBZmyYreB1D1fjftMW6sEGBzfSKZRcn+kiEpqXELq21O/TV +jLJGbo+0PDqxECQyDbOgoQZXcCevFnFhdsSQOYb+0O2kAiMVYGxDtqoKM5g8wj0D +BiE6fnyZoQTDv5lEuvfG0+youCtXlxiK/9cfhikI+hVXuTgwQXt9AgMBAAEwDQYJ +KoZIhvcNAQEFBQADgYEAbMrLydFajwfZXDH3PfpKtDPCm+yV3qvEMGWLfjBdN50g +PwsZE/OIp+KJttdS+MjMG1TfwfWIqa5zGG2ctxx+fHsKH+t3NsO76Eol1p+dKqZp +PdFp2UhViMgURkrpP593AsTTO9BGaz+awSaESDHm8pO+cLaeGKQp93W0sgC0lHQ= -----END CERTIFICATE----- diff --git a/test/fixtures/keys/ca2-cert.srl b/test/fixtures/keys/ca2-cert.srl index 707df7c58e..00dca7dcd0 100644 --- a/test/fixtures/keys/ca2-cert.srl +++ b/test/fixtures/keys/ca2-cert.srl @@ -1 +1 @@ -CC466176F117998E +8306BE7DE1BB099A diff --git a/test/fixtures/keys/ca2-crl.pem b/test/fixtures/keys/ca2-crl.pem index cdbf2da045..166df74583 100644 --- a/test/fixtures/keys/ca2-crl.pem +++ b/test/fixtures/keys/ca2-crl.pem @@ -2,9 +2,9 @@ MIIBXTCBxzANBgkqhkiG9w0BAQQFADB6MQswCQYDVQQGEwJVUzELMAkGA1UECBMC Q0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAOBgNVBAsTB05vZGUu anMxDDAKBgNVBAMTA2NhMjEgMB4GCSqGSIb3DQEJARYRcnlAdGlueWNsb3Vkcy5v -cmcXDTExMDIxMDA3NTcxMVoXDTEzMTEwNTA3NTcxMVowHDAaAgkAzEZhdvEXmY4X -DTExMDIxMDA3NTY1N1owDQYJKoZIhvcNAQEEBQADgYEAgH9u/zWn48ycNmJezW57 -E54QQI2KqwqmnO1S0lt6EDhjktCAxgljoEhjb3rS3221jddbb9FckYVVMKVX3rPP -cUPXF1jLJ8I/jF0mETK4sZQPjA/PIzPQOnUzzQmszfr42b+5x6HQ0gg2RTqN1TC2 -wLLY7ihxVXUzhVIHlGIp9Hk= +cmcXDTExMDMxNDE4MjkxNloXDTEzMTIwNzE4MjkxNlowHDAaAgkAgwa+feG7CZoX +DTExMDMxNDE4MjkxNFowDQYJKoZIhvcNAQEEBQADgYEArRKuEkOla61fm4zlZtHe +LTXFV0Hgo21PScHAp6JqPol4rN5R9+EmUkv7gPCVVBJ9VjIgxSosHiLsDiz3zR+u +txHemhzbdIVANAIiChnFct8sEqH2eL4N6XNUIlMIR06NjNl7NbN8w8haqiearnuT +wmnaL4TThPmpbpKAF7N7JqQ= -----END X509 CRL----- diff --git a/test/fixtures/keys/ca2-database.txt b/test/fixtures/keys/ca2-database.txt index 422d22c6f7..a0966d2697 100644 --- a/test/fixtures/keys/ca2-database.txt +++ b/test/fixtures/keys/ca2-database.txt @@ -1 +1 @@ -R 131105075655Z 110210075657Z CC466176F117998E unknown /C=US/ST=CA/L=SF/O=Joyent/OU=Node.js/CN=agent4/emailAddress=ry@tinyclouds.org +R 380729182912Z 110314182914Z 8306BE7DE1BB099A unknown /C=US/ST=CA/L=SF/O=Joyent/OU=Node.js/CN=agent4/emailAddress=ry@tinyclouds.org diff --git a/test/fixtures/keys/ca2-key.pem b/test/fixtures/keys/ca2-key.pem index a118535f3b..49f678a351 100644 --- a/test/fixtures/keys/ca2-key.pem +++ b/test/fixtures/keys/ca2-key.pem @@ -1,17 +1,17 @@ -----BEGIN ENCRYPTED PRIVATE KEY----- -MIICxjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIzqCAnqkKV5sCAggA -MBQGCCqGSIb3DQMHBAgvE1MWZKV5tgSCAoAe0ygwlrXz3uIDRw2hKhgG28XFZaG0 -Py/8vORZ6JknZF/ucZE4ZsJW0OLhLRe0VmoVIErgLQ6bl6ZhlGq7oZ0DCyiHo3TV -2uUTn3DXQ9d4aSE2cMlA3wSzYihm1up9PUYvWhrhC90/Sc0fB81OA1Hhv2jS36hY -c4rSVfCkSgaziWy77x9XqbEnxpdVRkngbVnVG4UWFfoBTsza+j+C/ysxR/nXDlei -5KKe87V9AcdzFKI+qJP52CQBac1DQCg8EQ51v40BllfK/8JB/45tAETqAiu80COI -zSFs56p4UIsQiXUaToZxA9SsLOPJJHrOL9/IQe5aMRrG0ro5u0/CbIYN0uSbR6Om -iUAXXk/6Oni8C07qO4VLIjG0NKnnIhDgtGGkyn8XDhtNBKsFLhGzAbmOLOZKKko6 -GgxzY7o52I5bOu8oDN9KLrMZKC9Sow9J+xEf65jCIK40HjpoYiKDiDY/xaSOUL9b -ig0WkxwMzWCA0RIsA/958ZBzv+R2Ag90iPDz9xF5vMNucvGHqOPuKo56JcM0SGev -Xr1KxZAOVJcP9It3Yv8Of+DLilwo56O9md2Su0HKNxM0wyanowPw2PcGCK5rtu87 -YDSOHfmg05Bt0F3LC2dU5ak1YJfu/DpVj69hQ5/g/c5JMMVYAjmZGyc6IPKWXHYr -P+ECSDdICBrDLkVeCClhKkNgAw1n8xepdgCE0rWSkbxoCmoKDXQDl1kOfs5TWIvL -JRqrVYz2yoPAa1Q9gTM3iDtBL3RJwF2jXk4IDySR/1YDf+BbnyhiisIRSMp8GeQS -uX1Ke+bu3QWwFVqa0eYScVPZZzNUADHzviMweRX9l+1aCw0R31po7Fwl +MIICxjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIbhsCgrscf9MCAggA +MBQGCCqGSIb3DQMHBAjz0LdWOB2KVQSCAoDu+sHRLP6v6QiEwqynnF43yP02/F+8 +Jssz6cgFPpm4MWm+xwzvMsS4ET0UYE68OTZz/QgihwH0mp/34tkUnP0HqtdbnTH1 +fkG47hb8fVSEyDQSzs1ha/u31GIachNURKyhWR5mr15AJxu2B94Z3ldNv1yjI+Fy +M1muuyx/cdkKTdpfpYr6n//wF1tup2u8Y7nkKsFus/mCuRlpItxKcRb1+nvW0s+K +3bSR8CTlEWd1Tx6Qx+ogRbP8gwqd6gelcz/Zj8nInx/Y0gTkQ4eodmLJ5iqsvC36 +SgQB5LuP12ujTyXB3Hwqb8LJ4lULERX6AYHAa7h0c+fxuFr0W9/8atplrd22hoiP +zZhgPHeH3R1fibB4M4xW2xgtbysOHj74RYlhQm1TCXLlqvzKkvT2oQ1bk7tUUqoR +ozRxVzdL9oKWLzvR4LF8S67i35JlnOPU1AhcxD2+5ywRvTpugPyCE1mZOeVLHlGW +2pdmSKbdd2gm2iSfadDPJ1DPdHLp844jRg/D6XDs4rlBnt9FjMWaXYo+ELmokoYe +Yljv2MGfy6zsb5iKcNsx+llu04xGXfZ9BAuG+aT6DLCIcDIVvE0d6asc4Lz1xZli +BrgyB8el2a/PomPbbf1vI2vtDi3Rg/pQhu/2++ODI08jI9Rudz1EltQQ4Lo38Ton +nSZegTAy6afXiEh2ty09KxMo4sWs+F2I46e5Q3zGY9b/K19bbQTFxeBf2Rfwa8BF +cf8Xs+DlcOMz5w0U2iBQfT1cV7dWLlaop7avYkpQ0fLa1pConlNhpguezcaAB8Lb +VCfpoTh6VfHRtCLokQlkq0mlKPUSlMr/JAyVdvppp/T6Abt0VirM9ILV -----END ENCRYPTED PRIVATE KEY----- diff --git a/test/fixtures/module-load-order/file1.js b/test/fixtures/module-load-order/file1.js index d4ab32cb7a..d378d84541 100644 --- a/test/fixtures/module-load-order/file1.js +++ b/test/fixtures/module-load-order/file1.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.file1 = 'file1.js'; diff --git a/test/fixtures/module-load-order/file2.js b/test/fixtures/module-load-order/file2.js index 0b1af928ca..e87d59568e 100644 --- a/test/fixtures/module-load-order/file2.js +++ b/test/fixtures/module-load-order/file2.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.file2 = 'file2.js'; diff --git a/test/fixtures/module-load-order/file2/index.js b/test/fixtures/module-load-order/file2/index.js index 20c642bf2e..720da3147a 100644 --- a/test/fixtures/module-load-order/file2/index.js +++ b/test/fixtures/module-load-order/file2/index.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.file2 = 'file2/index.js'; diff --git a/test/fixtures/module-load-order/file3/index.js b/test/fixtures/module-load-order/file3/index.js index 5ec373cad7..2d9936a8d1 100644 --- a/test/fixtures/module-load-order/file3/index.js +++ b/test/fixtures/module-load-order/file3/index.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.file3 = 'file3/index.js'; diff --git a/test/fixtures/module-load-order/file4/index.js b/test/fixtures/module-load-order/file4/index.js index f28889d98a..0ded410d3c 100644 --- a/test/fixtures/module-load-order/file4/index.js +++ b/test/fixtures/module-load-order/file4/index.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.file4 = 'file4/index.js'; diff --git a/test/fixtures/module-load-order/file5/index.js b/test/fixtures/module-load-order/file5/index.js index 737945ffb5..9d3a033941 100644 --- a/test/fixtures/module-load-order/file5/index.js +++ b/test/fixtures/module-load-order/file5/index.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.file5 = 'file5/index.js'; diff --git a/test/fixtures/module-load-order/file6/index.js b/test/fixtures/module-load-order/file6/index.js index 4228429e92..9d890bf4f9 100644 --- a/test/fixtures/module-load-order/file6/index.js +++ b/test/fixtures/module-load-order/file6/index.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.file6 = 'file6/index.js'; diff --git a/test/fixtures/nested-index/one/hello.js b/test/fixtures/nested-index/one/hello.js index f139fee4d2..c0c8c4fb15 100644 --- a/test/fixtures/nested-index/one/hello.js +++ b/test/fixtures/nested-index/one/hello.js @@ -1,2 +1,23 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.hello = 'hello from one!'; diff --git a/test/fixtures/nested-index/one/index.js b/test/fixtures/nested-index/one/index.js index d959a288b1..9beac591df 100644 --- a/test/fixtures/nested-index/one/index.js +++ b/test/fixtures/nested-index/one/index.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.hello = require('./hello').hello; diff --git a/test/fixtures/nested-index/three.js b/test/fixtures/nested-index/three.js index e69de29bb2..dcceb09f9e 100644 --- a/test/fixtures/nested-index/three.js +++ b/test/fixtures/nested-index/three.js @@ -0,0 +1,21 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/test/fixtures/nested-index/three/index.js b/test/fixtures/nested-index/three/index.js index e69de29bb2..dcceb09f9e 100644 --- a/test/fixtures/nested-index/three/index.js +++ b/test/fixtures/nested-index/three/index.js @@ -0,0 +1,21 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/test/fixtures/nested-index/two/hello.js b/test/fixtures/nested-index/two/hello.js index 8ec14b950e..339276cc7a 100644 --- a/test/fixtures/nested-index/two/hello.js +++ b/test/fixtures/nested-index/two/hello.js @@ -1,2 +1,23 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.hello = 'hello from two!'; diff --git a/test/fixtures/nested-index/two/index.js b/test/fixtures/nested-index/two/index.js index d959a288b1..9beac591df 100644 --- a/test/fixtures/nested-index/two/index.js +++ b/test/fixtures/nested-index/two/index.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.hello = require('./hello').hello; diff --git a/test/fixtures/net-fd-passing-receiver.js b/test/fixtures/net-fd-passing-receiver.js index e22d1883ed..04a143c180 100644 --- a/test/fixtures/net-fd-passing-receiver.js +++ b/test/fixtures/net-fd-passing-receiver.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + process.mixin(require('../common')); net = require('net'); diff --git a/test/fixtures/node_modules/asdf.js b/test/fixtures/node_modules/asdf.js index 67e2ea21ed..6cf68cadb4 100644 --- a/test/fixtures/node_modules/asdf.js +++ b/test/fixtures/node_modules/asdf.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + console.error(__filename); console.error(module.paths.join('\n')+'\n'); throw new Error('Should not ever get here.'); diff --git a/test/fixtures/node_modules/bar.js b/test/fixtures/node_modules/bar.js index 0a9ce329c5..8162473a06 100644 --- a/test/fixtures/node_modules/bar.js +++ b/test/fixtures/node_modules/bar.js @@ -1,2 +1,23 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + console.error(__filename); console.error(module.paths.join('\n')+'\n'); diff --git a/test/fixtures/node_modules/baz/index.js b/test/fixtures/node_modules/baz/index.js index ae2351d276..44acc13da6 100644 --- a/test/fixtures/node_modules/baz/index.js +++ b/test/fixtures/node_modules/baz/index.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + console.error(__filename); console.error(module.paths.join('\n')+'\n'); // this should work, and get the one that doesn't throw diff --git a/test/fixtures/node_modules/baz/node_modules/asdf.js b/test/fixtures/node_modules/baz/node_modules/asdf.js index 0a9ce329c5..8162473a06 100644 --- a/test/fixtures/node_modules/baz/node_modules/asdf.js +++ b/test/fixtures/node_modules/baz/node_modules/asdf.js @@ -1,2 +1,23 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + console.error(__filename); console.error(module.paths.join('\n')+'\n'); diff --git a/test/fixtures/node_modules/foo.js b/test/fixtures/node_modules/foo.js index d8114a7139..c554bdd29b 100644 --- a/test/fixtures/node_modules/foo.js +++ b/test/fixtures/node_modules/foo.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + console.error(__filename); console.error(module.paths.join('\n')+'\n'); var assert = require('assert'); diff --git a/test/fixtures/node_modules/node_modules/bar.js b/test/fixtures/node_modules/node_modules/bar.js index 67e2ea21ed..6cf68cadb4 100644 --- a/test/fixtures/node_modules/node_modules/bar.js +++ b/test/fixtures/node_modules/node_modules/bar.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + console.error(__filename); console.error(module.paths.join('\n')+'\n'); throw new Error('Should not ever get here.'); diff --git a/test/fixtures/not-main-module.js b/test/fixtures/not-main-module.js index 3da57f4428..0bee402728 100644 --- a/test/fixtures/not-main-module.js +++ b/test/fixtures/not-main-module.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var assert = require('assert'); assert.notEqual(module, require.main, 'require.main should not == module'); assert.notEqual(module, process.mainModule, diff --git a/test/fixtures/packages/main-index/package-main-module/index.js b/test/fixtures/packages/main-index/package-main-module/index.js index a9fe79564c..f65d3a27d3 100644 --- a/test/fixtures/packages/main-index/package-main-module/index.js +++ b/test/fixtures/packages/main-index/package-main-module/index.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.ok = "ok" diff --git a/test/fixtures/packages/main/package-main-module.js b/test/fixtures/packages/main/package-main-module.js index a9fe79564c..f65d3a27d3 100644 --- a/test/fixtures/packages/main/package-main-module.js +++ b/test/fixtures/packages/main/package-main-module.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.ok = "ok" diff --git a/test/fixtures/person.jpg b/test/fixtures/person.jpg new file mode 100644 index 0000000000..4f71881c55 Binary files /dev/null and b/test/fixtures/person.jpg differ diff --git a/test/fixtures/print-10-lines.js b/test/fixtures/print-10-lines.js index 0aaf3ef293..d483fe6bff 100644 --- a/test/fixtures/print-10-lines.js +++ b/test/fixtures/print-10-lines.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + for (var i = 0; i < 10; i++) { console.log('count ' + i); } diff --git a/test/fixtures/print-chars-from-buffer.js b/test/fixtures/print-chars-from-buffer.js index e3b5647d6e..f7486aae92 100644 --- a/test/fixtures/print-chars-from-buffer.js +++ b/test/fixtures/print-chars-from-buffer.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/fixtures/print-chars.js b/test/fixtures/print-chars.js index ec97604921..a3bc8add2d 100644 --- a/test/fixtures/print-chars.js +++ b/test/fixtures/print-chars.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/fixtures/readdir/testing.js b/test/fixtures/readdir/testing.js index e69de29bb2..dcceb09f9e 100644 --- a/test/fixtures/readdir/testing.js +++ b/test/fixtures/readdir/testing.js @@ -0,0 +1,21 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/test/fixtures/recvfd.js b/test/fixtures/recvfd.js index f9ac1fbca7..8f7b066129 100644 --- a/test/fixtures/recvfd.js +++ b/test/fixtures/recvfd.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // See test/simple/test-sendfd.js for a complete description of what this // script is doing and how it fits into the test as a whole. diff --git a/test/fixtures/require-path/p1/bar.js b/test/fixtures/require-path/p1/bar.js index 2e8ccf9a2f..c66438783c 100644 --- a/test/fixtures/require-path/p1/bar.js +++ b/test/fixtures/require-path/p1/bar.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var path = require('path'); require.paths.unshift(path.join(__dirname, '../p2')); diff --git a/test/fixtures/require-path/p1/foo.js b/test/fixtures/require-path/p1/foo.js index 43a7e4b8ca..b0a5a2a575 100644 --- a/test/fixtures/require-path/p1/foo.js +++ b/test/fixtures/require-path/p1/foo.js @@ -1,2 +1,23 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + require.paths.unshift(__dirname); exports.bar = require('bar'); diff --git a/test/fixtures/require-path/p2/bar.js b/test/fixtures/require-path/p2/bar.js index 2ffb5ed1b2..9547039691 100644 --- a/test/fixtures/require-path/p2/bar.js +++ b/test/fixtures/require-path/p2/bar.js @@ -1,2 +1,23 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + exports.INBAR = __filename; diff --git a/test/fixtures/require-path/p2/foo.js b/test/fixtures/require-path/p2/foo.js index 0ee9298bc7..afd44014d7 100644 --- a/test/fixtures/require-path/p2/foo.js +++ b/test/fixtures/require-path/p2/foo.js @@ -1,2 +1,23 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + require.paths.unshift(__dirname); exports.bar = require('bar'); // surprise! this is not /p2/bar, this is /p1/bar diff --git a/test/fixtures/semicolon.js b/test/fixtures/semicolon.js index 092bc2b041..79a3084499 100644 --- a/test/fixtures/semicolon.js +++ b/test/fixtures/semicolon.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + ; diff --git a/test/fixtures/should_exit.js b/test/fixtures/should_exit.js index 1a37a575c4..1d80c5210b 100644 --- a/test/fixtures/should_exit.js +++ b/test/fixtures/should_exit.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + function tmp() {} process.addListener('SIGINT', tmp); process.removeListener('SIGINT', tmp); diff --git a/test/fixtures/stdio-filter.js b/test/fixtures/stdio-filter.js index 0078b5fa0a..c6daf9aedf 100644 --- a/test/fixtures/stdio-filter.js +++ b/test/fixtures/stdio-filter.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var util = require('util'); var regexIn = process.argv[2]; diff --git a/test/fixtures/test-init-index/index.js b/test/fixtures/test-init-index/index.js index 1531994d80..702035d81f 100644 --- a/test/fixtures/test-init-index/index.js +++ b/test/fixtures/test-init-index/index.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + (function() { require('util').print('Loaded successfully!'); })(); \ No newline at end of file diff --git a/test/fixtures/test-init-native/fs.js b/test/fixtures/test-init-native/fs.js index 512a18ef41..df106c3bc5 100644 --- a/test/fixtures/test-init-native/fs.js +++ b/test/fixtures/test-init-native/fs.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + (function() { var fs = require('fs'); if (fs.readFile) { diff --git a/test/fixtures/throws_error.js b/test/fixtures/throws_error.js index 80055bdf60..b38000894b 100644 --- a/test/fixtures/throws_error.js +++ b/test/fixtures/throws_error.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + throw new Error('blah'); diff --git a/test/fixtures/throws_error1.js b/test/fixtures/throws_error1.js index 80055bdf60..b38000894b 100644 --- a/test/fixtures/throws_error1.js +++ b/test/fixtures/throws_error1.js @@ -1 +1,22 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + throw new Error('blah'); diff --git a/test/fixtures/throws_error2.js b/test/fixtures/throws_error2.js index 6185815341..e1b3a696ec 100644 --- a/test/fixtures/throws_error2.js +++ b/test/fixtures/throws_error2.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + JSON.parse(undefined); diff --git a/test/fixtures/throws_error3.js b/test/fixtures/throws_error3.js index 080d0311fd..a53084c68c 100644 --- a/test/fixtures/throws_error3.js +++ b/test/fixtures/throws_error3.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + process.nextTick(function() { JSON.parse(undefined); }); diff --git a/test/message/2100bytes.js b/test/message/2100bytes.js index 59fe3c1523..2e76d86f92 100644 --- a/test/message/2100bytes.js +++ b/test/message/2100bytes.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var util = require('util'); diff --git a/test/message/hello_world.js b/test/message/hello_world.js index 996e08d51a..4fef1f300a 100644 --- a/test/message/hello_world.js +++ b/test/message/hello_world.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/message/undefined_reference_in_new_context.js b/test/message/undefined_reference_in_new_context.js index f8f6938806..3904bcc124 100644 --- a/test/message/undefined_reference_in_new_context.js +++ b/test/message/undefined_reference_in_new_context.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/pummel/test-child-process-spawn-loop.js b/test/pummel/test-child-process-spawn-loop.js index d619151347..25d0eee5e5 100644 --- a/test/pummel/test-child-process-spawn-loop.js +++ b/test/pummel/test-child-process-spawn-loop.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js index 4dee560e04..92b061ff63 100644 --- a/test/pummel/test-exec.js +++ b/test/pummel/test-exec.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var exec = require('child_process').exec; diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js index b104f4dd46..ada1c22035 100644 --- a/test/pummel/test-http-client-reconnect-bug.js +++ b/test/pummel/test-http-client-reconnect-bug.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/pummel/test-http-upload-timeout.js b/test/pummel/test-http-upload-timeout.js index 06b8e74496..c7dededd07 100644 --- a/test/pummel/test-http-upload-timeout.js +++ b/test/pummel/test-http-upload-timeout.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // This tests setTimeout() by having multiple clients connecting and sending // data in random intervals. Clients are also randomly disconnecting until there // are no more clients left. If no false timeout occurs, this test has passed. diff --git a/test/pummel/test-https-large-response.js b/test/pummel/test-https-large-response.js index 36d78bbeb8..b29114a48b 100644 --- a/test/pummel/test-https-large-response.js +++ b/test/pummel/test-https-large-response.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index 0a9dc980d8..d1cf3cfbc5 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // This test requires the program 'ab' var common = require('../common'); var assert = require('assert'); diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js index 1fd2bd13f9..a5f7feec08 100644 --- a/test/pummel/test-net-many-clients.js +++ b/test/pummel/test-net-many-clients.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/pummel/test-net-pause.js b/test/pummel/test-net-pause.js index 2ecb5285cd..0f5577e3cb 100644 --- a/test/pummel/test-net-pause.js +++ b/test/pummel/test-net-pause.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/pummel/test-net-pingpong-delay.js b/test/pummel/test-net-pingpong-delay.js index 215d712f47..06d2d34eef 100644 --- a/test/pummel/test-net-pingpong-delay.js +++ b/test/pummel/test-net-pingpong-delay.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index 208e69b573..99eeb3a790 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js index c53a592aee..57417f7f2d 100644 --- a/test/pummel/test-net-throttle.js +++ b/test/pummel/test-net-throttle.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js index 9a5f6f470a..8a3bf467b7 100644 --- a/test/pummel/test-net-timeout.js +++ b/test/pummel/test-net-timeout.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/pummel/test-next-tick-loops-quick.js b/test/pummel/test-next-tick-loops-quick.js index 3a95319732..2b941d017b 100644 --- a/test/pummel/test-next-tick-loops-quick.js +++ b/test/pummel/test-next-tick-loops-quick.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js index 4264835faa..2ce0c08245 100644 --- a/test/pummel/test-timers.js +++ b/test/pummel/test-timers.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/pummel/test-tls-throttle.js b/test/pummel/test-tls-throttle.js index ff0e5c35aa..4f353cadd7 100644 --- a/test/pummel/test-tls-throttle.js +++ b/test/pummel/test-tls-throttle.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Server sends a large string. Client counts bytes and pauses every few // seconds. Makes sure that pause and resume work properly. var common = require('../common'); diff --git a/test/pummel/test-vm-memleak.js b/test/pummel/test-vm-memleak.js index e2705f48b5..e946f19603 100644 --- a/test/pummel/test-vm-memleak.js +++ b/test/pummel/test-vm-memleak.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var assert = require('assert'); var common = require('../common'); diff --git a/test/pummel/test-watch-file.js b/test/pummel/test-watch-file.js index 05eb60ed6e..04a7f13e21 100644 --- a/test/pummel/test-watch-file.js +++ b/test/pummel/test-watch-file.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/path.js b/test/simple/path.js index c87f3e1926..d998c39713 100644 --- a/test/simple/path.js +++ b/test/simple/path.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // This is actually more a fixture than a test. It is used to make // sure that require('./path') and require('path') do different things. // It has to be in the same directory as the test 'test-module-loading.js' diff --git a/test/simple/test-assert.js b/test/simple/test-assert.js index e2aa645d4a..7ccaee8de5 100644 --- a/test/simple/test-assert.js +++ b/test/simple/test-assert.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var a = require('assert'); diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js index f60d29c820..72fd2a43cf 100644 --- a/test/simple/test-buffer.js +++ b/test/simple/test-buffer.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-c-ares.js b/test/simple/test-c-ares.js index 83dd897edd..1f68c53ba2 100644 --- a/test/simple/test-c-ares.js +++ b/test/simple/test-c-ares.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-chdir.js b/test/simple/test-chdir.js index 8d699369f3..4d0c52136a 100644 --- a/test/simple/test-chdir.js +++ b/test/simple/test-chdir.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-child-process-buffering.js b/test/simple/test-child-process-buffering.js index 92f62d8c05..f377273686 100644 --- a/test/simple/test-child-process-buffering.js +++ b/test/simple/test-child-process-buffering.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-child-process-custom-fds.js b/test/simple/test-child-process-custom-fds.js index eb73569171..97b70ee272 100644 --- a/test/simple/test-child-process-custom-fds.js +++ b/test/simple/test-child-process-custom-fds.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-child-process-cwd.js b/test/simple/test-child-process-cwd.js index ce4eb0133a..eeca22e7af 100644 --- a/test/simple/test-child-process-cwd.js +++ b/test/simple/test-child-process-cwd.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; diff --git a/test/simple/test-child-process-deprecated-api.js b/test/simple/test-child-process-deprecated-api.js index a43580e818..5f26b12c9d 100644 --- a/test/simple/test-child-process-deprecated-api.js +++ b/test/simple/test-child-process-deprecated-api.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; diff --git a/test/simple/test-child-process-double-pipe.js b/test/simple/test-child-process-double-pipe.js index bf171e9c23..55408ddc85 100644 --- a/test/simple/test-child-process-double-pipe.js +++ b/test/simple/test-child-process-double-pipe.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var assert = require('assert'), util = require('util'), spawn = require('child_process').spawn; diff --git a/test/simple/test-child-process-env.js b/test/simple/test-child-process-env.js index 1f5ffef4db..b8d3a92ae7 100644 --- a/test/simple/test-child-process-env.js +++ b/test/simple/test-child-process-env.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-child-process-exec-cwd.js b/test/simple/test-child-process-exec-cwd.js index bbca06de46..80c42bc610 100644 --- a/test/simple/test-child-process-exec-cwd.js +++ b/test/simple/test-child-process-exec-cwd.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + require('../common'); var assert = require('assert'); var exec = require('child_process').exec; diff --git a/test/simple/test-child-process-exec-env.js b/test/simple/test-child-process-exec-env.js index ec4ef02964..64ec327550 100644 --- a/test/simple/test-child-process-exec-env.js +++ b/test/simple/test-child-process-exec-env.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var exec = require('child_process').exec; diff --git a/test/simple/test-child-process-exit-code.js b/test/simple/test-child-process-exit-code.js index e579f89ae0..b86d3e8a1c 100644 --- a/test/simple/test-child-process-exit-code.js +++ b/test/simple/test-child-process-exit-code.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; diff --git a/test/simple/test-child-process-ipc.js b/test/simple/test-child-process-ipc.js index 60840290ea..a3f560cea3 100644 --- a/test/simple/test-child-process-ipc.js +++ b/test/simple/test-child-process-ipc.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-child-process-kill.js b/test/simple/test-child-process-kill.js index e3c3e0ba8f..65d858a864 100644 --- a/test/simple/test-child-process-kill.js +++ b/test/simple/test-child-process-kill.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-child-process-stdin.js b/test/simple/test-child-process-stdin.js index 5271ecd700..6352366674 100644 --- a/test/simple/test-child-process-stdin.js +++ b/test/simple/test-child-process-stdin.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-child-process-stdout-flush.js b/test/simple/test-child-process-stdout-flush.js index f75954043b..096a583081 100644 --- a/test/simple/test-child-process-stdout-flush.js +++ b/test/simple/test-child-process-stdout-flush.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-cli-eval.js b/test/simple/test-cli-eval.js index c4e9247f2a..27763adaf5 100644 --- a/test/simple/test-cli-eval.js +++ b/test/simple/test-cli-eval.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + assert = require('assert'); child = require('child_process'); diff --git a/test/simple/test-console.js b/test/simple/test-console.js index 244a7dfbee..adde7246b1 100644 --- a/test/simple/test-console.js +++ b/test/simple/test-console.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-crypto.js b/test/simple/test-crypto.js index 6083cac64f..647ba2060e 100644 --- a/test/simple/test-crypto.js +++ b/test/simple/test-crypto.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); @@ -119,3 +140,7 @@ txt += decipher.final('utf8'); assert.equal(txt, plaintext, 'encryption and decryption with key and iv'); +// update() should only take buffers / strings +assert.throws(function() { + crypto.createHash('sha1').update({foo: 'bar'}); +}, /string or buffer/); diff --git a/test/simple/test-debugger-client.js b/test/simple/test-debugger-client.js index 3890bf10be..ed039687c4 100644 --- a/test/simple/test-debugger-client.js +++ b/test/simple/test-debugger-client.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var debug = require('_debugger'); diff --git a/test/simple/test-delayed-require.js b/test/simple/test-delayed-require.js index 7d937e67b2..2724557b8d 100644 --- a/test/simple/test-delayed-require.js +++ b/test/simple/test-delayed-require.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-dgram-multicast.js b/test/simple/test-dgram-multicast.js index 2246ccf0ac..50c957d47c 100644 --- a/test/simple/test-dgram-multicast.js +++ b/test/simple/test-dgram-multicast.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-dgram-pingpong.js b/test/simple/test-dgram-pingpong.js index f27e4ce895..2ff3aec009 100644 --- a/test/simple/test-dgram-pingpong.js +++ b/test/simple/test-dgram-pingpong.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var Buffer = require('buffer').Buffer; diff --git a/test/simple/test-dgram-udp4.js b/test/simple/test-dgram-udp4.js index bad2b8850b..e4fd634f46 100644 --- a/test/simple/test-dgram-udp4.js +++ b/test/simple/test-dgram-udp4.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-dgram-unix-anon.js b/test/simple/test-dgram-unix-anon.js index 1a8b5e3a57..428a62bb2f 100644 --- a/test/simple/test-dgram-unix-anon.js +++ b/test/simple/test-dgram-unix-anon.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-dgram-unix.js b/test/simple/test-dgram-unix.js index f2a24a9c36..382906369d 100644 --- a/test/simple/test-dgram-unix.js +++ b/test/simple/test-dgram-unix.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-eio-race.js b/test/simple/test-eio-race.js index daf7a41b0b..f4c560cd9e 100644 --- a/test/simple/test-eio-race.js +++ b/test/simple/test-eio-race.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-eio-race2.js b/test/simple/test-eio-race2.js index 20444eea08..d6439f14cd 100644 --- a/test/simple/test-eio-race2.js +++ b/test/simple/test-eio-race2.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-eio-race4.js b/test/simple/test-eio-race4.js index 3e7b928eed..f1204e5850 100644 --- a/test/simple/test-eio-race4.js +++ b/test/simple/test-eio-race4.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var fs = require('fs'); diff --git a/test/simple/test-error-reporting.js b/test/simple/test-error-reporting.js index bdfab22ed3..8117b4527a 100644 --- a/test/simple/test-error-reporting.js +++ b/test/simple/test-error-reporting.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var exec = require('child_process').exec; diff --git a/test/simple/test-event-emitter-add-listeners.js b/test/simple/test-event-emitter-add-listeners.js index 7c4b7232eb..5006bd804f 100644 --- a/test/simple/test-event-emitter-add-listeners.js +++ b/test/simple/test-event-emitter-add-listeners.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var events = require('events'); @@ -23,6 +44,12 @@ console.log('start'); e.emit('hello', 'a', 'b'); + +// just make sure that this doesn't throw: +var f = new events.EventEmitter(); +f.setMaxListeners(0); + + process.addListener('exit', function() { assert.deepEqual(['hello'], events_new_listener_emited); assert.equal(1, times_hello_emited); diff --git a/test/simple/test-event-emitter-modify-in-emit.js b/test/simple/test-event-emitter-modify-in-emit.js index 0c13f19b91..15d350eb44 100644 --- a/test/simple/test-event-emitter-modify-in-emit.js +++ b/test/simple/test-event-emitter-modify-in-emit.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var events = require('events'); diff --git a/test/simple/test-event-emitter-num-args.js b/test/simple/test-event-emitter-num-args.js index e6907e80fb..375422eb9e 100644 --- a/test/simple/test-event-emitter-num-args.js +++ b/test/simple/test-event-emitter-num-args.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var events = require('events'); diff --git a/test/simple/test-event-emitter-once.js b/test/simple/test-event-emitter-once.js index 204b2d6c30..fb17237e0b 100644 --- a/test/simple/test-event-emitter-once.js +++ b/test/simple/test-event-emitter-once.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var events = require('events'); diff --git a/test/simple/test-event-emitter-remove-listeners.js b/test/simple/test-event-emitter-remove-listeners.js index 352290864f..0e4b8cb41b 100644 --- a/test/simple/test-event-emitter-remove-listeners.js +++ b/test/simple/test-event-emitter-remove-listeners.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var events = require('events'); diff --git a/test/simple/test-exception-handler.js b/test/simple/test-exception-handler.js index 6c4923e8e5..294ecafded 100644 --- a/test/simple/test-exception-handler.js +++ b/test/simple/test-exception-handler.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-exception-handler2.js b/test/simple/test-exception-handler2.js index 77f3eb1d5c..6b8afa909f 100644 --- a/test/simple/test-exception-handler2.js +++ b/test/simple/test-exception-handler2.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-exec-max-buffer.js b/test/simple/test-exec-max-buffer.js index a5a24eabea..a6537e9f92 100644 --- a/test/simple/test-exec-max-buffer.js +++ b/test/simple/test-exec-max-buffer.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var exec = require('child_process').exec; var assert = require('assert'); diff --git a/test/simple/test-executable-path.js b/test/simple/test-executable-path.js index 0cbe229819..8076b2d53b 100644 --- a/test/simple/test-executable-path.js +++ b/test/simple/test-executable-path.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-file-read-noexist.js b/test/simple/test-file-read-noexist.js index 64fdb453f0..7fad5dd3fa 100644 --- a/test/simple/test-file-read-noexist.js +++ b/test/simple/test-file-read-noexist.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-file-write-stream.js b/test/simple/test-file-write-stream.js index 80a3206cc3..0fb5b45a6b 100644 --- a/test/simple/test-file-write-stream.js +++ b/test/simple/test-file-write-stream.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-fs-chmod.js b/test/simple/test-fs-chmod.js index ded7bf6724..7616c8b3f8 100644 --- a/test/simple/test-fs-chmod.js +++ b/test/simple/test-fs-chmod.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-fs-error-messages.js b/test/simple/test-fs-error-messages.js index 5b3553d3fc..0a88c47988 100644 --- a/test/simple/test-fs-error-messages.js +++ b/test/simple/test-fs-error-messages.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-fs-fsync.js b/test/simple/test-fs-fsync.js index 712dc8b11b..c5877ce1d4 100644 --- a/test/simple/test-fs-fsync.js +++ b/test/simple/test-fs-fsync.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-fs-open.js b/test/simple/test-fs-open.js index 2971d4608e..02ae5d73f9 100644 --- a/test/simple/test-fs-open.js +++ b/test/simple/test-fs-open.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var fs = require('fs'); diff --git a/test/simple/test-fs-read-buffer.js b/test/simple/test-fs-read-buffer.js index c78013b8d2..a1a86c6972 100644 --- a/test/simple/test-fs-read-buffer.js +++ b/test/simple/test-fs-read-buffer.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'), diff --git a/test/simple/test-fs-read-file-sync-hostname.js b/test/simple/test-fs-read-file-sync-hostname.js index a2c8ac5da7..758e2aedd8 100644 --- a/test/simple/test-fs-read-file-sync-hostname.js +++ b/test/simple/test-fs-read-file-sync-hostname.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var fs = require('fs'); diff --git a/test/simple/test-fs-read-file-sync.js b/test/simple/test-fs-read-file-sync.js index cf6ab72dbf..518d32cc18 100644 --- a/test/simple/test-fs-read-file-sync.js +++ b/test/simple/test-fs-read-file-sync.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-fs-read-stream.js b/test/simple/test-fs-read-stream.js index 026afcb2a0..8b821c01d8 100644 --- a/test/simple/test-fs-read-stream.js +++ b/test/simple/test-fs-read-stream.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-fs-read.js b/test/simple/test-fs-read.js index c6be504471..8e1960d9c3 100644 --- a/test/simple/test-fs-read.js +++ b/test/simple/test-fs-read.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'), diff --git a/test/simple/test-fs-readfile-empty.js b/test/simple/test-fs-readfile-empty.js index bf7da45fca..31b83567ee 100644 --- a/test/simple/test-fs-readfile-empty.js +++ b/test/simple/test-fs-readfile-empty.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-fs-realpath.js b/test/simple/test-fs-realpath.js index 5d412785db..eae4540889 100644 --- a/test/simple/test-fs-realpath.js +++ b/test/simple/test-fs-realpath.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var fs = require('fs'); diff --git a/test/simple/test-fs-sir-writes-alot.js b/test/simple/test-fs-sir-writes-alot.js index 9df95a77bd..e16f56bdc8 100644 --- a/test/simple/test-fs-sir-writes-alot.js +++ b/test/simple/test-fs-sir-writes-alot.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var fs = require('fs'); var assert = require('assert'); diff --git a/test/simple/test-fs-stat.js b/test/simple/test-fs-stat.js index 7be70766bc..65332757b1 100644 --- a/test/simple/test-fs-stat.js +++ b/test/simple/test-fs-stat.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var fs = require('fs'); diff --git a/test/simple/test-fs-symlink.js b/test/simple/test-fs-symlink.js index 6092af241e..bb0eaadd0b 100644 --- a/test/simple/test-fs-symlink.js +++ b/test/simple/test-fs-symlink.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-fs-write-buffer.js b/test/simple/test-fs-write-buffer.js index 0452c46cb9..3021c3a066 100644 --- a/test/simple/test-fs-write-buffer.js +++ b/test/simple/test-fs-write-buffer.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'), diff --git a/test/simple/test-fs-write-file-buffer.js b/test/simple/test-fs-write-file-buffer.js index bdddba9524..dfe7cf5f30 100644 --- a/test/simple/test-fs-write-file-buffer.js +++ b/test/simple/test-fs-write-file-buffer.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var join = require('path').join; var util = require('util'); diff --git a/test/simple/test-fs-write-file.js b/test/simple/test-fs-write-file.js index 9fe8bcd808..780ac6c149 100644 --- a/test/simple/test-fs-write-file.js +++ b/test/simple/test-fs-write-file.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var fs = require('fs'); diff --git a/test/simple/test-fs-write-stream-end.js b/test/simple/test-fs-write-stream-end.js new file mode 100644 index 0000000000..6c0f29c344 --- /dev/null +++ b/test/simple/test-fs-write-stream-end.js @@ -0,0 +1,46 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var common = require('../common'); +var assert = require('assert'); + +var path = require('path'), + fs = require('fs'); + +var writeEndOk = false; +(function() { + debugger; + var file = path.join(common.tmpDir, 'write-end-test.txt'); + var stream = fs.createWriteStream(file); + + stream.end('a\n', 'utf8', function() { + var content = fs.readFileSync(file, 'utf8'); + assert.equal(content, 'a\n'); + writeEndOk = true; + }); + +})(); + + +process.on('exit', function() { + assert.ok(writeEndOk); +}); + diff --git a/test/simple/test-fs-write-stream.js b/test/simple/test-fs-write-stream.js index b038bf0303..7a257277ec 100644 --- a/test/simple/test-fs-write-stream.js +++ b/test/simple/test-fs-write-stream.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-fs-write-sync.js b/test/simple/test-fs-write-sync.js index 59e2f90f92..c3dbfe3ba6 100644 --- a/test/simple/test-fs-write-sync.js +++ b/test/simple/test-fs-write-sync.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-fs-write.js b/test/simple/test-fs-write.js index 706c91cc26..dbcdbe4838 100644 --- a/test/simple/test-fs-write.js +++ b/test/simple/test-fs-write.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-global.js b/test/simple/test-global.js index a1ddc72f62..4cc9799ba5 100644 --- a/test/simple/test-global.js +++ b/test/simple/test-global.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-http-1.0.js b/test/simple/test-http-1.0.js index 43c3f7535d..7d3cca78be 100644 --- a/test/simple/test-http-1.0.js +++ b/test/simple/test-http-1.0.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-http-304.js b/test/simple/test-http-304.js index a2cc95e57d..9f53a05662 100644 --- a/test/simple/test-http-304.js +++ b/test/simple/test-http-304.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-http-abort-client.js b/test/simple/test-http-abort-client.js index e54a50631e..54d5af6988 100644 --- a/test/simple/test-http-abort-client.js +++ b/test/simple/test-http-abort-client.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require("../common"); var http = require("http"); var assert = require("assert"); diff --git a/test/simple/test-http-agent.js b/test/simple/test-http-agent.js index 5e12d2e2c6..2425a3cd54 100644 --- a/test/simple/test-http-agent.js +++ b/test/simple/test-http-agent.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-allow-req-after-204-res.js b/test/simple/test-http-allow-req-after-204-res.js index c7882610d6..c9cbf9b5d1 100644 --- a/test/simple/test-http-allow-req-after-204-res.js +++ b/test/simple/test-http-allow-req-after-204-res.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var http = require('http'); var assert = require('assert'); diff --git a/test/simple/test-http-blank-header.js b/test/simple/test-http-blank-header.js index dd8091fecb..4b1282650f 100644 --- a/test/simple/test-http-blank-header.js +++ b/test/simple/test-http-blank-header.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-buffer-sanity.js b/test/simple/test-http-buffer-sanity.js index 57a813f8a3..f458f9424f 100644 --- a/test/simple/test-http-buffer-sanity.js +++ b/test/simple/test-http-buffer-sanity.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-cat.js b/test/simple/test-http-cat.js index 2ab7618606..78ea8e865b 100644 --- a/test/simple/test-http-cat.js +++ b/test/simple/test-http-cat.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-chunked.js b/test/simple/test-http-chunked.js index 4801d54d58..7fa89ea84b 100644 --- a/test/simple/test-http-chunked.js +++ b/test/simple/test-http-chunked.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-client-abort.js b/test/simple/test-http-client-abort.js index 3e0199b327..d8436979f4 100644 --- a/test/simple/test-http-client-abort.js +++ b/test/simple/test-http-client-abort.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-client-parse-error.js b/test/simple/test-http-client-parse-error.js index 9468bde441..1f845debef 100644 --- a/test/simple/test-http-client-parse-error.js +++ b/test/simple/test-http-client-parse-error.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-http-client-race-2.js b/test/simple/test-http-client-race-2.js index 136c02c1ab..547ef55d8a 100644 --- a/test/simple/test-http-client-race-2.js +++ b/test/simple/test-http-client-race-2.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-client-race.js b/test/simple/test-http-client-race.js index 627905e78e..1bed5ccefa 100644 --- a/test/simple/test-http-client-race.js +++ b/test/simple/test-http-client-race.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-client-upload-buf.js b/test/simple/test-http-client-upload-buf.js index 89778fcf0f..73c5e57abc 100644 --- a/test/simple/test-http-client-upload-buf.js +++ b/test/simple/test-http-client-upload-buf.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-client-upload.js b/test/simple/test-http-client-upload.js index 3bd9bed0a9..d1f1264980 100644 --- a/test/simple/test-http-client-upload.js +++ b/test/simple/test-http-client-upload.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-contentLength0.js b/test/simple/test-http-contentLength0.js index a7e2b5acdc..ce11afc347 100644 --- a/test/simple/test-http-contentLength0.js +++ b/test/simple/test-http-contentLength0.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var http = require('http'); diff --git a/test/simple/test-http-curl-chunk-problem.js b/test/simple/test-http-curl-chunk-problem.js index 13c18acc16..794b320ba7 100644 --- a/test/simple/test-http-curl-chunk-problem.js +++ b/test/simple/test-http-curl-chunk-problem.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + if (!process.versions.openssl) { console.error("Skipping because node compiled without OpenSSL."); process.exit(0); diff --git a/test/simple/test-http-default-encoding.js b/test/simple/test-http-default-encoding.js index b2a08f1988..7bf23968c6 100644 --- a/test/simple/test-http-default-encoding.js +++ b/test/simple/test-http-default-encoding.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-dns-fail.js b/test/simple/test-http-dns-fail.js index 3b8ebb9b5a..6b15af9cac 100644 --- a/test/simple/test-http-dns-fail.js +++ b/test/simple/test-http-dns-fail.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + /* * Repeated requests for a domain that fails to resolve * should trigger the error event after each attempt. @@ -24,6 +45,7 @@ function httpreq(count) { req.on('error', function(e){ console.log(e.message); + assert.strictEqual(e.code, 'ENOTFOUND'); hadError++ httpreq(count + 1) }) diff --git a/test/simple/test-http-eof-on-connect.js b/test/simple/test-http-eof-on-connect.js index 9bb5bbb8f0..e6a3150f8e 100644 --- a/test/simple/test-http-eof-on-connect.js +++ b/test/simple/test-http-eof-on-connect.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-http-exceptions.js b/test/simple/test-http-exceptions.js index e723496e54..4cc3a4ccee 100644 --- a/test/simple/test-http-exceptions.js +++ b/test/simple/test-http-exceptions.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-expect-continue.js b/test/simple/test-http-expect-continue.js index e15918fbfe..f313a16d2c 100644 --- a/test/simple/test-http-expect-continue.js +++ b/test/simple/test-http-expect-continue.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-extra-response.js b/test/simple/test-http-extra-response.js index 741372f65a..aa10bf3ec0 100644 --- a/test/simple/test-http-extra-response.js +++ b/test/simple/test-http-extra-response.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-full-response.js b/test/simple/test-http-full-response.js index 90c8332821..c52664c499 100644 --- a/test/simple/test-http-full-response.js +++ b/test/simple/test-http-full-response.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); // This test requires the program 'ab' diff --git a/test/simple/test-http-get-pipeline-problem.js b/test/simple/test-http-get-pipeline-problem.js new file mode 100644 index 0000000000..9d25075729 --- /dev/null +++ b/test/simple/test-http-get-pipeline-problem.js @@ -0,0 +1,108 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// We are demonstrating a problem with http.get when queueing up many +// transfers. The server simply introduces some delay and sends a file. +// Note this is demonstarted with connection: close. +var common = require('../common'); +var assert = require('assert'); +var http = require('http'); +var fs = require('fs'); + +var image = fs.readFileSync(common.fixturesDir + '/person.jpg'); + +console.log("image.length = " + image.length); + +var total = 100; +var requests = 0, responses = 0; + +var server = http.Server(function(req, res) { + if (++requests == total) { + server.close(); + } + + setTimeout(function() { + res.writeHead(200, { + 'content-type': 'image/jpeg', + 'connection': 'close', + 'content-length': image.length + }); + res.end(image); + }, 1); +}); + + +server.listen(common.PORT, function() { + for (var i = 0; i < total; i++) { + (function() { + var x = i; + + var opts = { + port: common.PORT, + headers: { connection: 'close' } + }; + + http.get(opts, function(res) { + console.error("recv " + x); + var s = fs.createWriteStream(common.tmpDir + '/' + x + ".jpg"); + res.pipe(s); + + // TODO there should be a callback to pipe() that will allow + // us to get a callback when the pipe is finished. + res.on('end', function() { + console.error("done " + x); + if (++responses == total) { + s.on('close', checkFiles); + } + }); + }).on('error', function(e) { + console.error('error! ', e.message) + throw e; + }); + })(); + } +}); + + +var checkedFiles = false; +function checkFiles() { + // Should see 1.jpg, 2.jpg, ..., 100.jpg in tmpDir + var files = fs.readdirSync(common.tmpDir); + assert.equal(total, files.length); + + for (var i = 0; i < total; i++) { + var fn = i + '.jpg'; + assert.ok(files.indexOf(fn) >= 0, "couldn't find '" + fn + "'"); + var stat = fs.statSync(common.tmpDir + '/' + fn); + assert.equal(image.length, stat.size, + "size doesn't match on '" + fn + + "'. Got " + stat.size + " bytes"); + } + + checkedFiles = true; +} + + +process.on('exit', function() { + assert.equal(total, requests); + assert.equal(total, responses); + assert.ok(checkedFiles); +}); diff --git a/test/simple/test-http-head-request.js b/test/simple/test-http-head-request.js index 627ede43ce..b42ae06e5e 100644 --- a/test/simple/test-http-head-request.js +++ b/test/simple/test-http-head-request.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-head-response-has-no-body.js b/test/simple/test-http-head-response-has-no-body.js index 17ef4ac95e..5b07341875 100644 --- a/test/simple/test-http-head-response-has-no-body.js +++ b/test/simple/test-http-head-response-has-no-body.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-http-keep-alive-close-on-header.js b/test/simple/test-http-keep-alive-close-on-header.js index 4afe9e2db0..506f207f83 100644 --- a/test/simple/test-http-keep-alive-close-on-header.js +++ b/test/simple/test-http-keep-alive-close-on-header.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-keep-alive.js b/test/simple/test-http-keep-alive.js index 10e7e8824e..ca67fccdb0 100644 --- a/test/simple/test-http-keep-alive.js +++ b/test/simple/test-http-keep-alive.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-malformed-request.js b/test/simple/test-http-malformed-request.js index cabd328719..aca2822af8 100644 --- a/test/simple/test-http-malformed-request.js +++ b/test/simple/test-http-malformed-request.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-http-many-keep-alive-connections.js b/test/simple/test-http-many-keep-alive-connections.js index 9cbda2bda5..a16987081c 100644 --- a/test/simple/test-http-many-keep-alive-connections.js +++ b/test/simple/test-http-many-keep-alive-connections.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-mutable-headers.js b/test/simple/test-http-mutable-headers.js index 844c817b39..947399981d 100644 --- a/test/simple/test-http-mutable-headers.js +++ b/test/simple/test-http-mutable-headers.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-parser.js b/test/simple/test-http-parser.js index d9e9cf0a44..ccfd676a33 100644 --- a/test/simple/test-http-parser.js +++ b/test/simple/test-http-parser.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-http-proxy.js b/test/simple/test-http-proxy.js index 4e4e38a8a4..96a13d03f5 100644 --- a/test/simple/test-http-proxy.js +++ b/test/simple/test-http-proxy.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-request-end.js b/test/simple/test-http-request-end.js index ce9bbd1cab..a24c316555 100644 --- a/test/simple/test-http-request-end.js +++ b/test/simple/test-http-request-end.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-response-close.js b/test/simple/test-http-response-close.js index 7a1b76e299..438bdc4b2d 100644 --- a/test/simple/test-http-response-close.js +++ b/test/simple/test-http-response-close.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-server-multiheaders.js b/test/simple/test-http-server-multiheaders.js index f1fb09e84a..4c09a2f9d5 100644 --- a/test/simple/test-http-server-multiheaders.js +++ b/test/simple/test-http-server-multiheaders.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Verify that the HTTP server implementation handles multiple instances // of the same header as per RFC2616: joining the handful of fields by ', ' // that support it, and dropping duplicates for other fields. diff --git a/test/simple/test-http-server.js b/test/simple/test-http-server.js index 3784439f0b..4eab19dade 100644 --- a/test/simple/test-http-server.js +++ b/test/simple/test-http-server.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-http-set-cookies.js b/test/simple/test-http-set-cookies.js index 748f96bd25..894bfe4374 100644 --- a/test/simple/test-http-set-cookies.js +++ b/test/simple/test-http-set-cookies.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-set-timeout.js b/test/simple/test-http-set-timeout.js index d9b54c2f94..641a425f8d 100644 --- a/test/simple/test-http-set-timeout.js +++ b/test/simple/test-http-set-timeout.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-set-trailers.js b/test/simple/test-http-set-trailers.js index 67fe567f67..89703d0dd9 100644 --- a/test/simple/test-http-set-trailers.js +++ b/test/simple/test-http-set-trailers.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-upgrade-client.js b/test/simple/test-http-upgrade-client.js index 386f1a26fa..541e86b60c 100644 --- a/test/simple/test-http-upgrade-client.js +++ b/test/simple/test-http-upgrade-client.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Verify that the 'upgrade' header causes an 'upgrade' event to be emitted to // the HTTP client. This test uses a raw TCP server to better control server // behavior. diff --git a/test/simple/test-http-upgrade-client2.js b/test/simple/test-http-upgrade-client2.js index bdd585a13c..147a1bd74c 100644 --- a/test/simple/test-http-upgrade-client2.js +++ b/test/simple/test-http-upgrade-client2.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-upgrade-server.js b/test/simple/test-http-upgrade-server.js index 26cd133c03..54b0ed26a0 100644 --- a/test/simple/test-http-upgrade-server.js +++ b/test/simple/test-http-upgrade-server.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-http-upgrade-server2.js b/test/simple/test-http-upgrade-server2.js index fd84ebe8ca..b2d8fbbdf9 100644 --- a/test/simple/test-http-upgrade-server2.js +++ b/test/simple/test-http-upgrade-server2.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-http-wget.js b/test/simple/test-http-wget.js index 3a977ae8ee..d68cbdc12d 100644 --- a/test/simple/test-http-wget.js +++ b/test/simple/test-http-wget.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-http-write-empty-string.js b/test/simple/test-http-write-empty-string.js index 39c2f613d9..a5193a7dc0 100644 --- a/test/simple/test-http-write-empty-string.js +++ b/test/simple/test-http-write-empty-string.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-http.js b/test/simple/test-http.js index 0e2a420fad..df6bb12c34 100644 --- a/test/simple/test-http.js +++ b/test/simple/test-http.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-https-agent.js b/test/simple/test-https-agent.js index 669aa03780..03e5f71cca 100644 --- a/test/simple/test-https-agent.js +++ b/test/simple/test-https-agent.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + if (!process.versions.openssl) { console.error("Skipping because node compiled without OpenSSL."); process.exit(0); diff --git a/test/simple/test-https-connecting-to-http.js b/test/simple/test-https-connecting-to-http.js index de488ff3a9..e7e2a299e3 100644 --- a/test/simple/test-https-connecting-to-http.js +++ b/test/simple/test-https-connecting-to-http.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // This tests the situation where you try to connect a https client // to an http server. You should get an error and exit. var common = require('../common'); diff --git a/test/simple/test-https-eof-for-eom.js b/test/simple/test-https-eof-for-eom.js index d562a21fdb..19f6520a6d 100644 --- a/test/simple/test-https-eof-for-eom.js +++ b/test/simple/test-https-eof-for-eom.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // I hate HTTP. One way of terminating an HTTP response is to not send // a content-length header, not send a transfer-encoding: chunked header, // and simply terminate the TCP connection. That is identity diff --git a/test/simple/test-https-simple.js b/test/simple/test-https-simple.js index 08de464cc9..b9fed4c570 100644 --- a/test/simple/test-https-simple.js +++ b/test/simple/test-https-simple.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + if (!process.versions.openssl) { console.error("Skipping because node compiled without OpenSSL."); process.exit(0); diff --git a/test/simple/test-init.js b/test/simple/test-init.js index e6f3b218f0..55a9b38a33 100644 --- a/test/simple/test-init.js +++ b/test/simple/test-init.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + (function() { var assert = require('assert'), child = require('child_process'), diff --git a/test/simple/test-listen-fd.js b/test/simple/test-listen-fd.js index d7bc1b7829..3e13921b15 100644 --- a/test/simple/test-listen-fd.js +++ b/test/simple/test-listen-fd.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Verify that net.Server.listenFD() can be used to accept connections on an // already-bound, already-listening socket. diff --git a/test/simple/test-memory-usage.js b/test/simple/test-memory-usage.js index de6d6c890c..b65dda45c8 100644 --- a/test/simple/test-memory-usage.js +++ b/test/simple/test-memory-usage.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-mkdir-rmdir.js b/test/simple/test-mkdir-rmdir.js index c731b96ad8..dbafa8275a 100644 --- a/test/simple/test-mkdir-rmdir.js +++ b/test/simple/test-mkdir-rmdir.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-module-loading.js b/test/simple/test-module-loading.js index 4b7062ff33..5f648f0c78 100644 --- a/test/simple/test-module-loading.js +++ b/test/simple/test-module-loading.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-net-binary.js b/test/simple/test-net-binary.js index 616e065265..80f9eea0ec 100644 --- a/test/simple/test-net-binary.js +++ b/test/simple/test-net-binary.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-net-can-reset-timeout.js b/test/simple/test-net-can-reset-timeout.js index c1b46ac53e..bb9b071427 100644 --- a/test/simple/test-net-can-reset-timeout.js +++ b/test/simple/test-net-can-reset-timeout.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var net = require('net'); var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-net-connect-buffer.js b/test/simple/test-net-connect-buffer.js index 4843f43d94..42cda79796 100644 --- a/test/simple/test-net-connect-buffer.js +++ b/test/simple/test-net-connect-buffer.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-net-connect-handle-econnrefused.js b/test/simple/test-net-connect-handle-econnrefused.js index a96473dc1a..17e9d993fa 100644 --- a/test/simple/test-net-connect-handle-econnrefused.js +++ b/test/simple/test-net-connect-handle-econnrefused.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var net = require('net'); var assert = require('assert'); diff --git a/test/simple/test-net-connect-timeout.js b/test/simple/test-net-connect-timeout.js index ad7dfa92ae..33a45a0908 100644 --- a/test/simple/test-net-connect-timeout.js +++ b/test/simple/test-net-connect-timeout.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // This example attempts to time out before the connection is established // https://groups.google.com/forum/#!topic/nodejs/UE0ZbfLt6t8 // https://groups.google.com/forum/#!topic/nodejs-dev/jR7-5UDqXkw diff --git a/test/simple/test-net-eaddrinuse.js b/test/simple/test-net-eaddrinuse.js index 85f5942baf..aa3666a189 100644 --- a/test/simple/test-net-eaddrinuse.js +++ b/test/simple/test-net-eaddrinuse.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-net-isip.js b/test/simple/test-net-isip.js index 92ebaaf76d..c226f1a9d3 100644 --- a/test/simple/test-net-isip.js +++ b/test/simple/test-net-isip.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-net-keepalive.js b/test/simple/test-net-keepalive.js index f66a193626..4da5efce2e 100644 --- a/test/simple/test-net-keepalive.js +++ b/test/simple/test-net-keepalive.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-net-pingpong.js b/test/simple/test-net-pingpong.js index da4be51c3c..f20ec057f3 100644 --- a/test/simple/test-net-pingpong.js +++ b/test/simple/test-net-pingpong.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-net-reconnect.js b/test/simple/test-net-reconnect.js index 65b582ab4c..8455f1689e 100644 --- a/test/simple/test-net-reconnect.js +++ b/test/simple/test-net-reconnect.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-net-server-bind.js b/test/simple/test-net-server-bind.js index 098155d112..b5b83bf2fe 100644 --- a/test/simple/test-net-server-bind.js +++ b/test/simple/test-net-server-bind.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-net-server-max-connections.js b/test/simple/test-net-server-max-connections.js index 293880931c..f45c1e53d3 100644 --- a/test/simple/test-net-server-max-connections.js +++ b/test/simple/test-net-server-max-connections.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-net-server-on-fd-0.js b/test/simple/test-net-server-on-fd-0.js new file mode 100644 index 0000000000..21b73c8717 --- /dev/null +++ b/test/simple/test-net-server-on-fd-0.js @@ -0,0 +1,48 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var common = require('../common'); +var assert = require('assert'); +var net = require('net'); + +process.stdin.destroy(); + +var accepted = null; +var server = net.createServer(function(socket) { + console.log('accepted'); + accepted = socket; + socket.end(); + server.close(); +}); + + +server.listen(common.PORT, function() { + console.log('listening...'); + assert.equal(server.fd, 0); + + net.createConnection(common.PORT); +}); + + +process.on('exit', function() { + assert.ok(accepted); +}); + diff --git a/test/simple/test-net-server-try-ports.js b/test/simple/test-net-server-try-ports.js index 91b8982a0c..6dc8ee5361 100644 --- a/test/simple/test-net-server-try-ports.js +++ b/test/simple/test-net-server-try-ports.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // This tests binds to one port, then attempts to start a server on that // port. It should be EADDRINUSE but be able to then bind to another port. var common = require('../common'); diff --git a/test/simple/test-net-socket-timeout.js b/test/simple/test-net-socket-timeout.js index c4d84fa177..2256d6813a 100644 --- a/test/simple/test-net-socket-timeout.js +++ b/test/simple/test-net-socket-timeout.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var net = require('net'); var assert = require('assert'); diff --git a/test/simple/test-net-stream.js b/test/simple/test-net-stream.js new file mode 100644 index 0000000000..868e336b9c --- /dev/null +++ b/test/simple/test-net-stream.js @@ -0,0 +1,37 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var common = require('../common'); +var assert = require('assert'); + +var Stream = require('net').Stream; + +var s = new Stream(); + +// test that destroy called on a stream with a server only ever decrements the +// server connection count once + +s.server = { connections: 10 } +assert.equal(10, s.server.connections); +s.destroy() +assert.equal(9, s.server.connections); +s.destroy() +assert.equal(9, s.server.connections); diff --git a/test/simple/test-next-tick-errors.js b/test/simple/test-next-tick-errors.js index 9188548c6d..ea895fd068 100644 --- a/test/simple/test-next-tick-errors.js +++ b/test/simple/test-next-tick-errors.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-next-tick-ordering.js b/test/simple/test-next-tick-ordering.js index d4b565a4a4..f392bb29b7 100644 --- a/test/simple/test-next-tick-ordering.js +++ b/test/simple/test-next-tick-ordering.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var i; diff --git a/test/simple/test-next-tick-ordering2.js b/test/simple/test-next-tick-ordering2.js index 2da24e1f14..c845b98683 100644 --- a/test/simple/test-next-tick-ordering2.js +++ b/test/simple/test-next-tick-ordering2.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-next-tick.js b/test/simple/test-next-tick.js index 45c6e96d72..1c9a51d0e0 100644 --- a/test/simple/test-next-tick.js +++ b/test/simple/test-next-tick.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-os.js b/test/simple/test-os.js index 25cabab3f9..5903f8f6b1 100644 --- a/test/simple/test-os.js +++ b/test/simple/test-os.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var os = require('os'); diff --git a/test/simple/test-path.js b/test/simple/test-path.js index 92d160ff22..734fcaf2cf 100644 --- a/test/simple/test-path.js +++ b/test/simple/test-path.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-pipe-file-to-http.js b/test/simple/test-pipe-file-to-http.js index 0565232663..d43eb7f7f7 100644 --- a/test/simple/test-pipe-file-to-http.js +++ b/test/simple/test-pipe-file-to-http.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var fs = require('fs'); diff --git a/test/simple/test-pipe-head.js b/test/simple/test-pipe-head.js index a77e739e15..636f90ceee 100644 --- a/test/simple/test-pipe-head.js +++ b/test/simple/test-pipe-head.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-pipe.js b/test/simple/test-pipe.js index f52a875ce6..d28abff50a 100644 --- a/test/simple/test-pipe.js +++ b/test/simple/test-pipe.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var http = require('http'); diff --git a/test/simple/test-process-env.js b/test/simple/test-process-env.js index b193e46248..725962d34b 100644 --- a/test/simple/test-process-env.js +++ b/test/simple/test-process-env.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // first things first, set the timezone; see tzset(3) process.env.TZ = 'Europe/Amsterdam'; diff --git a/test/simple/test-process-kill-null.js b/test/simple/test-process-kill-null.js index d45ea9f9f7..f61487e9ad 100644 --- a/test/simple/test-process-kill-null.js +++ b/test/simple/test-process-kill-null.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var assert = require('assert'); var spawn = require('child_process').spawn; diff --git a/test/simple/test-pump-file2tcp-noexist.js b/test/simple/test-pump-file2tcp-noexist.js index d7b59b150c..642849018a 100644 --- a/test/simple/test-pump-file2tcp-noexist.js +++ b/test/simple/test-pump-file2tcp-noexist.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-pump-file2tcp.js b/test/simple/test-pump-file2tcp.js index 56eba6da53..b9250cc03f 100644 --- a/test/simple/test-pump-file2tcp.js +++ b/test/simple/test-pump-file2tcp.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var net = require('net'); diff --git a/test/simple/test-querystring.js b/test/simple/test-querystring.js index 0327191d70..8e30dae1e5 100644 --- a/test/simple/test-querystring.js +++ b/test/simple/test-querystring.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-readdir.js b/test/simple/test-readdir.js index a2041d4cde..8bdbf1d854 100644 --- a/test/simple/test-readdir.js +++ b/test/simple/test-readdir.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-regression-object-prototype.js b/test/simple/test-regression-object-prototype.js index 17fe1727d3..158532ad87 100644 --- a/test/simple/test-regression-object-prototype.js +++ b/test/simple/test-regression-object-prototype.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + //console.log('puts before'); Object.prototype.xadsadsdasasdxx = function() { diff --git a/test/simple/test-repl.js b/test/simple/test-repl.js index d22f083afe..3183fa1b63 100644 --- a/test/simple/test-repl.js +++ b/test/simple/test-repl.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-require-cache-without-stat.js b/test/simple/test-require-cache-without-stat.js index b9f000a9a5..9e6b0aa881 100644 --- a/test/simple/test-require-cache-without-stat.js +++ b/test/simple/test-require-cache-without-stat.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // We've experienced a regression where the module loader stats a bunch of // directories on require() even if it's been called before. The require() // should caching the request. diff --git a/test/simple/test-require-cache.js b/test/simple/test-require-cache.js index a069d0a799..2f812044a7 100644 --- a/test/simple/test-require-cache.js +++ b/test/simple/test-require-cache.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-require-exceptions.js b/test/simple/test-require-exceptions.js index 6dc12212ae..16280016db 100644 --- a/test/simple/test-require-exceptions.js +++ b/test/simple/test-require-exceptions.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-require-resolve.js b/test/simple/test-require-resolve.js index 07f7da46b3..1e4ff7f09f 100644 --- a/test/simple/test-require-resolve.js +++ b/test/simple/test-require-resolve.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var fixturesDir = common.fixturesDir; var assert = require('assert'); diff --git a/test/simple/test-script-context.js b/test/simple/test-script-context.js index 52a3e21bfa..a7f853797f 100644 --- a/test/simple/test-script-context.js +++ b/test/simple/test-script-context.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-script-new.js b/test/simple/test-script-new.js index e513126f29..7894bb9fa9 100644 --- a/test/simple/test-script-new.js +++ b/test/simple/test-script-new.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var Script = require('vm').Script; diff --git a/test/simple/test-script-static-context.js b/test/simple/test-script-static-context.js index 0503da3431..d2cb701816 100644 --- a/test/simple/test-script-static-context.js +++ b/test/simple/test-script-static-context.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-script-static-new.js b/test/simple/test-script-static-new.js index 502e0a8d47..eaac2d97c0 100644 --- a/test/simple/test-script-static-new.js +++ b/test/simple/test-script-static-new.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var Script = require('vm').Script; diff --git a/test/simple/test-script-static-this.js b/test/simple/test-script-static-this.js index e46c4c7536..63c11331e9 100644 --- a/test/simple/test-script-static-this.js +++ b/test/simple/test-script-static-this.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var Script = require('vm').Script; diff --git a/test/simple/test-script-this.js b/test/simple/test-script-this.js index c82c7e20ff..a55a490973 100644 --- a/test/simple/test-script-this.js +++ b/test/simple/test-script-this.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var Script = require('vm').Script; diff --git a/test/simple/test-sendfd.js b/test/simple/test-sendfd.js index 28586a606b..bb39c28f62 100644 --- a/test/simple/test-sendfd.js +++ b/test/simple/test-sendfd.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Test sending and receiving a file descriptor. // // This test is pretty complex. It ends up spawning test/fixtures/recvfd.js diff --git a/test/simple/test-sigint-infinite-loop.js b/test/simple/test-sigint-infinite-loop.js index c444caf419..f970d9eed9 100644 --- a/test/simple/test-sigint-infinite-loop.js +++ b/test/simple/test-sigint-infinite-loop.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // This test is to assert that we can SIGINT a script which loops forever. // Ref(http): // groups.google.com/group/nodejs-dev/browse_thread/thread/e20f2f8df0296d3f diff --git a/test/simple/test-signal-handler.js b/test/simple/test-signal-handler.js index 9866fd6693..2a3b72998f 100644 --- a/test/simple/test-signal-handler.js +++ b/test/simple/test-signal-handler.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-signal-unregister.js b/test/simple/test-signal-unregister.js index 12f3f0cab9..0b3f04fa55 100644 --- a/test/simple/test-signal-unregister.js +++ b/test/simple/test-signal-unregister.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-stdin-from-file.js b/test/simple/test-stdin-from-file.js index b429fb7211..b165e4c4e4 100644 --- a/test/simple/test-stdin-from-file.js +++ b/test/simple/test-stdin-from-file.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var join = require('path').join; diff --git a/test/simple/test-stdout-to-file.js b/test/simple/test-stdout-to-file.js index 44206589a2..9c99bcc19f 100644 --- a/test/simple/test-stdout-to-file.js +++ b/test/simple/test-stdout-to-file.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-stream-pipe-event.js b/test/simple/test-stream-pipe-event.js index a480d60f90..868158f2a6 100644 --- a/test/simple/test-stream-pipe-event.js +++ b/test/simple/test-stream-pipe-event.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var stream = require('stream'); var assert = require('assert'); var util = require('util'); diff --git a/test/simple/test-string-decoder.js b/test/simple/test-string-decoder.js index f49d589167..f0a9db8921 100644 --- a/test/simple/test-string-decoder.js +++ b/test/simple/test-string-decoder.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var StringDecoder = require('string_decoder').StringDecoder; diff --git a/test/simple/test-sync-fileread.js b/test/simple/test-sync-fileread.js index 3f5f6debd5..cc161aa648 100644 --- a/test/simple/test-sync-fileread.js +++ b/test/simple/test-sync-fileread.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/simple/test-sys.js b/test/simple/test-sys.js index 5047787491..1456ec8b0f 100644 --- a/test/simple/test-sys.js +++ b/test/simple/test-sys.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-timers-linked-list.js b/test/simple/test-timers-linked-list.js index 26bf0525ab..a1b8f0625f 100644 --- a/test/simple/test-timers-linked-list.js +++ b/test/simple/test-timers-linked-list.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var L = require('_linklist'); diff --git a/test/simple/test-tls-client-verify.js b/test/simple/test-tls-client-verify.js index 923153b441..0e6ef790da 100644 --- a/test/simple/test-tls-client-verify.js +++ b/test/simple/test-tls-client-verify.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + if (!process.versions.openssl) { console.error("Skipping because node compiled without OpenSSL."); process.exit(0); diff --git a/test/simple/test-tls-ext-key-usage.js b/test/simple/test-tls-ext-key-usage.js index 75c376f4f2..57d2f3b882 100644 --- a/test/simple/test-tls-ext-key-usage.js +++ b/test/simple/test-tls-ext-key-usage.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // There is a bug with 'openssl s_server' which makes it not flush certain // important events to stdout when done over a pipe. Therefore we skip this // test for all openssl versions less than 1.0.0. diff --git a/test/simple/test-tls-junk-closes-server.js b/test/simple/test-tls-junk-closes-server.js index f76a157381..2a163891df 100644 --- a/test/simple/test-tls-junk-closes-server.js +++ b/test/simple/test-tls-junk-closes-server.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + if (!process.versions.openssl) { console.error("Skipping because node compiled without OpenSSL."); process.exit(0); diff --git a/test/simple/test-tls-securepair-client.js b/test/simple/test-tls-securepair-client.js index 86e0b7c05f..48103960c0 100644 --- a/test/simple/test-tls-securepair-client.js +++ b/test/simple/test-tls-securepair-client.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // There is a bug with 'openssl s_server' which makes it not flush certain // important events to stdout when done over a pipe. Therefore we skip this // test for all openssl versions less than 1.0.0. diff --git a/test/simple/test-tls-securepair-server.js b/test/simple/test-tls-securepair-server.js index 86998b65fe..124c045a03 100644 --- a/test/simple/test-tls-securepair-server.js +++ b/test/simple/test-tls-securepair-server.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + if (!process.versions.openssl) { console.error("Skipping because node compiled without OpenSSL."); process.exit(0); diff --git a/test/simple/test-tls-server-verify.js b/test/simple/test-tls-server-verify.js index 2836da12ff..ce4ac567c0 100644 --- a/test/simple/test-tls-server-verify.js +++ b/test/simple/test-tls-server-verify.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + if (!process.versions.openssl) { console.error("Skipping because node compiled without OpenSSL."); process.exit(0); diff --git a/test/simple/test-tls-set-encoding.js b/test/simple/test-tls-set-encoding.js index ce6e419b94..6634110fee 100644 --- a/test/simple/test-tls-set-encoding.js +++ b/test/simple/test-tls-set-encoding.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); var tls = require('tls'); diff --git a/test/simple/test-tty-stdout-end.js b/test/simple/test-tty-stdout-end.js new file mode 100644 index 0000000000..c79e029e1e --- /dev/null +++ b/test/simple/test-tty-stdout-end.js @@ -0,0 +1,35 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// Can't test this when 'make test' doesn't assign a tty to the stdout. +var common = require('../common'); +var assert = require('assert'); +var tty = require('tty'); + +var closed = false; +process.stdout.on('close', function() { + closed = true; +}); +process.on('exit', function() { + assert.ok(closed); +}); + +process.stdout.end(); diff --git a/test/simple/test-umask.js b/test/simple/test-umask.js index cd6d6c997a..7b7fa9bf94 100644 --- a/test/simple/test-umask.js +++ b/test/simple/test-umask.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-url.js b/test/simple/test-url.js index 91509b2baa..4f3d139ca9 100644 --- a/test/simple/test-url.js +++ b/test/simple/test-url.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); @@ -28,7 +49,8 @@ var parseTests = { 'pathname': '/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=' }, 'http://mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=' : { - 'href': 'http://mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=', + 'href': 'http://mt0.google.com/vt/lyrs=m@114???&hl=en&src=api' + + '&x=2&y=2&z=3&s=', 'protocol': 'http:', 'host': 'mt0.google.com', 'hostname': 'mt0.google.com', @@ -37,7 +59,8 @@ var parseTests = { 'pathname': '/vt/lyrs=m@114' }, 'http://user:pass@mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=' : { - 'href': 'http://user:pass@mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=', + 'href': 'http://user:pass@mt0.google.com/vt/lyrs=m@114???' + + '&hl=en&src=api&x=2&y=2&z=3&s=', 'protocol': 'http:', 'host': 'user:pass@mt0.google.com', 'auth': 'user:pass', @@ -84,49 +107,6 @@ var parseTests = { 'query': 'baz=quux', 'pathname': '/foo/bar' }, - 'http://example.com?foo=bar#frag' : { - 'href': 'http://example.com?foo=bar#frag', - 'protocol': 'http:', - 'host': 'example.com', - 'hostname': 'example.com', - 'hash': '#frag', - 'search': '?foo=bar', - 'query': 'foo=bar' - }, - 'http://example.com?foo=@bar#frag' : { - 'href': 'http://example.com?foo=@bar#frag', - 'protocol': 'http:', - 'host': 'example.com', - 'hostname': 'example.com', - 'hash': '#frag', - 'search': '?foo=@bar', - 'query': 'foo=@bar' - }, - 'http://example.com?foo=/bar/#frag' : { - 'href': 'http://example.com?foo=/bar/#frag', - 'protocol': 'http:', - 'host': 'example.com', - 'hostname': 'example.com', - 'hash': '#frag', - 'search': '?foo=/bar/', - 'query': 'foo=/bar/' - }, - 'http://example.com?foo=?bar/#frag' : { - 'href': 'http://example.com?foo=?bar/#frag', - 'protocol': 'http:', - 'host': 'example.com', - 'hostname': 'example.com', - 'hash': '#frag', - 'search': '?foo=?bar/', - 'query': 'foo=?bar/' - }, - 'http://example.com#frag=?bar/#frag' : { - 'href': 'http://example.com#frag=?bar/#frag', - 'protocol': 'http:', - 'host': 'example.com', - 'hostname': 'example.com', - 'hash': '#frag=?bar/#frag' - }, '/foo/bar?baz=quux#frag' : { 'href': '/foo/bar?baz=quux#frag', 'hash': '#frag', @@ -154,9 +134,7 @@ var parseTests = { 'javascript:alert(\'hello\');' : { 'href': 'javascript:alert(\'hello\');', 'protocol': 'javascript:', - 'host': 'alert(\'hello\')', - 'hostname': 'alert(\'hello\')', - 'pathname' : ';' + 'pathname': 'alert(\'hello\');' }, 'xmpp:isaacschlueter@jabber.org' : { 'href': 'xmpp:isaacschlueter@jabber.org', @@ -194,21 +172,13 @@ var parseTestsWithQueryString = { 'pathname': '/foo/bar' }, 'http://example.com' : { - 'href': 'http://example.com', + 'href': 'http://example.com/', 'protocol': 'http:', 'slashes': true, 'host': 'example.com', 'hostname': 'example.com', - 'query': {} - }, - 'http://example.com?' : { - 'href': 'http://example.com?', - 'protocol': 'http:', - 'slashes': true, - 'host': 'example.com', - 'hostname': 'example.com', - 'search': '?', - 'query': {} + 'query': {}, + 'pathname': '/' } }; for (var u in parseTestsWithQueryString) { @@ -225,7 +195,72 @@ for (var u in parseTestsWithQueryString) { // some extra formatting tests, just to verify // that it'll format slightly wonky content to a valid url. var formatTests = { + 'http://example.com?' : { + 'href': 'http://example.com/?', + 'protocol': 'http:', + 'slashes': true, + 'host': 'example.com', + 'hostname': 'example.com', + 'search': '?', + 'query': {}, + 'pathname': '/' + }, + 'http://example.com?foo=bar#frag' : { + 'href': 'http://example.com/?foo=bar#frag', + 'protocol': 'http:', + 'host': 'example.com', + 'hostname': 'example.com', + 'hash': '#frag', + 'search': '?foo=bar', + 'query': 'foo=bar', + 'pathname': '/' + }, + 'http://example.com?foo=@bar#frag' : { + 'href': 'http://example.com/?foo=@bar#frag', + 'protocol': 'http:', + 'host': 'example.com', + 'hostname': 'example.com', + 'hash': '#frag', + 'search': '?foo=@bar', + 'query': 'foo=@bar', + 'pathname': '/' + }, + 'http://example.com?foo=/bar/#frag' : { + 'href': 'http://example.com/?foo=/bar/#frag', + 'protocol': 'http:', + 'host': 'example.com', + 'hostname': 'example.com', + 'hash': '#frag', + 'search': '?foo=/bar/', + 'query': 'foo=/bar/', + 'pathname': '/' + }, + 'http://example.com?foo=?bar/#frag' : { + 'href': 'http://example.com/?foo=?bar/#frag', + 'protocol': 'http:', + 'host': 'example.com', + 'hostname': 'example.com', + 'hash': '#frag', + 'search': '?foo=?bar/', + 'query': 'foo=?bar/', + 'pathname': '/' + }, + 'http://example.com#frag=?bar/#frag' : { + 'href': 'http://example.com/#frag=?bar/#frag', + 'protocol': 'http:', + 'host': 'example.com', + 'hostname': 'example.com', + 'hash': '#frag=?bar/#frag', + 'pathname': '/' + }, + 'http://google.com" onload="alert(42)/' : { + 'href': 'http://google.com/', + 'protocol': 'http:', + 'host': 'google.com', + 'pathname': '/' + }, 'http://a.com/a/b/c?s#h' : { + 'href': 'http://a.com/a/b/c?s#h', 'protocol': 'http', 'host': 'a.com', 'pathname': 'a/b/c', @@ -233,7 +268,7 @@ var formatTests = { 'search': 's' }, 'xmpp:isaacschlueter@jabber.org' : { - 'href': 'xmpp://isaacschlueter@jabber.org', + 'href': 'xmpp:isaacschlueter@jabber.org', 'protocol': 'xmpp:', 'host': 'isaacschlueter@jabber.org', 'auth': 'isaacschlueter', @@ -241,9 +276,17 @@ var formatTests = { } }; for (var u in formatTests) { - var actual = url.format(formatTests[u]); - assert.equal(actual, u, - 'wonky format(' + u + ') == ' + u + '\nactual:' + actual); + var expect = formatTests[u].href; + delete formatTests[u].href; + var actual = url.format(u); + var actualObj = url.format(formatTests[u]); + assert.equal(actual, expect, + 'wonky format(' + u + ') == ' + expect + + '\nactual:' + actual); + assert.equal(actualObj, expect, + 'wonky format(' + JSON.stringify(formatTests[u]) + + ') == ' + expect + + '\nactual: ' + actualObj); } /* diff --git a/test/simple/test-utf8-scripts.js b/test/simple/test-utf8-scripts.js index b9bef97a5e..4639304f87 100644 --- a/test/simple/test-utf8-scripts.js +++ b/test/simple/test-utf8-scripts.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + var common = require('../common'); var assert = require('assert'); diff --git a/test/simple/test-zerolengthbufferbug.js b/test/simple/test-zerolengthbufferbug.js index 25c1f26c30..819ef25dc3 100644 --- a/test/simple/test-zerolengthbufferbug.js +++ b/test/simple/test-zerolengthbufferbug.js @@ -1,3 +1,24 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // Serving up a zero-length buffer should work. var common = require('../common'); diff --git a/tools/js2c.py b/tools/js2c.py index 8ef644ee19..fd8b25b1a4 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -53,7 +53,7 @@ def ToCArray(filename, lines): value = ord(chr) - if value > 128: + if value >= 128: print 'non-ascii value ' + filename + ':' + str(row) + ':' + str(col) sys.exit(1); @@ -220,6 +220,7 @@ namespace node { struct _native { const char* name; const char* source; + size_t source_len; }; static const struct _native natives[] = { @@ -236,7 +237,7 @@ static const struct _native natives[] = { NATIVE_DECLARATION = """\ - { "%(id)s", %(id)s_native }, + { "%(id)s", %(id)s_native, sizeof(%(id)s_native)-1 }, """ SOURCE_DECLARATION = """\ diff --git a/wscript b/wscript index 526195456d..e0f1748fad 100644 --- a/wscript +++ b/wscript @@ -1,4 +1,26 @@ #!/usr/bin/env python + +# Copyright Joyent, Inc. and other Node contributors. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to the +# following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +# USE OR OTHER DEALINGS IN THE SOFTWARE. + import re import Options import sys, os, shutil, glob @@ -818,6 +840,7 @@ def build(bld): src/node_script.cc src/node_os.cc src/node_dtrace.cc + src/node_string.cc """ if sys.platform.startswith("win32"): @@ -860,7 +883,7 @@ def build(bld): , 'CPPFLAGS' : " ".join(program.env["CPPFLAGS"]).replace('"', '\\"') , 'LIBFLAGS' : " ".join(program.env["LIBFLAGS"]).replace('"', '\\"') , 'PREFIX' : safe_path(program.env["PREFIX"]) - , 'VERSION' : '0.4.1' # FIXME should not be hard-coded, see NODE_VERSION_STRING in src/node_version. + , 'VERSION' : '0.4.2' # FIXME should not be hard-coded, see NODE_VERSION_STRING in src/node_version. } return x